internal override Symbol PreEval(Symbol x) { var z = x.ToComplex(); if (z.Re < 0 || z.Im != 0.0) { return(new Complex(Math.log(z.Re * z.Re + z.Im * z.Im) / 2, Math.atan2(z.Im, z.Re))); } return(new Complex(Math.log(z.Re))); }
internal override Algebraic SymEval(Algebraic x, Algebraic y) { if (y is Complex && !y.IsComplex() && x is Complex && !x.IsComplex()) { return(new Complex(Math.atan2((( Complex )y).Re, (( Complex )x).Re))); } if (Symbol.ZERO != x) { return(FunctionVariable.Create("atan", y / x) + FunctionVariable.Create("sign", y) * (Symbol.ONE - FunctionVariable.Create("sign", x)) * Symbol.PI / Symbol.TWO); } else { return((FunctionVariable.Create("sign", y) * Symbol.PI) / Symbol.TWO); } }
public virtual Complex Arg() { return(new Complex(Math.atan2(Im, Re))); }