Closed leesugil closed 4 months ago
f(x + dx, y) now works
g(x) = f(x + dx) - f(x) not working. hypothesis: 1) 'x' read from 'g(' 2) wiring fails as when the 'formula' is parsed, f(x) and f(x + dx) must have been parsed weird. test the hypothesis. IF true, then here's the suggested update: when wiring, before scanning x, update the expression first, replacing f(x) and f(x + dx) by it's actual expression.
three cases:
intput: h(x) = 5 * [1] 31996 segmentation fault ./a.out 2> /dev/null
intput: f(x) = 5 _removing var x [1] 32001 trace trap ./a.out 2> /dev/null
intput: h(x) = f(x) [1] 32009 segmentation fault ./a.out 2> /dev/null
the three cases are resolved
the original issue has been resolved with updateFuncComp.
however, there are two concerns with the current adaptation: 1) once updateFuncComp is called, like for example on g(x) = f(x + dx) - f(x), it completely replaces f(x + dx) and f(x) by its explicit formula in the name formula for g(x), so even if a change happens on the actual formula of f later, it's not reflected in g as g already lost the "f(" parts in its expression. this suggests that g should keep f(x + dx) and f(x) in its original expression, and should somehow have another version of Expr for replacement/calculation purposes. 2) Symb, Func, Var should be fundamentally the same, right? the current working version didn't start from the perfect design plan, but it seems reasonable to merge all of them. so, for example, g has its members
one thing to add is to be able to call things like "g(5) = f(5 + dx) - f(5)" when f is not defined. this requires a major update in Expr as it'll require a further parsing capabilities like
f(x, y, z)
/ \
x y, z
/ \
y z
progress update
updateExpr and evalSymb: ideally, when "h" is called, its p->formula->name "f((x))" is called, which should be understood as "f(x)", then "f(x)"->formula->name should be called.
highlighted part shouldn't have happened. it just returns "f((x))" as the originally registered as "h(x) = f(x)". the return also should be evaluated.
resolved
can it do something like f(x, y) = x^2 + 2 x y + y^2 so that i can also calculate (f(x + dx, y) - f(x, y)) / dx ?