top | item 25255543

(no title)

nitsuaeekcm | 5 years ago

SymPy is pretty niche, but it saved my butt many years ago in my years of collegiate robotics. We spent months unsuccessfully trying to compute kinematics and sensor coordinate transformations on vectors of quarternions by “hand” with numpy. I wouldn’t wish it on my worst enemy. There are so many opportunities for mistakes, and the intermediate numbers can rarely be checked against your intuition.

With SymPy however (and some optional Newtonian physics package), one can simply define their free-bodies and coordinate systems, and SymPy will spit out simplified, compiled tensors of whatever expressions they want! It was truly magical at the time.

discuss

order

creata|5 years ago

> SymPy is pretty niche

I don't know; I use isympy (interactive sympy, uses IPython if installed) as a local Wolfram Alpha for all my math problems, and it's really good at that.

qubex|5 years ago

> as a local Wolfram Alpha

It’s called Mathematica, son.

DylanDmitri|5 years ago

I wrote an "anything-regressor" in SymPy, where you provide an equation (like y=mx+b) and a dataset of x's and y's, and it solves for constants to get a line of best fit. Super simple to implement and worked for any equation (quartic, logistic, etc) and any dimension of input variables.

Eventual goal was trying to implement something like XGBoost, but by applying successive regression equations to the residuals instead of successive decision trees. E.g. figure out that a sin wave best fits the initial data, and then a linear best explains the remaining difference.

Worked pretty well on toy data sets, but was much too slow to scale to anything real. Still think the idea has promise for producing human interpretable ML models.

nestorD|5 years ago

This sounds like symbolic regression (where the space of possible equations is usually searched using genetic algorithm).

10000truths|5 years ago

Similar situation here. I needed to optimize a critical C++ function that took two 3D line segments and returned a transform matrix that would transform the first line segment into the second. I was able to completely remove the matrix multiplications from the function by using SymPy to pre-compose the scale/rotate/translate matrices and simplify the result, and the benchmarks showed a significant speedup.

billfruit|5 years ago

I was grappling some very similar problem, and working with numerical results to verify intermediate results wasn't helpful and finally had to turn to maxima to final give analytically derived and simplified expressions.

These symbolic tools can save ones skin on a bad day.