/** * Compute the * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top"> * square root</a> of <code>1 - this<sup>2</sup></code> for this complex * number. * Computes the result directly as * {@code sqrt(ONE.subtract(z.multiply(z)))}. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * </p> * 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 <code>1 - this<sup>2</sup></code>. * @since 1.2 */ public Complex sqrt1z() { return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt(); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> of this complex number. * Implements the formula: * <p> * {@code atan(z) = (i/2) log((i + z)/(i - z))} * </p><p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite.</p> * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if (isNaN) { return NaN; } return this.add(I).divide(I.subtract(this)).log() .multiply(I.divide(createComplex(2.0, 0.0))); }
if ((z.subtract(oldz)).abs() <= tolerance) { return z; final Complex H = G2.subtract(d2v.divide(pv)); final Complex delta = n1C.multiply((nC.multiply(H)).subtract(G2)); final Complex dminus = G.subtract(deltaSqrt); final Complex denominator = dplus.abs() > dminus.abs() ? dplus : dminus; } else { oldz = z; z = z.subtract(nC.divide(denominator));
Complex complexFs2 = new Complex(fs2); for(int i = 0; i < z.length; i++){ zz[i] = (complexFs2.add(z[i])).divide(complexFs2.subtract(z[i])); pz[i] = (complexFs2.add(p[i])).divide(complexFs2.subtract(p[i])); for (Complex aZ : z) temp = temp.multiply(complexFs2.subtract(aZ)); for (Complex aP : p) temp2 = temp2.multiply(complexFs2.subtract(aP));
/** * @param that * @return */ public Complex subtract(final Complex that) { return fComplex.subtract(that); }
public ComplexNum subtract(final ComplexNum that) { return newInstance(fComplex.subtract(that.fComplex)); }
/** * Compute the * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top"> * square root</a> of <code>1 - this<sup>2</sup></code> for this complex * number. * Computes the result directly as * {@code sqrt(ONE.subtract(z.multiply(z)))}. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * </p> * 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 <code>1 - this<sup>2</sup></code>. * @since 1.2 */ public Complex sqrt1z() { return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt(); }
/** * Compute the * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top"> * square root</a> of <code>1 - this<sup>2</sup></code> for this complex * number. * Computes the result directly as * {@code sqrt(ONE.subtract(z.multiply(z)))}. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * </p> * 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 <code>1 - this<sup>2</sup></code>. * @since 1.2 */ public Complex sqrt1z() { return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt(); }
public static Complex solve_quadratic_2(double a, double b, double c) { return (new Complex(-b).subtract(new Complex(b * b - 4 * a * c, 0)) .sqrt()).divide(2. * a); }
public static void main(String[] args) { Complex c1 = new Complex(4.0, 8.5); Complex c2 = new Complex(8.0, 4.5); Complex result = new Complex(8.0, 4.5); result.add(c1,c2); result.print(); result.subtract(c1,c2); result.print();
public SV otherSide(double r, double x, double g1, double b1, double g2, double b2, double ratio) { Complex z = new Complex(r, x); // z=r+jx Complex y1 = new Complex(g1, b1); // y1=g1+jb1 Complex y2 = new Complex(g2, b2); // y2=g2+jb2 Complex s1 = new Complex(p, q); // s1=p1+jq1 Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a)); Complex v1 = u1.divide(Math.sqrt(3f)); // v1=u1/sqrt(3) Complex v1p = v1.multiply(ratio); // v1p=v1*rho Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) Complex i1p = i1.divide(ratio); // i1p=i1/rho Complex i2p = i1p.subtract(y1.multiply(v1p)); // i2p=i1p-y1*v1p Complex v2 = v1p.subtract(z.multiply(i2p)); // v2p=v1p-z*i2 Complex i2 = i2p.subtract(y2.multiply(v2)); // i2=i2p-y2*v2 Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) Complex u2 = v2.multiply(Math.sqrt(3f)); return new SV(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument())); }
private Complex transform(Complex c) { if (c.isInfinite()) return new Complex(-1, 0); // frequency transform c = c.multiply(f); Complex one = new Complex(1, 0); // bilinear low pass transform return (one.add(c)).divide(one.subtract(c)); }
public SV otherSide(double r, double x, double g, double b, double ratio) { Complex z = new Complex(r, x); // z=r+jx Complex y = new Complex(g, b); // y=g+jb Complex s1 = new Complex(p, q); // s1=p1+jq1 Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a)); Complex v1 = u1.divide(Math.sqrt(3f)); // v1=u1/sqrt(3) Complex v1p = v1.multiply(ratio); // v1p=v1*rho Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) Complex i1p = i1.divide(ratio); // i1p=i1/rho Complex i2 = i1p.subtract(y.multiply(v1p)); // i2=i1p-y*v1p Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2 Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) Complex u2 = v2.multiply(Math.sqrt(3f)); return new SV(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument())); }
public StateVariable toSv2(StateVariable sv1) { Complex s1 = new Complex(-sv1.p, -sv1.q); // s1=p1+jq1 Complex u1 = ComplexUtils.polar2Complex(sv1.u, Math.toRadians(sv1.theta)); Complex v1 = u1.divide(SQUARE_3); // v1=u1/sqrt(3) Complex v1p = v1.multiply(ratio); // v1p=v1*rho Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) Complex i1p = i1.divide(ratio); // i1p=i1/rho Complex i2 = i1p.subtract(y.multiply(v1p)).negate(); // i2=-(i1p-y*v1p) Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2 Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) Complex u2 = v2.multiply(SQUARE_3); return new StateVariable(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument())); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> of this complex number. * Implements the formula: * <p> * {@code atan(z) = (i/2) log((i + z)/(i - z))} * </p><p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite.</p> * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if (isNaN) { return NaN; } return this.add(I).divide(I.subtract(this)).log() .multiply(I.divide(createComplex(2.0, 0.0))); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> of this complex number. * Implements the formula: * <p> * {@code atan(z) = (i/2) log((i + z)/(i - z))} * </p><p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite.</p> * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if (notDefined) { return NaN; } return this.add(I).divide(I.subtract(this)).log() .multiply(I.divide(createComplex(2.0, 0.0))); }
private Complex transform(Complex c) { if (c.isInfinite()) return new Complex(1, 0); // frequency transform c = c.multiply(f); // bilinear high pass transform return new Complex(-1).multiply((new Complex(1)).add(c)).divide( (new Complex(1)).subtract(c)); }
private ComplexPair transform(Complex c) { if (c.isInfinite()) c = new Complex(-1); else c = ((new Complex(1)).add(c)).divide((new Complex(1)).subtract(c)); // bilinear Complex u = new Complex(0); u = MathSupplement.addmul(u, 4 * (b2 + a2 - 1), c); u = u.add(8 * (b2 - a2 + 1)); u = u.multiply(c); u = u.add(4 * (a2 + b2 - 1)); u = u.sqrt(); Complex v = u.multiply(-.5); v = v.add(a); v = MathSupplement.addmul(v, -a, c); u = u.multiply(.5); u = u.add(a); u = MathSupplement.addmul(u, -a, c); Complex d = new Complex(b + 1); d = MathSupplement.addmul(d, b - 1, c); return new ComplexPair(u.divide(d), v.divide(d)); }
private ComplexPair transform(Complex c) { if (c.isInfinite()) { return new ComplexPair(new Complex(-1), new Complex(1)); } c = ((new Complex(1)).add(c)).divide((new Complex(1)).subtract(c)); // bilinear Complex v = new Complex(0); v = MathSupplement.addmul(v, 4 * (b2 * (a2 - 1) + 1), c); v = v.add(8 * (b2 * (a2 - 1) - 1)); v = v.multiply(c); v = v.add(4 * (b2 * (a2 - 1) + 1)); v = v.sqrt(); Complex u = v.multiply(-1); u = MathSupplement.addmul(u, ab_2, c); u = u.add(ab_2); v = MathSupplement.addmul(v, ab_2, c); v = v.add(ab_2); Complex d = new Complex(0); d = MathSupplement.addmul(d, 2 * (b - 1), c).add(2 * (1 + b)); return new ComplexPair(u.divide(d), v.divide(d)); }