GesselStantonKoepfProperty2.java

  1. package org.drip.sample.hypergeometric;

  2. import org.drip.function.definition.R1PropertyVerification;
  3. import org.drip.function.definition.R2ToR1Property;
  4. import org.drip.numerical.common.FormatUtil;
  5. import org.drip.service.env.EnvManager;
  6. import org.drip.specialfunction.property.HypergeometricEqualityLemma;

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

  10. /*!
  11.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  12.  *
  13.  *  This file is part of DROP, an open-source library targeting risk, transaction costs, exposure, margin
  14.  *      calculations, and portfolio construction within and across fixed income, credit, commodity, equity,
  15.  *      FX, and structured products.
  16.  *  
  17.  *      https://lakshmidrip.github.io/DROP/
  18.  *  
  19.  *  DROP is composed of three main modules:
  20.  *  
  21.  *  - DROP Analytics Core - https://lakshmidrip.github.io/DROP-Analytics-Core/
  22.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  23.  *  - DROP Numerical Core - https://lakshmidrip.github.io/DROP-Numerical-Core/
  24.  *
  25.  *  DROP Analytics Core implements libraries for the following:
  26.  *  - Fixed Income Analytics
  27.  *  - Asset Backed Analytics
  28.  *  - XVA Analytics
  29.  *  - Exposure and Margin Analytics
  30.  *
  31.  *  DROP Portfolio Core implements libraries for the following:
  32.  *  - Asset Allocation Analytics
  33.  *  - Transaction Cost Analytics
  34.  *
  35.  *  DROP Numerical Core implements libraries for the following:
  36.  *  - Statistical Learning Library
  37.  *  - Numerical Optimizer Library
  38.  *  - Machine Learning Library
  39.  *  - Spline Builder Library
  40.  *
  41.  *  Documentation for DROP is Spread Over:
  42.  *
  43.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  44.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  45.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  46.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  47.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  48.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  49.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  50.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  51.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  52.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  53.  *
  54.  *  Licensed under the Apache License, Version 2.0 (the "License");
  55.  *      you may not use this file except in compliance with the License.
  56.  *  
  57.  *  You may obtain a copy of the License at
  58.  *      http://www.apache.org/licenses/LICENSE-2.0
  59.  *  
  60.  *  Unless required by applicable law or agreed to in writing, software
  61.  *      distributed under the License is distributed on an "AS IS" BASIS,
  62.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  63.  *  
  64.  *  See the License for the specific language governing permissions and
  65.  *      limitations under the License.
  66.  */

  67. /**
  68.  * <i>GesselStantonKoepfProperty2</i> verifies the Second Gessel-Stanton-Koepf Identity Property Lemma for
  69.  * Rational Z. The References are:
  70.  *
  71.  * <br><br>
  72.  *  <ul>
  73.  *      <li>
  74.  *          Gessel, I., and D. Stanton (1982): Strange Evaluations of Hyper-geometric Series <i>SIAM Journal
  75.  *              on Mathematical Analysis</i> <b>13 (2)</b> 295-308
  76.  *      </li>
  77.  *      <li>
  78.  *          Koepf, W (1995): Algorithms for m-fold Hyper-geometric Summation <i>Journal of Symbolic
  79.  *              Computation</i> <b>20 (4)</b> 399-417
  80.  *      </li>
  81.  *      <li>
  82.  *          Lavoie, J. L., F. Grondin, and A. K. Rathie (1996): Generalization of Whipple’s Theorem on the
  83.  *              Sum of a (_2^3)F(a,b;c;z) <i>Journal of Computational and Applied Mathematics</i> <b>72</b>
  84.  *              293-300
  85.  *      </li>
  86.  *      <li>
  87.  *          National Institute of Standards and Technology (2019): Hyper-geometric Function
  88.  *              https://dlmf.nist.gov/15
  89.  *      </li>
  90.  *      <li>
  91.  *          Wikipedia (2019): Hyper-geometric Function https://en.wikipedia.org/wiki/Hypergeometric_function
  92.  *      </li>
  93.  *  </ul>
  94.  *
  95.  *  <br><br>
  96.  *  <ul>
  97.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalCore.md">Numerical Core Module</a></li>
  98.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalOptimizerLibrary.md">Numerical Optimizer</a></li>
  99.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Function</a></li>
  100.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/hypergeometric/README.md">Estimates of Hyper-geometric Function</a></li>
  101.  *  </ul>
  102.  *
  103.  * @author Lakshmi Krishnamurthy
  104.  */

  105. public class GesselStantonKoepfProperty2
  106. {

  107.     private static final void Verifier (
  108.         final double a,
  109.         final double[] zArray,
  110.         final R2ToR1Property gesselStantonKoepfProperty)
  111.         throws Exception
  112.     {
  113.         for (double z : zArray)
  114.         {
  115.             R1PropertyVerification propertyVerification = gesselStantonKoepfProperty.verify (
  116.                 a,
  117.                 z
  118.             );

  119.             System.out.println (
  120.                 "\t| {" + FormatUtil.FormatDouble (a, 1, 2, 1., false) + ", " +
  121.                     FormatUtil.FormatDouble (z, 1, 2, 1., false) + "} => " +
  122.                     FormatUtil.FormatDouble (propertyVerification.lValue(), 1, 10, 1.) + " | " +
  123.                     FormatUtil.FormatDouble (propertyVerification.rValue(), 1, 10, 1.) + " | " +
  124.                     propertyVerification.verified() + " ||"
  125.             );
  126.         }
  127.     }

  128.     public static final void main (
  129.         final String[] argumentArray)
  130.         throws Exception
  131.     {
  132.         EnvManager.InitEnv ("");

  133.         double[] aArray =
  134.         {
  135.             -0.10,
  136.             -0.20,
  137.             -0.30,
  138.             -0.40,
  139.             -0.50,
  140.         };
  141.         double[] zArray =
  142.         {
  143.             -Math.PI,
  144.             -0.50 * Math.PI,
  145.             -0.00,
  146.              0.50 * Math.PI,
  147.              Math.PI,
  148.         };

  149.         R2ToR1Property gesselStantonKoepfProperty = HypergeometricEqualityLemma.SecondGesselStantonKoepf();

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

  151.         System.out.println ("\t|    SECOND GESSEL STANTON KOEPF PROPERTY VERIFIER     ||");

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

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

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

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

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

  157.         System.out.println ("\t|                - Verified?                           ||");

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

  159.         for (double a : aArray)
  160.         {
  161.             Verifier (
  162.                 a,
  163.                 zArray,
  164.                 gesselStantonKoepfProperty
  165.             );
  166.         }

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

  168.         EnvManager.TerminateEnv();
  169.     }
  170. }