robpike / ivy

ivy, an APL-like calculator
Other
1.32k stars 103 forks source link

value: internal evaluation must use builtins #107

Closed robpike closed 2 years ago

robpike commented 2 years ago

This program:

op atan x = 0j0.5 * log(1-x)/1+z

is the formula for the atan of complex x. The formula is right but the evaluation is not, because internally log of a complex number will call atan, and get this one instead of the real atan. Trouble ensues, to put it politely.

Internal calls to things like EvalUnary(c, "atan") should be guaranteed to get the real one. Should be easy if we have a builtin context. Or maybe not.