PaddiM8 / kalker

Scientific calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
https://kalker.xyz
MIT License
1.64k stars 74 forks source link

Issues with variable resolution in user defined functions #117

Closed 32Bites closed 1 year ago

32Bites commented 1 year ago

There would appear to be an issue with how the caret operator, which in this context ought to be treated as the exponentiation operator, resolves variables.

This is a minimal working example of the issue seen in f(x) = x^x, where the resulting error is Undefined variable: 'x'. when calling the function with f(1).

The issue would appear to be in how the exponent is evaluated, since f(x, y) = x^y when called with say f(2, 2), results in Undefined variable: 'y'..

I have yet to delve deep into the code to determine the cause of the issue since I was using Kalker to complete some math homework, however, when I'm not busy I will try to figure out the problem on my own time.

PaddiM8 commented 1 year ago

Hmm yeah you're right, I can reproduce this as well. I could look into it as well if you don't end up doing so. Thanks!

PaddiM8 commented 1 year ago

Should now be fixed. Turns out it perform analysis on the right hand side of power expressions, which is when it's connected to it's parent function.