GaussContiguousEqualityLemma.java

  1. package org.drip.specialfunction.property;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

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

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

  112. public class GaussContiguousEqualityLemma
  113. {

  114.     /**
  115.      * Construct the Hyper-geometric Gauss Contiguous Identity #2 Verifier
  116.      *
  117.      * @param a A
  118.      * @param b B
  119.      * @param c C
  120.      *
  121.      * @return The Hyper-geometric Gauss Contiguous Identity #2 Verifier
  122.      */

  123.     public static final org.drip.function.definition.R1ToR1Property RelationIdentity2 (
  124.         final double a,
  125.         final double b,
  126.         final double c)
  127.     {
  128.         org.drip.function.definition.R2ToR1 logBetaEstimator =
  129.             org.drip.specialfunction.beta.LogGammaEstimator.Weierstrass (1000);

  130.         if (null == logBetaEstimator)
  131.         {
  132.             return null;
  133.         }

  134.         try
  135.         {
  136.             final org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator hypergeometricEstimator =
  137.                 new org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator (
  138.                     new org.drip.specialfunction.definition.HypergeometricParameters (
  139.                         a,
  140.                         b,
  141.                         c
  142.                     ),
  143.                     logBetaEstimator,
  144.                     10000
  145.                 );

  146.             final org.drip.specialfunction.definition.RegularHypergeometricEstimator
  147.                 aPlusRegularHypergeometricEstimator = new
  148.                     org.drip.specialfunction.hypergeometric.GaussContiguousRelations
  149.                         (hypergeometricEstimator).aPlus();

  150.             return new org.drip.function.definition.R1ToR1Property (
  151.                 org.drip.function.definition.R1ToR1Property.EQ,
  152.                 new org.drip.function.definition.R1ToR1 (null)
  153.                 {
  154.                     @Override public double evaluate (
  155.                         final double z)
  156.                         throws java.lang.Exception
  157.                     {
  158.                         return z * hypergeometricEstimator.derivative (
  159.                             z,
  160.                             1
  161.                         );
  162.                     }
  163.                 },
  164.                 new org.drip.function.definition.R1ToR1 (null)
  165.                 {
  166.                     @Override public double evaluate (
  167.                         final double z)
  168.                         throws java.lang.Exception
  169.                     {
  170.                         return a * (
  171.                             aPlusRegularHypergeometricEstimator.regularHypergeometric (z) -
  172.                             hypergeometricEstimator.regularHypergeometric (z)
  173.                         );
  174.                     }
  175.                 },
  176.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  177.             );
  178.         }
  179.         catch (java.lang.Exception e)
  180.         {
  181.             e.printStackTrace();
  182.         }

  183.         return null;
  184.     }

  185.     /**
  186.      * Construct the Hyper-geometric Gauss Contiguous Identity #3 Verifier
  187.      *
  188.      * @param a A
  189.      * @param b B
  190.      * @param c C
  191.      *
  192.      * @return The Hyper-geometric Gauss Contiguous Identity #3 Verifier
  193.      */

  194.     public static final org.drip.function.definition.R1ToR1Property RelationIdentity3 (
  195.         final double a,
  196.         final double b,
  197.         final double c)
  198.     {
  199.         org.drip.function.definition.R2ToR1 logBetaEstimator =
  200.             org.drip.specialfunction.beta.LogGammaEstimator.Weierstrass (1000);

  201.         if (null == logBetaEstimator)
  202.         {
  203.             return null;
  204.         }

  205.         try
  206.         {
  207.             final org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator hypergeometricEstimator =
  208.                 new org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator (
  209.                     new org.drip.specialfunction.definition.HypergeometricParameters (
  210.                         a,
  211.                         b,
  212.                         c
  213.                     ),
  214.                     logBetaEstimator,
  215.                     10000
  216.                 );

  217.             final org.drip.specialfunction.definition.RegularHypergeometricEstimator
  218.                 bPlusHypergeometricEstimator = new
  219.                     org.drip.specialfunction.hypergeometric.GaussContiguousRelations
  220.                         (hypergeometricEstimator).bPlus();

  221.             return new org.drip.function.definition.R1ToR1Property (
  222.                 org.drip.function.definition.R1ToR1Property.EQ,
  223.                 new org.drip.function.definition.R1ToR1 (null)
  224.                 {
  225.                     @Override public double evaluate (
  226.                         final double z)
  227.                         throws java.lang.Exception
  228.                     {
  229.                         return z * hypergeometricEstimator.derivative (
  230.                             z,
  231.                             1
  232.                         );
  233.                     }
  234.                 },
  235.                 new org.drip.function.definition.R1ToR1 (null)
  236.                 {
  237.                     @Override public double evaluate (
  238.                         final double z)
  239.                         throws java.lang.Exception
  240.                     {
  241.                         return b * (
  242.                             bPlusHypergeometricEstimator.regularHypergeometric (z) -
  243.                             hypergeometricEstimator.regularHypergeometric (z)
  244.                         );
  245.                     }
  246.                 },
  247.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  248.             );
  249.         }
  250.         catch (java.lang.Exception e)
  251.         {
  252.             e.printStackTrace();
  253.         }

  254.         return null;
  255.     }

  256.     /**
  257.      * Construct the Hyper-geometric Gauss Contiguous Identity #4 Verifier
  258.      *
  259.      * @param a A
  260.      * @param b B
  261.      * @param c C
  262.      *
  263.      * @return The Hyper-geometric Gauss Contiguous Identity #4 Verifier
  264.      */

  265.     public static final org.drip.function.definition.R1ToR1Property RelationIdentity4 (
  266.         final double a,
  267.         final double b,
  268.         final double c)
  269.     {
  270.         org.drip.function.definition.R2ToR1 logBetaEstimator =
  271.             org.drip.specialfunction.beta.LogGammaEstimator.Weierstrass (10000);

  272.         if (null == logBetaEstimator)
  273.         {
  274.             return null;
  275.         }

  276.         try
  277.         {
  278.             final org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator hypergeometricEstimator =
  279.                 new org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator (
  280.                     new org.drip.specialfunction.definition.HypergeometricParameters (
  281.                         a,
  282.                         b,
  283.                         c
  284.                     ),
  285.                     logBetaEstimator,
  286.                     100000
  287.                 );

  288.             final org.drip.specialfunction.definition.RegularHypergeometricEstimator
  289.                 cMinusHypergeometricEstimator = new
  290.                     org.drip.specialfunction.hypergeometric.GaussContiguousRelations
  291.                         (hypergeometricEstimator).cMinus();

  292.             return new org.drip.function.definition.R1ToR1Property (
  293.                 org.drip.function.definition.R1ToR1Property.EQ,
  294.                 new org.drip.function.definition.R1ToR1 (null)
  295.                 {
  296.                     @Override public double evaluate (
  297.                         final double z)
  298.                         throws java.lang.Exception
  299.                     {
  300.                         return z * hypergeometricEstimator.derivative (
  301.                             z,
  302.                             1
  303.                         );
  304.                     }
  305.                 },
  306.                 new org.drip.function.definition.R1ToR1 (null)
  307.                 {
  308.                     @Override public double evaluate (
  309.                         final double z)
  310.                         throws java.lang.Exception
  311.                     {
  312.                         return (c - 1.) * (
  313.                             cMinusHypergeometricEstimator.regularHypergeometric (z) -
  314.                             hypergeometricEstimator.regularHypergeometric (z)
  315.                         );
  316.                     }
  317.                 },
  318.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  319.             );
  320.         }
  321.         catch (java.lang.Exception e)
  322.         {
  323.             e.printStackTrace();
  324.         }

  325.         return null;
  326.     }

  327.     /**
  328.      * Construct the Hyper-geometric Gauss Contiguous Identity #5 Verifier
  329.      *
  330.      * @param a A
  331.      * @param b B
  332.      * @param c C
  333.      *
  334.      * @return The Hyper-geometric Gauss Contiguous Identity #5 Verifier
  335.      */

  336.     public static final org.drip.function.definition.R1ToR1Property RelationIdentity5 (
  337.         final double a,
  338.         final double b,
  339.         final double c)
  340.     {
  341.         org.drip.function.definition.R2ToR1 logBetaEstimator =
  342.             org.drip.specialfunction.beta.LogGammaEstimator.Weierstrass (10000);

  343.         if (null == logBetaEstimator)
  344.         {
  345.             return null;
  346.         }

  347.         try
  348.         {
  349.             final org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator hypergeometricEstimator =
  350.                 new org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator (
  351.                     new org.drip.specialfunction.definition.HypergeometricParameters (
  352.                         a,
  353.                         b,
  354.                         c
  355.                     ),
  356.                     logBetaEstimator,
  357.                     100000
  358.                 );

  359.             final org.drip.specialfunction.definition.RegularHypergeometricEstimator
  360.                 aMinusHypergeometricEstimator = new
  361.                     org.drip.specialfunction.hypergeometric.GaussContiguousRelations
  362.                         (hypergeometricEstimator).aMinus();

  363.             return new org.drip.function.definition.R1ToR1Property (
  364.                 org.drip.function.definition.R1ToR1Property.EQ,
  365.                 new org.drip.function.definition.R1ToR1 (null)
  366.                 {
  367.                     @Override public double evaluate (
  368.                         final double z)
  369.                         throws java.lang.Exception
  370.                     {
  371.                         return z * hypergeometricEstimator.derivative (
  372.                             z,
  373.                             1
  374.                         );
  375.                     }
  376.                 },
  377.                 new org.drip.function.definition.R1ToR1 (null)
  378.                 {
  379.                     @Override public double evaluate (
  380.                         final double z)
  381.                         throws java.lang.Exception
  382.                     {
  383.                         return (
  384.                             (c - a) * aMinusHypergeometricEstimator.regularHypergeometric (z) +
  385.                             (a - c + b * z) * hypergeometricEstimator.regularHypergeometric (z)
  386.                         ) / (1. - z);
  387.                     }
  388.                 },
  389.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  390.             );
  391.         }
  392.         catch (java.lang.Exception e)
  393.         {
  394.             e.printStackTrace();
  395.         }

  396.         return null;
  397.     }

  398.     /**
  399.      * Construct the Hyper-geometric Gauss Contiguous Identity #6 Verifier
  400.      *
  401.      * @param a A
  402.      * @param b B
  403.      * @param c C
  404.      *
  405.      * @return The Hyper-geometric Gauss Contiguous Identity #6 Verifier
  406.      */

  407.     public static final org.drip.function.definition.R1ToR1Property RelationIdentity6 (
  408.         final double a,
  409.         final double b,
  410.         final double c)
  411.     {
  412.         org.drip.function.definition.R2ToR1 logBetaEstimator =
  413.             org.drip.specialfunction.beta.LogGammaEstimator.Weierstrass (10000);

  414.         if (null == logBetaEstimator)
  415.         {
  416.             return null;
  417.         }

  418.         try
  419.         {
  420.             final org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator hypergeometricEstimator =
  421.                 new org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator (
  422.                     new org.drip.specialfunction.definition.HypergeometricParameters (
  423.                         a,
  424.                         b,
  425.                         c
  426.                     ),
  427.                     logBetaEstimator,
  428.                     100000
  429.                 );

  430.             final org.drip.specialfunction.definition.RegularHypergeometricEstimator
  431.                 bMinusHypergeometricEstimator = new
  432.                     org.drip.specialfunction.hypergeometric.GaussContiguousRelations
  433.                         (hypergeometricEstimator).bMinus();

  434.             return new org.drip.function.definition.R1ToR1Property (
  435.                 org.drip.function.definition.R1ToR1Property.EQ,
  436.                 new org.drip.function.definition.R1ToR1 (null)
  437.                 {
  438.                     @Override public double evaluate (
  439.                         final double z)
  440.                         throws java.lang.Exception
  441.                     {
  442.                         return z * hypergeometricEstimator.derivative (
  443.                             z,
  444.                             1
  445.                         );
  446.                     }
  447.                 },
  448.                 new org.drip.function.definition.R1ToR1 (null)
  449.                 {
  450.                     @Override public double evaluate (
  451.                         final double z)
  452.                         throws java.lang.Exception
  453.                     {
  454.                         return (
  455.                             (c - b) * bMinusHypergeometricEstimator.regularHypergeometric (z) +
  456.                             (b - c + a * z) * hypergeometricEstimator.regularHypergeometric (z)
  457.                         ) / (1. - z);
  458.                     }
  459.                 },
  460.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  461.             );
  462.         }
  463.         catch (java.lang.Exception e)
  464.         {
  465.             e.printStackTrace();
  466.         }

  467.         return null;
  468.     }

  469.     /**
  470.      * Construct the Hyper-geometric Gauss Contiguous Identity #7 Verifier
  471.      *
  472.      * @param a A
  473.      * @param b B
  474.      * @param c C
  475.      *
  476.      * @return The Hyper-geometric Gauss Contiguous Identity #7 Verifier
  477.      */

  478.     public static final org.drip.function.definition.R1ToR1Property RelationIdentity7 (
  479.         final double a,
  480.         final double b,
  481.         final double c)
  482.     {
  483.         org.drip.function.definition.R2ToR1 logBetaEstimator =
  484.             org.drip.specialfunction.beta.LogGammaEstimator.Weierstrass (10000);

  485.         if (null == logBetaEstimator)
  486.         {
  487.             return null;
  488.         }

  489.         try
  490.         {
  491.             final org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator hypergeometricEstimator =
  492.                 new org.drip.specialfunction.hypergeometric.EulerQuadratureEstimator (
  493.                     new org.drip.specialfunction.definition.HypergeometricParameters (
  494.                         a,
  495.                         b,
  496.                         c
  497.                     ),
  498.                     logBetaEstimator,
  499.                     100000
  500.                 );

  501.             final org.drip.specialfunction.definition.RegularHypergeometricEstimator
  502.                 cPlusHypergeometricEstimator = new
  503.                     org.drip.specialfunction.hypergeometric.GaussContiguousRelations
  504.                         (hypergeometricEstimator).cPlus();

  505.             return new org.drip.function.definition.R1ToR1Property (
  506.                 org.drip.function.definition.R1ToR1Property.EQ,
  507.                 new org.drip.function.definition.R1ToR1 (null)
  508.                 {
  509.                     @Override public double evaluate (
  510.                         final double z)
  511.                         throws java.lang.Exception
  512.                     {
  513.                         return hypergeometricEstimator.derivative (
  514.                             z,
  515.                             1
  516.                         );
  517.                     }
  518.                 },
  519.                 new org.drip.function.definition.R1ToR1 (null)
  520.                 {
  521.                     @Override public double evaluate (
  522.                         final double z)
  523.                         throws java.lang.Exception
  524.                     {
  525.                         return (
  526.                             (c - a) * (c - b) * cPlusHypergeometricEstimator.regularHypergeometric (z) +
  527.                             c * (a + b - c) * hypergeometricEstimator.regularHypergeometric (z)
  528.                         ) / (c * (1. - z));
  529.                     }
  530.                 },
  531.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  532.             );
  533.         }
  534.         catch (java.lang.Exception e)
  535.         {
  536.             e.printStackTrace();
  537.         }

  538.         return null;
  539.     }
  540. }