This may be the most ridiculous use of about 3000 lines of VEX, but I've made an equation evaluator / solver / fitter asset, and I'm wondering if there are any obvious use cases it should support but doesn't before I post it to Orbolt. For example, function minimization would be easy to add, but I'm not sure on how the UI should behave for it. Would anyone find the parsed equation info useful? Etc.
Anyway, the default shows it can recognize that “0.27 sin tau (1.3x + 0.4time)” means the same thing as “y = 0.27*sin(6.283185307*(1.3*P.x + 0.4*time))”, and yes, it'll accept that too. (Note: tau is 2pi [youtube.com].)
It supports so much stuff that I won't try to jam everything in here, but as an example of the non-linear solver, you can type in “0 = (1-x0)^2 + 100(y0-x0^2)^2” (the Rosenbrock banana function) and set Solver to “Always non-linear”, and it'll solve for the x0 and y0 that get closest to solving the equation, (in this case, x0=1 and y0=1).
I always forget the basis functions for representing a cubic function in terms of 2 values and 2 derivatives, but I remember how to get it down to solving a system of linear equations for each, so I've tested that out using 4 equations and 4 unknowns. Just make sure the unknowns aren't named any already-defined keywords or attributes, like x, y, z, P, e, or i. The linear solver is much faster than the non-linear solver, but only works if all equations are linear in the unknowns; (they can be non-linear in the input values, like x, y, etc).
If you have input data and you want to find the values of unknowns that make an equation best fit the data, you can put the data into the first input, type in the equation with unknowns, and choose the solver. For example, to fit a sum of two exponentials to some data, you can use “y = a0 exp(g0 x) + a1 exp(g1 x)”. If the data have different confidence levels in an attribute “errorbar”, you can append “+/- errorbar”, and it will take that into account, which can be quite useful, since least-squares regression (whether linear or non-linear) is quite susceptible to outliers. If you have animated data and don't want the equation to be re-parsed on every frame, there's a way around that too with the last input.
It supports vectors and complex numbers, and will treat float and float attributes as them automatically. To create a vector, use “vector(a,b,c)”, and for complex numbers, “complex(r,i)”. You can access components with square brackets or “.x” etc. There are also related functions, dot, cross, length, length2, conj, re, im. e^(i tau x) will correctly give a complex number with unit length and phase tau*x. It doesn't support vector or complex unknowns, but if you're using the non-linear solver, you can do things like “complex(unknownReal,unknownImag)”.
Anyway, I'm especially looking forward to using this with the Load Data Table asset [orbolt.com], (like the Table Import SOP, but beefier), as well as making animated function plots, and I'll be putting this on Orbolt too… maybe after writing some help for it, though. :wink: