Java acos acosh(double a)

Here you can find the source of acosh(double a)

Description

Calculates inverse hyperbolic cosine of a double value.

License

Apache License

Declaration

public static double acosh(double a) 

Method Source Code

//package com.java2s;
/*/*from  w w  w  . ja va 2 s.c  o  m*/
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Calculates inverse hyperbolic cosine of a {@code double} value.
     * <p>
     * Special cases:
     * <ul>
     *    <li>If the argument is NaN, then the result is NaN.
     *    <li>If the argument is +1, then the result is a zero.
     *    <li>If the argument is positive infinity, then the result is positive infinity.
     *    <li>If the argument is less than 1, then the result is NaN.
     * </ul>
     */
    public static double acosh(double a) {
        return Math.log(Math.sqrt(a * a - 1.0d) + a);
    }

    /**
     * Returns {@code x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base))}
     * @param base must be {@code > 1}
     */
    public static int log(long x, int base) {
        if (base <= 1) {
            throw new IllegalArgumentException("base must be > 1");
        }
        int ret = 0;
        while (x >= base) {
            x /= base;
            ret++;
        }
        return ret;
    }

    /**
     * Calculates logarithm in a given base with doubles.
     */
    public static double log(double base, double x) {
        return Math.log(x) / Math.log(base);
    }
}

Related

  1. acos(int f)
  2. acos(Integer a)
  3. acos(Long a)
  4. acos(Number x)
  5. acos_v2(double x)
  6. acosh(double x)
  7. acosh(double x)
  8. acosh(double x)
  9. acosh(double x)