Complex Values in Evaluate

(Qoptics) #1

When I evaluate this code in C#:

var Parsed = Infix.ParseOrUndefined(“a*sqrt(-1)”);
var Vars = new Dictionary<string, FloatingPoint>();
Vars.Add(“a”, 1.0);
var Answer = Evaluate.Evaluate(Vars, Parsed);

the value of “Answer” is undef. I’d expected it to be -i. Am I missing something, or is there an issue with complex values in evaluate?


Thanks @qoptics, it seems like a bug and I guess I know where problem is it.

(Qoptics) #3

That looks like the culprit. It seems you need a case that uses the complex power function for negative x with non-integer y. Also, do you need a special case for x=0 and y=-1 to handle the 1/0 condition?

Thanks for your work.

(Christoph Rüegg) #4

Yes. Thanks for reporting this. We likely also have the same problem in the Approximation-related modules.

I’ve noticed we have poor test coverage on Complex number use cases. I’ve added a separate issue for that.