FirstSchlafliNonIntegerEstimate.java

  1. package org.drip.sample.bessel;

  2. import org.drip.numerical.common.FormatUtil;
  3. import org.drip.service.env.EnvManager;
  4. import org.drip.specialfunction.bessel.FirstSchlafliIntegralEstimator;

  5. /*
  6.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  7.  */

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

  77. /**
  78.  * <i>FirstSchlafliNonIntegerEstimate</i> illustrates the Schlafli Integral Based Estimation for the
  79.  * Cylindrical Bessel Function of the First Kind for Non-Integer Orders. The References are:
  80.  *
  81.  * <br><br>
  82.  *  <ul>
  83.  *      <li>
  84.  *          Abramowitz, M., and I. A. Stegun (2007): <i>Handbook of Mathematics Functions</i> <b>Dover Book
  85.  *              on Mathematics</b>
  86.  *      </li>
  87.  *      <li>
  88.  *          Arfken, G. B., and H. J. Weber (2005): <i>Mathematical Methods for Physicists 6<sup>th</sup>
  89.  *              Edition</i> <b>Harcourt</b> San Diego
  90.  *      </li>
  91.  *      <li>
  92.  *          Temme N. M. (1996): <i>Special Functions: An Introduction to the Classical Functions of
  93.  *              Mathematical Physics 2<sup>nd</sup> Edition</i> <b>Wiley</b> New York
  94.  *      </li>
  95.  *      <li>
  96.  *          Watson, G. N. (1995): <i>A Treatise on the Theory of Bessel Functions</i> <b>Cambridge University
  97.  *              Press</b>
  98.  *      </li>
  99.  *      <li>
  100.  *          Wikipedia (2019): Bessel Function https://en.wikipedia.org/wiki/Bessel_function
  101.  *      </li>
  102.  *  </ul>
  103.  *
  104.  *  <br><br>
  105.  *  <ul>
  106.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  107.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FunctionAnalysisLibrary.md">Function Analysis Library</a></li>
  108.  *      <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>
  109.  *      <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>
  110.  *  </ul>
  111.  *
  112.  * @author Lakshmi Krishnamurthy
  113.  */

  114. public class FirstSchlafliNonIntegerEstimate
  115. {

  116.     private static final void BesselJ (
  117.         final FirstSchlafliIntegralEstimator besselEstimator,
  118.         final int quadratureCount,
  119.         final double[] zArray,
  120.         final double[] alphaArray)
  121.         throws Exception
  122.     {
  123.         System.out.println ("\t|----------------------------------------------------------------------||");

  124.         System.out.println ("\t|         BESSEL FIRST KIND SCHLAFLI NON-INTEGER FORM ESTIMATE         ||");

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

  126.         System.out.println ("\t|    Quadrature Term Count => " + quadratureCount);

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

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

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

  130.         System.out.println ("\t|                - Alpha Bessel Estimate Row                           ||");

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

  132.         for (double z : zArray)
  133.         {
  134.             String display = "\t| [" + FormatUtil.FormatDouble (z, 2, 1, 1., false) + "] => ";

  135.             for (double alpha : alphaArray)
  136.             {
  137.                 display = display + " " + FormatUtil.FormatDouble (
  138.                     besselEstimator.bigJ (
  139.                         alpha,
  140.                         z
  141.                     ), 1, 6, 1.
  142.                 ) + " |";
  143.             }

  144.             System.out.println (display + "|");
  145.         }

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

  147.         System.out.println();
  148.     }

  149.     public static final void main (
  150.         final String[] argumentArray)
  151.         throws Exception
  152.     {
  153.         EnvManager.InitEnv ("");

  154.         int[] quadratureCountArray =
  155.         {
  156.             25,
  157.             50,
  158.             75,
  159.         };
  160.         double[] zArray =
  161.         {
  162.              1.,
  163.              2.,
  164.              3.,
  165.              4.,
  166.              5.,
  167.              6.,
  168.              7.,
  169.              8.,
  170.              9.,
  171.             10.,
  172.             11.,
  173.             12.,
  174.             13.,
  175.             14.,
  176.             15.,
  177.             16.,
  178.             17.,
  179.             18.,
  180.             19.,
  181.             20.,
  182.         };
  183.         double[] alphaArray =
  184.         {
  185.             0.0,
  186.             0.5,
  187.             1.0,
  188.             1.5,
  189.             2.0,
  190.         };

  191.         for (int quadratureCount : quadratureCountArray)
  192.         {
  193.             BesselJ (
  194.                 FirstSchlafliIntegralEstimator.NonIntegerForm (quadratureCount),
  195.                 quadratureCount,
  196.                 zArray,
  197.                 alphaArray
  198.             );
  199.         }

  200.         EnvManager.TerminateEnv();
  201.     }
  202. }