HighZSecondAsymptote.java

  1. package org.drip.sample.bessel;

  2. import org.drip.function.definition.R1ToR1;
  3. import org.drip.numerical.common.FormatUtil;
  4. import org.drip.service.env.EnvManager;
  5. import org.drip.specialfunction.bessel.FirstFrobeniusSeriesEstimator;
  6. import org.drip.specialfunction.bessel.SecondNISTSeriesEstimator;
  7. import org.drip.specialfunction.definition.BesselSecondKindEstimator;
  8. import org.drip.specialfunction.digamma.BinetFirstIntegral;
  9. import org.drip.specialfunction.gamma.EulerIntegralSecondKind;

  10. /*
  11.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  12.  */

  13. /*!
  14.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  15.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  16.  *
  17.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  18.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  19.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  20.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  21.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  22.  *      and computational support.
  23.  *  
  24.  *      https://lakshmidrip.github.io/DROP/
  25.  *  
  26.  *  DROP is composed of three modules:
  27.  *  
  28.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  29.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  30.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  31.  *
  32.  *  DROP Product Core implements libraries for the following:
  33.  *  - Fixed Income Analytics
  34.  *  - Loan Analytics
  35.  *  - Transaction Cost Analytics
  36.  *
  37.  *  DROP Portfolio Core implements libraries for the following:
  38.  *  - Asset Allocation Analytics
  39.  *  - Asset Liability Management Analytics
  40.  *  - Capital Estimation Analytics
  41.  *  - Exposure Analytics
  42.  *  - Margin Analytics
  43.  *  - XVA Analytics
  44.  *
  45.  *  DROP Computational Core implements libraries for the following:
  46.  *  - Algorithm Support
  47.  *  - Computation Support
  48.  *  - Function Analysis
  49.  *  - Model Validation
  50.  *  - Numerical Analysis
  51.  *  - Numerical Optimizer
  52.  *  - Spline Builder
  53.  *  - Statistical Learning
  54.  *
  55.  *  Documentation for DROP is Spread Over:
  56.  *
  57.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  58.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  59.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  60.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  61.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  62.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  63.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  64.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  65.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  66.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  67.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  68.  *
  69.  *  Licensed under the Apache License, Version 2.0 (the "License");
  70.  *      you may not use this file except in compliance with the License.
  71.  *  
  72.  *  You may obtain a copy of the License at
  73.  *      http://www.apache.org/licenses/LICENSE-2.0
  74.  *  
  75.  *  Unless required by applicable law or agreed to in writing, software
  76.  *      distributed under the License is distributed on an "AS IS" BASIS,
  77.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  78.  *  
  79.  *  See the License for the specific language governing permissions and
  80.  *      limitations under the License.
  81.  */

  82. /**
  83.  * <i>HighZSecondAsymptote</i> illustrates the High z Estimation for the Cylindrical Bessel Function of the
  84.  * Second Kind. The References are:
  85.  *
  86.  * <br><br>
  87.  *  <ul>
  88.  *      <li>
  89.  *          Abramowitz, M., and I. A. Stegun (2007): <i>Handbook of Mathematics Functions</i> <b>Dover Book
  90.  *              on Mathematics</b>
  91.  *      </li>
  92.  *      <li>
  93.  *          Arfken, G. B., and H. J. Weber (2005): <i>Mathematical Methods for Physicists 6<sup>th</sup>
  94.  *              Edition</i> <b>Harcourt</b> San Diego
  95.  *      </li>
  96.  *      <li>
  97.  *          Temme N. M. (1996): <i>Special Functions: An Introduction to the Classical Functions of
  98.  *              Mathematical Physics 2<sup>nd</sup> Edition</i> <b>Wiley</b> New York
  99.  *      </li>
  100.  *      <li>
  101.  *          Watson, G. N. (1995): <i>A Treatise on the Theory of Bessel Functions</i> <b>Cambridge University
  102.  *              Press</b>
  103.  *      </li>
  104.  *      <li>
  105.  *          Wikipedia (2019): Bessel Function https://en.wikipedia.org/wiki/Bessel_function
  106.  *      </li>
  107.  *  </ul>
  108.  *
  109.  *  <br><br>
  110.  *  <ul>
  111.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  112.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FunctionAnalysisLibrary.md">Function Analysis Library</a></li>
  113.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">DROP API Construction and Usage</a></li>
  114.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/bessel/README.md">Estimates of the Bessel Functions</a></li>
  115.  *  </ul>
  116.  *
  117.  * @author Lakshmi Krishnamurthy
  118.  */

  119. public class HighZSecondAsymptote
  120. {

  121.     private static final void BesselY (
  122.         final BesselSecondKindEstimator besselSecondKindEstimatorAsymptote,
  123.         final BesselSecondKindEstimator besselSecondKindEstimator,
  124.         final double[] alphaArray,
  125.         final double[] zArray)
  126.         throws Exception
  127.     {
  128.         System.out.println ("\t|-----------------------------------------------||");

  129.         System.out.println ("\t|   HIGH z BESSEL SECOND ASYMPTOTE COMPARISON   ||");

  130.         System.out.println ("\t|-----------------------------------------------||");

  131.         System.out.println ("\t|        L -> R:                                ||");

  132.         System.out.println ("\t|                - Alpha                        ||");

  133.         System.out.println ("\t|                - z                            ||");

  134.         System.out.println ("\t|                - Bessel Asymptote             ||");

  135.         System.out.println ("\t|                - Bessel Frobenius             ||");

  136.         System.out.println ("\t|-----------------------------------------------||");

  137.         for (double alpha : alphaArray)
  138.         {
  139.             for (double z : zArray)
  140.             {
  141.                 String display = "\t| [" +
  142.                     FormatUtil.FormatDouble (alpha, 1, 2, 1., false) + ", " +
  143.                     FormatUtil.FormatDouble (z, 2, 1, 1., false) + "] => " +
  144.                     FormatUtil.FormatDouble (
  145.                         besselSecondKindEstimatorAsymptote.bigY (
  146.                             alpha,
  147.                             z
  148.                         ), 1, 10, 1.
  149.                     ) + " | " +
  150.                     FormatUtil.FormatDouble (
  151.                         besselSecondKindEstimator.bigY (
  152.                             alpha,
  153.                             z
  154.                         ), 1, 10, 1.
  155.                     ) + " |";

  156.                 System.out.println (display + "|");
  157.             }

  158.             System.out.println ("\t|-----------------------------------------------||");
  159.         }

  160.         System.out.println();
  161.     }

  162.     public static final void main (
  163.         final String[] argumentArray)
  164.         throws Exception
  165.     {
  166.         EnvManager.InitEnv ("");

  167.         int besselFirstTermCount = 80;
  168.         int besselSecondTermCount = 80;
  169.         double[] zArray =
  170.         {
  171.              0.,
  172.              2.,
  173.              4.,
  174.              6.,
  175.              8.,
  176.             10.,
  177.             12.,
  178.             14.,
  179.             16.,
  180.             18.,
  181.             20.,
  182.             22.,
  183.             24.,
  184.             26.,
  185.             28.,
  186.             30.,
  187.         };
  188.         double[] alphaArray =
  189.         {
  190.             0.00,
  191.             1.00,
  192.             2.00,
  193.             3.00,
  194.             4.00,
  195.         };

  196.         R1ToR1 gammaEstimator = new EulerIntegralSecondKind (null);

  197.         BesselY (
  198.             BesselSecondKindEstimator.HighZAsymptote(),
  199.             SecondNISTSeriesEstimator.Standard (
  200.                 new BinetFirstIntegral (null),
  201.                 gammaEstimator,
  202.                 FirstFrobeniusSeriesEstimator.Standard (
  203.                     gammaEstimator,
  204.                     besselFirstTermCount
  205.                 ),
  206.                 besselSecondTermCount
  207.             ),
  208.             alphaArray,
  209.             zArray
  210.         );

  211.         EnvManager.TerminateEnv();
  212.     }
  213. }