/** * Return the absolute value of the given complex number * * @param num the number to getScalar the absolute value for * @return the absolute value of this complex number */ public static IComplexNumber sqrt(IComplexNumber num) { Complex c = new Complex(num.realComponent().doubleValue(), num.imaginaryComponent().doubleValue()).sqrt(); return Nd4j.createDouble(c.getReal(), c.getImaginary()); }
/** * 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(); }
final Complex delta = n1C.multiply((nC.multiply(H)).subtract(G2)); final Complex deltaSqrt = delta.sqrt(); final Complex dplus = G.add(deltaSqrt); final Complex dminus = G.subtract(deltaSqrt);
Complex number = new Complex(-4); System.out.println("Square root: " + number.sqrt());
/** * Return the absolute value of the given complex number * * @param num the number to getScalar the absolute value for * @return the absolute value of this complex number */ public static IComplexNumber sqrt(IComplexNumber num) { Complex c = new Complex(num.realComponent().doubleValue(), num.imaginaryComponent().doubleValue()).sqrt(); return Nd4j.createDouble(c.getReal(), c.getImaginary()); }
/** * 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(); }
/** * c = sqrt(a) Michael Borcherds 2010-02-07 * * @param a * a * @param c * c */ public static void complexSqrt(GeoVec2D a, GeoVec2D c) { Complex out = new Complex(a.x, a.y); out = out.sqrt(); c.x = out.getReal(); c.y = out.getImaginary(); c.setMode(Kernel.COORD_COMPLEX); }
public static Complex solve_quadratic_1(double a, double b, double c) { return (new Complex(-b).add(new Complex(b * b - 4 * a * c, 0)).sqrt()) .divide(2. * a); }
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 ValueType sqrt(CalculatedValue g) { if (g.isComplex() || (g.isReal() && g.real < 0)) { if (g.unit != null) { invalidate(ErrorType.INCOMPATIBLE_UNIT); } else { unit = null; } return setComplexValue(g.getComplex().sqrt()); } else { if (g.unit != null) { unit = g.unit.root(2); } else { unit = null; } return setValue(FastMath.sqrt(g.real)); } }
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)); }
final Complex delta = n1C.multiply((nC.multiply(H)).subtract(G2)); final Complex deltaSqrt = delta.sqrt(); final Complex dplus = G.add(deltaSqrt); final Complex dminus = G.subtract(deltaSqrt);
final Complex delta = n1C.multiply((nC.multiply(H)).subtract(G2)); final Complex deltaSqrt = delta.sqrt(); final Complex dplus = G.add(deltaSqrt); final Complex dminus = G.subtract(deltaSqrt);