DigammaEqualityLemma.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>DigammaEqualityLemma</i> contains the Verifiable Equality Lemmas of the Digamma Function. The
  76.  * References are:
  77.  *
  78.  * <br><br>
  79.  *  <ul>
  80.  *      <li>
  81.  *          Blagouchine, I. V. (2014): Re-discovery of Malmsten's Integrals, their Evaluation by Contour
  82.  *              Integration Methods, and some Related Results <i>Ramanujan Journal</i> <b>35 (1)</b> 21-110
  83.  *      </li>
  84.  *      <li>
  85.  *          Borwein, J. M., and R. M. Corless (2017): Gamma Function and the Factorial in the Monthly
  86.  *              https://arxiv.org/abs/1703.05349 <b>arXiv</b>
  87.  *      </li>
  88.  *      <li>
  89.  *          Davis, P. J. (1959): Leonhard Euler's Integral: A Historical Profile of the Gamma Function
  90.  *              <i>American Mathematical Monthly</i> <b>66 (10)</b> 849-869
  91.  *      </li>
  92.  *      <li>
  93.  *          Whitaker, E. T., and G. N. Watson (1996): <i>A Course on Modern Analysis</i> <b>Cambridge
  94.  *              University Press</b> New York
  95.  *      </li>
  96.  *      <li>
  97.  *          Wikipedia (2019): Gamma Function https://en.wikipedia.org/wiki/Gamma_function
  98.  *      </li>
  99.  *  </ul>
  100.  *
  101.  *  <br><br>
  102.  *  <ul>
  103.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  104.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FunctionAnalysisLibrary.md">Function Analysis Library</a></li>
  105.  *      <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>
  106.  *      <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>
  107.  *  </ul>
  108.  *
  109.  * @author Lakshmi Krishnamurthy
  110.  */

  111. public class DigammaEqualityLemma
  112. {

  113.     /**
  114.      * Generate the Digamma (0, 1) Reflection Formula Verifier
  115.      *
  116.      * @return The Digamma (0, 1) Reflection Formula Verifier
  117.      */

  118.     public static final org.drip.function.definition.R1ToR1Property ReflectionFormula()
  119.     {
  120.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  121.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  122.         try
  123.         {
  124.             return new org.drip.function.definition.R1ToR1Property (
  125.                 org.drip.function.definition.R1ToR1Property.EQ,
  126.                 new org.drip.function.definition.R1ToR1 (null)
  127.                 {
  128.                     @Override public double evaluate (
  129.                         final double z)
  130.                         throws java.lang.Exception
  131.                     {
  132.                         if (!org.drip.numerical.common.NumberUtil.IsValid (z))
  133.                         {
  134.                             throw new java.lang.Exception
  135.                                 ("DigammaEqualityLemma::ReflectionFormula::evaluate => Invalid Inputs");
  136.                         }

  137.                         return abramowitzStegun2007.evaluate (1. - z) - abramowitzStegun2007.evaluate (z);
  138.                     }
  139.                 },
  140.                 new org.drip.function.definition.R1ToR1 (null)
  141.                 {
  142.                     @Override public double evaluate (
  143.                         final double z)
  144.                         throws java.lang.Exception
  145.                     {
  146.                         if (!org.drip.numerical.common.NumberUtil.IsValid (z))
  147.                         {
  148.                             throw new java.lang.Exception
  149.                                 ("DigammaEqualityLemma::ReflectionFormula::evaluate => Invalid Inputs");
  150.                         }

  151.                         return java.lang.Math.PI / java.lang.Math.tan (java.lang.Math.PI * z);
  152.                     }
  153.                 },
  154.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  155.             );
  156.         }
  157.         catch (java.lang.Exception e)
  158.         {
  159.             e.printStackTrace();
  160.         }

  161.         return null;
  162.     }

  163.     /**
  164.      * Generate the Gaussian Finite Summation Identity Verifier #1
  165.      *
  166.      * @return The Gaussian Finite Summation Identity Verifier #1
  167.      */

  168.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity1()
  169.     {
  170.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  171.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  172.         try
  173.         {
  174.             return new org.drip.function.definition.R1ToR1Property (
  175.                 org.drip.function.definition.R1ToR1Property.EQ,
  176.                 new org.drip.function.definition.R1ToR1 (null)
  177.                 {
  178.                     @Override public double evaluate (
  179.                         final double m)
  180.                         throws java.lang.Exception
  181.                     {
  182.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  183.                         {
  184.                             throw new java.lang.Exception
  185.                                 ("DigammaEqualityLemma::SummationIdentity1::evaluate => Invalid Inputs");
  186.                         }

  187.                         double summation = 0.;

  188.                         for (int r = 1; r <= m; ++r)
  189.                         {
  190.                             summation = summation + abramowitzStegun2007.evaluate (((double) r) / ((double) m));
  191.                         }

  192.                         return summation;
  193.                     }
  194.                 },
  195.                 new org.drip.function.definition.R1ToR1 (null)
  196.                 {
  197.                     @Override public double evaluate (
  198.                         final double m)
  199.                         throws java.lang.Exception
  200.                     {
  201.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  202.                         {
  203.                             throw new java.lang.Exception
  204.                                 ("DigammaEqualityLemma::SummationIdentity1::evaluate => Invalid Inputs");
  205.                         }

  206.                         return -m * (org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI +
  207.                             java.lang.Math.log (m));
  208.                     }
  209.                 },
  210.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  211.             );
  212.         }
  213.         catch (java.lang.Exception e)
  214.         {
  215.             e.printStackTrace();
  216.         }

  217.         return null;
  218.     }

  219.     /**
  220.      * Generate the Gaussian Finite Summation Identity Verifier #2
  221.      *
  222.      * @param k k
  223.      *
  224.      * @return The Gaussian Finite Summation Identity Verifier #2
  225.      */

  226.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity2 (
  227.         final int k)
  228.     {
  229.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  230.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  231.         try
  232.         {
  233.             return new org.drip.function.definition.R1ToR1Property (
  234.                 org.drip.function.definition.R1ToR1Property.EQ,
  235.                 new org.drip.function.definition.R1ToR1 (null)
  236.                 {
  237.                     @Override public double evaluate (
  238.                         final double m)
  239.                         throws java.lang.Exception
  240.                     {
  241.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  242.                         {
  243.                             throw new java.lang.Exception
  244.                                 ("DigammaEqualityLemma::SummationIdentity2::evaluate => Invalid Inputs");
  245.                         }

  246.                         double summation = 0.;

  247.                         for (int r = 1; r < m; ++r)
  248.                         {
  249.                             double z = ((double) r) / ((double) m);

  250.                             summation = summation + abramowitzStegun2007.evaluate (z) *
  251.                                 java.lang.Math.cos (2. * java.lang.Math.PI * k * z);
  252.                         }

  253.                         return summation;
  254.                     }
  255.                 },
  256.                 new org.drip.function.definition.R1ToR1 (null)
  257.                 {
  258.                     @Override public double evaluate (
  259.                         final double m)
  260.                         throws java.lang.Exception
  261.                     {
  262.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  263.                         {
  264.                             throw new java.lang.Exception
  265.                                 ("DigammaEqualityLemma::SummationIdentity2::evaluate => Invalid Inputs");
  266.                         }

  267.                         return m * java.lang.Math.log (2. * java.lang.Math.sin (java.lang.Math.PI * k / m)) +
  268.                             org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI;
  269.                     }
  270.                 },
  271.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  272.             );
  273.         }
  274.         catch (java.lang.Exception e)
  275.         {
  276.             e.printStackTrace();
  277.         }

  278.         return null;
  279.     }

  280.     /**
  281.      * Generate the Gaussian Finite Summation Identity Verifier #3
  282.      *
  283.      * @param k k
  284.      *
  285.      * @return The Gaussian Finite Summation Identity Verifier #3
  286.      */

  287.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity3 (
  288.         final int k)
  289.     {
  290.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  291.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  292.         try
  293.         {
  294.             return new org.drip.function.definition.R1ToR1Property (
  295.                 org.drip.function.definition.R1ToR1Property.EQ,
  296.                 new org.drip.function.definition.R1ToR1 (null)
  297.                 {
  298.                     @Override public double evaluate (
  299.                         final double m)
  300.                         throws java.lang.Exception
  301.                     {
  302.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  303.                         {
  304.                             throw new java.lang.Exception
  305.                                 ("DigammaEqualityLemma::SummationIdentity3::evaluate => Invalid Inputs");
  306.                         }

  307.                         double summation = 0.;

  308.                         for (int r = 1; r < m; ++r)
  309.                         {
  310.                             double z = ((double) r) / ((double) m);

  311.                             summation = summation + abramowitzStegun2007.evaluate (z) *
  312.                                 java.lang.Math.sin (2. * java.lang.Math.PI * k * z);
  313.                         }

  314.                         return summation;
  315.                     }
  316.                 },
  317.                 new org.drip.function.definition.R1ToR1 (null)
  318.                 {
  319.                     @Override public double evaluate (
  320.                         final double m)
  321.                         throws java.lang.Exception
  322.                     {
  323.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  324.                         {
  325.                             throw new java.lang.Exception
  326.                                 ("DigammaEqualityLemma::SummationIdentity3::evaluate => Invalid Inputs");
  327.                         }

  328.                         return 0.5 * java.lang.Math.PI * (2. * k - m);
  329.                     }
  330.                 },
  331.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  332.             );
  333.         }
  334.         catch (java.lang.Exception e)
  335.         {
  336.             e.printStackTrace();
  337.         }

  338.         return null;
  339.     }

  340.     /**
  341.      * Generate the Blagouchine Finite Summation Identity Verifier #4
  342.      *
  343.      * @param k k
  344.      *
  345.      * @return The Blagouchine Finite Summation Identity Verifier #4
  346.      */

  347.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity4 (
  348.         final int k)
  349.     {
  350.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  351.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  352.         try
  353.         {
  354.             return new org.drip.function.definition.R1ToR1Property (
  355.                 org.drip.function.definition.R1ToR1Property.EQ,
  356.                 new org.drip.function.definition.R1ToR1 (null)
  357.                 {
  358.                     @Override public double evaluate (
  359.                         final double m)
  360.                         throws java.lang.Exception
  361.                     {
  362.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  363.                         {
  364.                             throw new java.lang.Exception
  365.                                 ("DigammaEqualityLemma::SummationIdentity4::evaluate => Invalid Inputs");
  366.                         }

  367.                         double summation = 0.;

  368.                         for (int r = 0; r < m; ++r)
  369.                         {
  370.                             double z = (2. * r + 1.) / (2. * m);

  371.                             summation = summation + abramowitzStegun2007.evaluate (z) *
  372.                                 java.lang.Math.cos (2. * java.lang.Math.PI * k * z);
  373.                         }

  374.                         return summation;
  375.                     }
  376.                 },
  377.                 new org.drip.function.definition.R1ToR1 (null)
  378.                 {
  379.                     @Override public double evaluate (
  380.                         final double m)
  381.                         throws java.lang.Exception
  382.                     {
  383.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  384.                         {
  385.                             throw new java.lang.Exception
  386.                                 ("DigammaEqualityLemma::SummationIdentity4::evaluate => Invalid Inputs");
  387.                         }

  388.                         return m * java.lang.Math.log (java.lang.Math.tan (0.5 * java.lang.Math.PI * k / m));
  389.                     }
  390.                 },
  391.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  392.             );
  393.         }
  394.         catch (java.lang.Exception e)
  395.         {
  396.             e.printStackTrace();
  397.         }

  398.         return null;
  399.     }

  400.     /**
  401.      * Generate the Blagouchine Finite Summation Identity Verifier #5
  402.      *
  403.      * @param k k
  404.      *
  405.      * @return The Blagouchine Finite Summation Identity Verifier #5
  406.      */

  407.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity5 (
  408.         final int k)
  409.     {
  410.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  411.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  412.         try
  413.         {
  414.             return new org.drip.function.definition.R1ToR1Property (
  415.                 org.drip.function.definition.R1ToR1Property.EQ,
  416.                 new org.drip.function.definition.R1ToR1 (null)
  417.                 {
  418.                     @Override public double evaluate (
  419.                         final double m)
  420.                         throws java.lang.Exception
  421.                     {
  422.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  423.                         {
  424.                             throw new java.lang.Exception
  425.                                 ("DigammaEqualityLemma::SummationIdentity5::evaluate => Invalid Inputs");
  426.                         }

  427.                         double summation = 0.;

  428.                         for (int r = 0; r < m; ++r)
  429.                         {
  430.                             double z = (2. * r + 1.) / (2. * m);

  431.                             summation = summation + abramowitzStegun2007.evaluate (z) *
  432.                                 java.lang.Math.sin (2. * java.lang.Math.PI * k * z);
  433.                         }

  434.                         return summation;
  435.                     }
  436.                 },
  437.                 new org.drip.function.definition.R1ToR1 (null)
  438.                 {
  439.                     @Override public double evaluate (
  440.                         final double m)
  441.                         throws java.lang.Exception
  442.                     {
  443.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m || m <= k)
  444.                         {
  445.                             throw new java.lang.Exception
  446.                                 ("DigammaEqualityLemma::SummationIdentity5::evaluate => Invalid Inputs");
  447.                         }

  448.                         return -0.5 * java.lang.Math.PI * m;
  449.                     }
  450.                 },
  451.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  452.             );
  453.         }
  454.         catch (java.lang.Exception e)
  455.         {
  456.             e.printStackTrace();
  457.         }

  458.         return null;
  459.     }

  460.     /**
  461.      * Generate the Blagouchine Finite Summation Identity Verifier #6
  462.      *
  463.      * @return The Blagouchine Finite Summation Identity Verifier #6
  464.      */

  465.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity6()
  466.     {
  467.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  468.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  469.         try
  470.         {
  471.             return new org.drip.function.definition.R1ToR1Property (
  472.                 org.drip.function.definition.R1ToR1Property.EQ,
  473.                 new org.drip.function.definition.R1ToR1 (null)
  474.                 {
  475.                     @Override public double evaluate (
  476.                         final double m)
  477.                         throws java.lang.Exception
  478.                     {
  479.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  480.                         {
  481.                             throw new java.lang.Exception
  482.                                 ("DigammaEqualityLemma::SummationIdentity6::evaluate => Invalid Inputs");
  483.                         }

  484.                         double summation = 0.;

  485.                         for (int r = 1; r < m; ++r)
  486.                         {
  487.                             double z = ((double) r) / ((double) m);

  488.                             summation = summation + abramowitzStegun2007.evaluate (z) /
  489.                                 java.lang.Math.tan (java.lang.Math.PI * z);
  490.                         }

  491.                         return summation;
  492.                     }
  493.                 },
  494.                 new org.drip.function.definition.R1ToR1 (null)
  495.                 {
  496.                     @Override public double evaluate (
  497.                         final double m)
  498.                         throws java.lang.Exception
  499.                     {
  500.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  501.                         {
  502.                             throw new java.lang.Exception
  503.                                 ("DigammaEqualityLemma::SummationIdentity6::evaluate => Invalid Inputs");
  504.                         }

  505.                         return -java.lang.Math.PI * (m - 1.) * (m - 2.) / 6.;
  506.                     }
  507.                 },
  508.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  509.             );
  510.         }
  511.         catch (java.lang.Exception e)
  512.         {
  513.             e.printStackTrace();
  514.         }

  515.         return null;
  516.     }

  517.     /**
  518.      * Generate the Blagouchine Finite Summation Identity Verifier #7
  519.      *
  520.      * @return The Blagouchine Finite Summation Identity Verifier #7
  521.      */

  522.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity7()
  523.     {
  524.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  525.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  526.         try
  527.         {
  528.             return new org.drip.function.definition.R1ToR1Property (
  529.                 org.drip.function.definition.R1ToR1Property.EQ,
  530.                 new org.drip.function.definition.R1ToR1 (null)
  531.                 {
  532.                     @Override public double evaluate (
  533.                         final double m)
  534.                         throws java.lang.Exception
  535.                     {
  536.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  537.                         {
  538.                             throw new java.lang.Exception
  539.                                 ("DigammaEqualityLemma::SummationIdentity7::evaluate => Invalid Inputs");
  540.                         }

  541.                         double summation = 0.;

  542.                         for (int r = 1; r < m; ++r)
  543.                         {
  544.                             double z = ((double) r) / ((double) m);

  545.                             summation = summation + z * abramowitzStegun2007.evaluate (z);
  546.                         }

  547.                         return summation;
  548.                     }
  549.                 },
  550.                 new org.drip.function.definition.R1ToR1 (null)
  551.                 {
  552.                     @Override public double evaluate (
  553.                         final double m)
  554.                         throws java.lang.Exception
  555.                     {
  556.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  557.                         {
  558.                             throw new java.lang.Exception
  559.                                 ("DigammaEqualityLemma::SummationIdentity7::evaluate => Invalid Inputs");
  560.                         }

  561.                         double summation = 0.;

  562.                         for (int r = 1; r < m; ++r)
  563.                         {
  564.                             double z = ((double) r) / ((double) m);

  565.                             summation = summation + z / java.lang.Math.tan (java.lang.Math.PI * z);
  566.                         }

  567.                         return -0.5 * org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI * (m - 1.)
  568.                             - 0.5 * m * java.lang.Math.log (m)
  569.                             - 0.5 * java.lang.Math.PI * summation;
  570.                     }
  571.                 },
  572.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  573.             );
  574.         }
  575.         catch (java.lang.Exception e)
  576.         {
  577.             e.printStackTrace();
  578.         }

  579.         return null;
  580.     }

  581.     /**
  582.      * Generate the Blagouchine Finite Summation Identity Verifier #8
  583.      *
  584.      * @param l l
  585.      *
  586.      * @return The Blagouchine Finite Summation Identity Verifier #8
  587.      */

  588.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity8 (
  589.         final double l)
  590.     {
  591.         if (!org.drip.numerical.common.NumberUtil.IsValid (l))
  592.         {
  593.             return null;
  594.         }

  595.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  596.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  597.         try
  598.         {
  599.             return new org.drip.function.definition.R1ToR1Property (
  600.                 org.drip.function.definition.R1ToR1Property.EQ,
  601.                 new org.drip.function.definition.R1ToR1 (null)
  602.                 {
  603.                     @Override public double evaluate (
  604.                         final double m)
  605.                         throws java.lang.Exception
  606.                     {
  607.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  608.                         {
  609.                             throw new java.lang.Exception
  610.                                 ("DigammaEqualityLemma::SummationIdentity8::evaluate => Invalid Inputs");
  611.                         }

  612.                         double summation = 0.;

  613.                         for (int r = 1; r < m; ++r)
  614.                         {
  615.                             double z = ((double) r) / ((double) m);

  616.                             summation = summation + abramowitzStegun2007.evaluate (z) *
  617.                                 java.lang.Math.cos ((2. * l + 1.) * java.lang.Math.PI * z);
  618.                         }

  619.                         return summation;
  620.                     }
  621.                 },
  622.                 new org.drip.function.definition.R1ToR1 (null)
  623.                 {
  624.                     @Override public double evaluate (
  625.                         final double m)
  626.                         throws java.lang.Exception
  627.                     {
  628.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  629.                         {
  630.                             throw new java.lang.Exception
  631.                                 ("DigammaEqualityLemma::SummationIdentity8::evaluate => Invalid Inputs");
  632.                         }

  633.                         double summation = 0.;

  634.                         for (int r = 1; r < m; ++r)
  635.                         {
  636.                             double z = ((double) r) / ((double) m);

  637.                             double theta = 2. * java.lang.Math.PI * z;

  638.                             summation = summation + r * java.lang.Math.sin (theta) / (
  639.                                 java.lang.Math.cos (theta) -
  640.                                 java.lang.Math.cos ((2. * l + 1.) * java.lang.Math.PI / m)
  641.                             );
  642.                         }

  643.                         return -1. * java.lang.Math.PI / m * summation;
  644.                     }
  645.                 },
  646.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  647.             );
  648.         }
  649.         catch (java.lang.Exception e)
  650.         {
  651.             e.printStackTrace();
  652.         }

  653.         return null;
  654.     }

  655.     /**
  656.      * Generate the Blagouchine Finite Summation Identity Verifier #9
  657.      *
  658.      * @param l l
  659.      *
  660.      * @return The Blagouchine Finite Summation Identity Verifier #9
  661.      */

  662.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity9 (
  663.         final double l)
  664.     {
  665.         if (!org.drip.numerical.common.NumberUtil.IsValid (l))
  666.         {
  667.             return null;
  668.         }

  669.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  670.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  671.         try
  672.         {
  673.             return new org.drip.function.definition.R1ToR1Property (
  674.                 org.drip.function.definition.R1ToR1Property.EQ,
  675.                 new org.drip.function.definition.R1ToR1 (null)
  676.                 {
  677.                     @Override public double evaluate (
  678.                         final double m)
  679.                         throws java.lang.Exception
  680.                     {
  681.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  682.                         {
  683.                             throw new java.lang.Exception
  684.                                 ("DigammaEqualityLemma::SummationIdentity9::evaluate => Invalid Inputs");
  685.                         }

  686.                         double summation = 0.;

  687.                         for (int r = 1; r < m; ++r)
  688.                         {
  689.                             double z = ((double) r) / ((double) m);

  690.                             summation = summation + abramowitzStegun2007.evaluate (z) *
  691.                                 java.lang.Math.sin ((2. * l + 1.) * java.lang.Math.PI * z);
  692.                         }

  693.                         return summation;
  694.                     }
  695.                 },
  696.                 new org.drip.function.definition.R1ToR1 (null)
  697.                 {
  698.                     @Override public double evaluate (
  699.                         final double m)
  700.                         throws java.lang.Exception
  701.                     {
  702.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  703.                         {
  704.                             throw new java.lang.Exception
  705.                                 ("DigammaEqualityLemma::SummationIdentity9::evaluate => Invalid Inputs");
  706.                         }

  707.                         double summation = 0.;
  708.                         double twoLPlus1PiByM = (2. * l + 1.) * java.lang.Math.PI / m;

  709.                         double cos2LPlus1PiByM = java.lang.Math.cos (twoLPlus1PiByM);

  710.                         for (int r = 1; r < m; ++r)
  711.                         {
  712.                             double z = ((double) r) / ((double) m);

  713.                             double theta = java.lang.Math.PI * z;

  714.                             summation = summation + java.lang.Math.log (java.lang.Math.sin (theta)) /
  715.                                 (java.lang.Math.cos (2. * theta) - cos2LPlus1PiByM);
  716.                         }

  717.                         return java.lang.Math.sin (twoLPlus1PiByM) * summation -
  718.                             (
  719.                                 org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI +
  720.                                 java.lang.Math.log (2. * m)
  721.                             ) / java.lang.Math.tan (0.5 * twoLPlus1PiByM);
  722.                     }
  723.                 },
  724.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  725.             );
  726.         }
  727.         catch (java.lang.Exception e)
  728.         {
  729.             e.printStackTrace();
  730.         }

  731.         return null;
  732.     }

  733.     /**
  734.      * Generate the Blagouchine Finite Summation Identity Verifier #10
  735.      *
  736.      * @return The Blagouchine Finite Summation Identity Verifier #10
  737.      */

  738.     public static final org.drip.function.definition.R1ToR1Property SummationIdentity10()
  739.     {
  740.         final org.drip.specialfunction.digamma.CumulativeSeriesEstimator abramowitzStegun2007 =
  741.             org.drip.specialfunction.digamma.CumulativeSeriesEstimator.AbramowitzStegun2007 (1638400);

  742.         try
  743.         {
  744.             return new org.drip.function.definition.R1ToR1Property (
  745.                 org.drip.function.definition.R1ToR1Property.EQ,
  746.                 new org.drip.function.definition.R1ToR1 (null)
  747.                 {
  748.                     @Override public double evaluate (
  749.                         final double m)
  750.                         throws java.lang.Exception
  751.                     {
  752.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  753.                         {
  754.                             throw new java.lang.Exception
  755.                                 ("DigammaEqualityLemma::SummationIdentity10::evaluate => Invalid Inputs");
  756.                         }

  757.                         double summation = 0.;

  758.                         for (int r = 1; r < m; ++r)
  759.                         {
  760.                             double digamma = abramowitzStegun2007.evaluate ((double) r) / ((double) m);

  761.                             summation = summation + digamma * digamma;
  762.                         }

  763.                         return summation;
  764.                     }
  765.                 },
  766.                 new org.drip.function.definition.R1ToR1 (null)
  767.                 {
  768.                     @Override public double evaluate (
  769.                         final double m)
  770.                         throws java.lang.Exception
  771.                     {
  772.                         if (!org.drip.numerical.common.NumberUtil.IsValid (m) || 0. >= m)
  773.                         {
  774.                             throw new java.lang.Exception
  775.                                 ("DigammaEqualityLemma::SummationIdentity10::evaluate => Invalid Inputs");
  776.                         }

  777.                         double summation = 0.;

  778.                         for (int l = 1; l < m; ++l)
  779.                         {
  780.                             double logSinPiLByM = java.lang.Math.log (
  781.                                 java.lang.Math.sin (
  782.                                     java.lang.Math.PI * l / m
  783.                                 )
  784.                             );

  785.                             summation = summation + logSinPiLByM * logSinPiLByM;
  786.                         }

  787.                         double log2 = java.lang.Math.log (2.);

  788.                         return
  789.                             (m - 1.) * org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI *
  790.                                 org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI +
  791.                             m * (
  792.                                 2. * org.drip.specialfunction.gamma.Definitions.EULER_MASCHERONI +
  793.                                 java.lang.Math.log (4. * m)
  794.                             ) * java.lang.Math.log (m) -
  795.                             log2 * log2 * m * (m - 1.) +
  796.                             java.lang.Math.PI * java.lang.Math.PI / 12. * (2. - 3. * m + m * m) +
  797.                             m * summation;
  798.                     }
  799.                 },
  800.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  801.             );
  802.         }
  803.         catch (java.lang.Exception e)
  804.         {
  805.             e.printStackTrace();
  806.         }

  807.         return null;
  808.     }
  809. }