BoundedParameter.java

  1. /*
  2.  * Licensed to the Hipparchus project under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      https://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.hipparchus.special.elliptic.jacobi;

  18. import org.hipparchus.complex.Complex;
  19. import org.hipparchus.special.elliptic.legendre.LegendreEllipticIntegral;
  20. import org.hipparchus.util.MathUtils;

  21. /** Algorithm for computing the principal Jacobi functions for parameter m in [0; 1].
  22.  * @since 2.0
  23.  */
  24. class BoundedParameter extends JacobiElliptic {

  25.     /** Jacobi θ functions. */
  26.     private final JacobiTheta jacobiTheta;

  27.     /** Value of Jacobi θ functions at origin. */
  28.     private final Theta t0;

  29.     /** Scaling factor. */
  30.     private final double scaling;

  31.     /** Simple constructor.
  32.      * @param m parameter of the Jacobi elliptic function
  33.      */
  34.     BoundedParameter(final double m) {

  35.         super(m);

  36.         // compute nome
  37.         final double q = LegendreEllipticIntegral.nome(m);

  38.         // prepare underlying Jacobi θ functions
  39.         this.jacobiTheta = new JacobiTheta(q);
  40.         this.t0          = jacobiTheta.values(Complex.ZERO);
  41.         this.scaling     = MathUtils.SEMI_PI / LegendreEllipticIntegral.bigK(m);

  42.     }

  43.     /** {@inheritDoc}
  44.      * <p>
  45.      * The algorithm for evaluating the functions is based on {@link JacobiTheta
  46.      * Jacobi theta functions}.
  47.      * </p>
  48.      */
  49.     @Override
  50.     public CopolarN valuesN(double u) {

  51.         // evaluate Jacobi θ functions at argument
  52.         final Theta tZ = jacobiTheta.values(new Complex(u * scaling));

  53.         // convert to Jacobi elliptic functions
  54.         final double sn = t0.theta3().multiply(tZ.theta1()).divide(t0.theta2().multiply(tZ.theta4())).getRealPart();
  55.         final double cn = t0.theta4().multiply(tZ.theta2()).divide(t0.theta2().multiply(tZ.theta4())).getRealPart();
  56.         final double dn = t0.theta4().multiply(tZ.theta3()).divide(t0.theta3().multiply(tZ.theta4())).getRealPart();

  57.         return new CopolarN(sn, cn, dn);

  58.     }

  59. }