Java Code Examples for org.apache.commons.math.util.MathUtils#cosh()
The following examples show how to use
org.apache.commons.math.util.MathUtils#cosh() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Complex.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i * </code> * </pre> * * @return the hyperbolic tangent of {@code this}. * @since 1.2 */ public Complex tanh() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d); }
Example 2
Source File: Cardumen_00113_t.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i * </code> * </pre> * * @return the hyperbolic tangent of {@code this}. * @since 1.2 */ public Complex tanh() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d); }
Example 3
Source File: Cardumen_00218_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 4
Source File: Cardumen_0044_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 5
Source File: Complex.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}.</p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>.</p> * <p> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i</code></pre></p> * * @return the tangent of this complex number * @since 1.2 */ public Complex tan() { if (isNaN()) { return Complex.NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 6
Source File: ComplexUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Cosine.html" TARGET="_top"> * cosine</a> * for the given complex argument. * <p> * Implements the formula: <pre> * <code> cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>. * <p> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * cos(1 ± INFINITY i) = 1 ∓ INFINITY i * cos(±INFINITY + i) = NaN + NaN i * cos(±INFINITY ± INFINITY i) = NaN + NaN i</code></pre> * * @param z the value whose cosine is to be returned * @return the cosine of <code>z</code> * @throws NullPointerException if <code>z</code> is null */ public static Complex cos(Complex z) { if (z.isNaN()) { return Complex.NaN; } double a = z.getReal(); double b = z.getImaginary(); return new Complex(Math.cos(a) * MathUtils.cosh(b), -Math.sin(a) * MathUtils.sinh(b)); }
Example 7
Source File: Math_47_Complex_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 8
Source File: Math_47_Complex_t.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 9
Source File: Cardumen_00168_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 10
Source File: Cardumen_00113_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 11
Source File: Math_46_Complex_t.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i * </code> * </pre> * * @return the hyperbolic tangent of {@code this}. * @since 1.2 */ public Complex tanh() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d); }
Example 12
Source File: Cardumen_0044_t.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i * </code> * </pre> * * @return the tangent of {@code this}. * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 13
Source File: Arja_0035_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}.</p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>.</p> * <p> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i</code></pre></p> * * @return the tangent of this complex number * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 14
Source File: JGenProg2015_007_s.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}.</p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>.</p> * <p> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i</code></pre></p> * * @return the hyperbolic tangent of this complex number * @since 1.2 */ public Complex tanh() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d); }
Example 15
Source File: Math_53_Complex_t.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}.</p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>.</p> * <p> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i</code></pre></p> * * @return the tangent of this complex number * @since 1.2 */ public Complex tan() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 16
Source File: Complex.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * Implements the formula: * <pre> * <code> * tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i * </code> * </pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <br/> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * <br/> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * <pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i * </code> * </pre> * * @return the hyperbolic tangent of {@code this}. * @since 1.2 */ public Complex tanh() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d); }
Example 17
Source File: Complex.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> of this complex number. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}.</p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>.</p> * <p> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±π/2 + 0 i) = ±INFINITY + NaN i</code></pre></p> * * @return the tangent of this complex number * @since 1.2 */ public Complex tan() { if (isNaN()) { return Complex.NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = Math.cos(real2) + MathUtils.cosh(imaginary2); return createComplex(Math.sin(real2) / d, MathUtils.sinh(imaginary2) / d); }
Example 18
Source File: ComplexUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top"> * tangent</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>. * <p> * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tan(1 ± INFINITY i) = 0 + NaN i * tan(±INFINITY + i) = NaN + NaN i * tan(±INFINITY ± INFINITY i) = NaN + NaN i * tan(±&pi/2 + 0 i) = ±INFINITY + NaN i</code></pre> * * @param z the value whose tangent is to be returned * @return the tangent of <code>z</code> * @throws NullPointerException if <code>z</code> is null */ public static Complex tan(Complex z) { if (z.isNaN()) { return Complex.NaN; } double a2 = 2.0 * z.getReal(); double b2 = 2.0 * z.getImaginary(); double d = Math.cos(a2) + MathUtils.cosh(b2); return new Complex(Math.sin(a2) / d, MathUtils.sinh(b2) / d); }
Example 19
Source File: Complex.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * <p> * Implements the formula: <pre> * <code>tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i</code></pre> * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}.</p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is <code>NaN</code>.</p> * <p> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result.<pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i</code></pre></p> * * @return the hyperbolic tangent of this complex number * @since 1.2 */ public Complex tanh() { if (isNaN()) { return Complex.NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + Math.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, Math.sin(imaginary2) / d); }
Example 20
Source File: Complex_t.java From coming with MIT License | 3 votes |
/** * Compute the * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top"> * hyperbolic tangent</a> of this complex number. * <p> * Implements the formula: * * <pre> * <code>tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i</code> * </pre> * * where the (real) functions on the right-hand side are * {@link java.lang.Math#sin}, {@link java.lang.Math#cos}, * {@link MathUtils#cosh} and {@link MathUtils#sinh}. * </p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the input * argument is <code>NaN</code>. * </p> * <p> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * * <pre> * Examples: * <code> * tanh(1 ± INFINITY i) = NaN + NaN i * tanh(±INFINITY + i) = NaN + 0 i * tanh(±INFINITY ± INFINITY i) = NaN + NaN i * tanh(0 + (π/2)i) = NaN + INFINITY i</code> * </pre> * </p> * * @return the hyperbolic tangent of this complex number * @since 1.2 */ public Complex tanh() { if (isNaN) { return NaN; } double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d); }