FieldNearOneParameter.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.CalculusFieldElement;
  19. import org.hipparchus.util.FastMath;
  20. import org.hipparchus.util.FieldSinhCosh;

  21. /** Algorithm for computing the principal Jacobi functions for parameters slightly below one.
  22.  * <p>
  23.  * The algorithm for evaluating the functions is based on approximation
  24.  * in terms of hyperbolic functions. It is given in Abramowitz and Stegun,
  25.  * sections 16.15.
  26.  * </p>
  27.  * @param <T> the type of the field elements
  28.  * @since 2.0
  29.  */
  30. class FieldNearOneParameter<T extends CalculusFieldElement<T>> extends FieldJacobiElliptic<T> {

  31.     /** Complementary parameter of the Jacobi elliptic function. */
  32.     private final T m1Fourth;

  33.     /** Simple constructor.
  34.      * @param m parameter of the Jacobi elliptic function (must be one or slightly below one here)
  35.      */
  36.     FieldNearOneParameter(final T m) {
  37.         super(m);
  38.         this.m1Fourth = m.getField().getOne().subtract(m).multiply(0.25);
  39.     }

  40.     /** {@inheritDoc} */
  41.     @Override
  42.     public FieldCopolarN<T> valuesN(final T u) {
  43.         final FieldSinhCosh<T> sch    = FastMath.sinhCosh(u);
  44.         final T                sech   = sch.cosh().reciprocal();
  45.         final T                t      = sch.sinh().multiply(sech);
  46.         final T                factor = sch.sinh().multiply(sch.cosh()).subtract(u).multiply(sech).multiply(m1Fourth);
  47.         return new FieldCopolarN<>(t.add(factor.multiply(sech)),  // equation 16.15.1
  48.                         sech.subtract(factor.multiply(t)),        // equation 16.15.2
  49.                         sech.add(factor.multiply(t)));            // equation 16.15.3
  50.     }

  51. }