/** * Instantiates a new complex node. * * @param real the real */ public ComplexNode( double real ) { super( "ComplexNode" ); this.value = new Complex( real, 0.0 ); }
@Override public Complex evaluate( Complex arg1 ) { return arg1.acos();// acos(arg1); } } );
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top"> * inverse cosine</a> of this complex number. Implements the formula: * * <pre> * <code> acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))</code> * </pre> * * Returns {@link org.matheclipse.parser.client.math.Complex#NaN} if either * real or imaginary part of the input argument is <code>NaN</code> or * infinite. * * @return the inverse cosine of this complex number * @since 1.2 */ public Complex acos() { if ( isNaN() ) { return Complex.NaN; } return this.add( this.sqrt1z().multiply( Complex.I ) ).log().multiply( Complex.I.negate() ); }
/** * Return the additive inverse of this complex number. Returns * <code>Complex.NaN</code> if either real or imaginary part of this Complex * number equals <code>Double.NaN</code>. * * @return the negation of this complex number */ public Complex negate() { if ( isNaN() ) { return NaN; } return createComplex( -real, -imaginary ); }
/** * Compute the * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top"> * square root</a> of 1 - <code>this</code><sup>2</sup> for this complex * number. Computes the result directly as * <code>sqrt(Complex.ONE.subtract(z.multiply(z)))</code>. * * Returns {@link org.matheclipse.parser.client.math.Complex#NaN} if either * real or imaginary part of the input argument is <code>NaN</code>. * * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * * @return the square root of 1 - <code>this</code><sup>2</sup> * @since 1.2 */ public Complex sqrt1z() { return createComplex( 1.0, 0.0 ).subtract( this.multiply( this ) ).sqrt(); }
/** * Return the difference between this complex number and the given complex * number. Uses the definitional formula * * <pre> * (a + bi) - (c + di) = (a-c) + (b-d)i * </pre> * * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * * @param rhs the other complex number * @return the complex number difference * @throws java.lang.NullPointerException if <code>rhs</code> is null */ public Complex subtract( Complex rhs ) { if ( isNaN() || rhs.isNaN() ) { return NaN; } return createComplex( real - rhs.getReal(), imaginary - rhs.getImaginary() ); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> of this complex number. Implements the formula: * * <pre> * <code> atan(z) = (i/2) log((i + z)/(i - z)) </code> * </pre> * * Returns {@link org.matheclipse.parser.client.math.Complex#NaN} if either * real or imaginary part of the input argument is <code>NaN</code> or * infinite. * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if ( isNaN() ) { return Complex.NaN; } return this.add( Complex.I ).divide( Complex.I.subtract( this ) ).log().multiply( Complex.I.divide( createComplex( 2.0, 0.0 ) ) ); }
if ( isNaN() ) { return Complex.NaN; return createComplex( Math.log( abs() ), Math.atan2( imaginary, real ) );
/** * Return the sum of this complex number and the given complex number. Uses * the definitional formula * * <pre> * (a + bi) + (c + di) = (a+c) + (b+d)i * </pre> * * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise Inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * * @param rhs the other complex number * @return the complex number sum * @throws java.lang.NullPointerException if <code>rhs</code> is null */ public Complex add( Complex rhs ) { return createComplex( real + rhs.getReal(), imaginary + rhs.getImaginary() ); }
/** * Evaluate. * * @param arg1 the arg 1 * @param arg2 the arg 2 * @return the complex */ @Override public Complex evaluate( Complex arg1, Complex arg2 ) { return arg1.add( arg2 ); }
@Override public Complex evaluate( Complex arg1 ) { return arg1.asin();// asin(arg1); } } );
@Override public Complex evaluate( Complex arg1 ) { return arg1.cos();// cos(arg1); } } );
@Override public Complex evaluate( Complex arg1 ) { return arg1.cosh();// cosh(arg1); } } );
/** * Evaluate. * * @param arg1 the arg 1 * @return the complex */ @Override public Complex evaluate( Complex arg1 ) { return arg1.atan();// ComplexUtils.atan(arg1); }
/** * Return the difference between this complex number and the given complex * number. * <p> * Uses the definitional formula * * <pre> * (a + bi) - (c + di) = (a-c) + (b-d)i * </pre> * * </p> * <p> * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * </p> * * @param rhs * the other complex number * @return the complex number difference * @throws NullPointerException * if <code>rhs</code> is null */ public Complex subtract(Complex rhs) { if (isNaN() || rhs.isNaN()) { return NaN; } return createComplex(real - rhs.getReal(), imaginary - rhs.getImaginary()); }
/** * Compute the <a href="http://mathworld.wolfram.com/InverseTangent.html" * TARGET="_top"> inverse tangent</a> of this complex number. * <p> * Implements the formula: * * <pre> * <code> atan(z) = (i/2) log((i + z)/(i - z)) </code> * </pre> * * </p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the input * argument is <code>NaN</code> or infinite. * </p> * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if (isNaN()) { return Complex.NaN; } return this.add(Complex.I).divide(Complex.I.subtract(this)).log().multiply(Complex.I.divide(createComplex(2.0, 0.0))); }
/** * Return the additive inverse of this complex number. * <p> * Returns <code>Complex.NaN</code> if either real or imaginary part of this * Complex number equals <code>Double.NaN</code>. * </p> * * @return the negation of this complex number */ public Complex negate() { if (isNaN()) { return NaN; } return createComplex(-real, -imaginary); }