Java acot acot(final T value)

Here you can find the source of acot(final T value)

Description

Return the arcus cotangens of value in radian.

License

Apache License

Parameter

Parameter Description
T The number type
value A rational floating point number.

Return

The Arcuscotangens of value .

Declaration

public static final <T extends Number & Comparable<? super T>> double acot(final T value) 

Method Source Code

//package com.java2s;
/*/*from w  w w .  j a va2s  .c o  m*/
 * Copyright 2016 Langhammer, Tim | Earth >> Europe >> Potsdam |
 * {@literal @}<a href="mailto:tlhammer@mailbox.org" alt="email">mail</a> |
 * "Tolerance first".
 *
 * Licensed 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 {
    public static final double PI_HALF = Math.PI / 2D;

    /**
     * Return the {@code arcus cotangens} of {@code value} in radian.
     * <p>
     * This function is implemented as described in "Teubner - Taschenbuch der
     * Mathematik [Bronstein/Samendjajew]".
     *
     *
     * @param <T>   The number type
     * @param value A rational floating point number.
     * @return The {@code Arcuscotangens} of {@code value}.
     */
    public static final <T extends Number & Comparable<? super T>> double acot(final T value) {
        double rc;

        double d = value.doubleValue();
        // Zero == Pi/2
        // 
        if (0D == d) {
            rc = PI_HALF;
        } // Everything above zero
        else if (d > 0D) {
            rc = Math.atan(1D / d);
        } // Everything below zero
        else {
            rc = Math.PI + Math.atan(1D / d);
        }

        return rc;
    }
}

Related

  1. acot(double x)
  2. acot(double x)