News for hackers. Stuff that matters.
Re:SymPy: Symbolic Mathematics in Python by whyever on Wednesday February 28, 2024 @09:32AM (#39538433)
Why are you calculating the Jacobian symbolically? AFAIK, for complex cases, the numerical Jacobian is often faster / more numerically stable.
Re:SymPy: Symbolic Mathematics in Python by abricq on Wednesday February 28, 2024 @09:40AM (#39538534)
Well, the symbolic computation is only used to generate C code. The generated code then evaluates jacobians numerically. And we use several methods for numerical stability on top of that.
Re:SymPy: Symbolic Mathematics in Python by eutectic on Wednesday February 28, 2024 @11:01AM (#39539684)
I though finite difference differentiation was notoriously unstable.
Re:SymPy: Symbolic Mathematics in Python by legobmw99 on Wednesday February 28, 2024 @11:10AM (#39539846)
Perhaps the commenter means something like reverse mode automatic differentiation?

Finite differences does indeed have stability issues, and even if you apply some tricks will only give you about half float precision

Re:SymPy: Symbolic Mathematics in Python by funks_ on Wednesday February 28, 2024 @10:53AM (#39539568)
Especially if you actually require vector-Jacobian or Jacobian-vector products instead of the full Jacobian.
Re:SymPy: Symbolic Mathematics in Python by mitthrowaway2 on Wednesday February 28, 2024 @12:46PM (#39541319)
The poster is talking about using symbolic math to obtain a closed-form expression for the Jacobian that is then numerically evaluated. This will often be faster and more accurate. For example, if your function is sin(x), then the symbolic math tells you your derivative is cos(x), so you put that expression in your code and compile it. When calling this on the angle x = 0.123, your code then just evaluates numerically cosf(0.123), rather than (sinf(0.124) - sinf(0.122)).
Re:SymPy: Symbolic Mathematics in Python by toolslive on Wednesday February 28, 2024 @12:46PM (#39541321)
There are plenty of situations where the scenario goes like this: you first do symbolical calculations. then fill in some of the free variables, your resulting expression will simplify a lot. Then you compile that resulting expression to native code and evaluate the simplified specialized code for a zillion parameter vectors.

Anyway,if your day job needs something like this you're better off using a lisp than python.

Re:SymPy: Symbolic Mathematics in Python by thebiss on Friday March 01, 2024 @12:03PM (#39563828)
For those of us that have never touched lisp - can you explain why?
Re:SymPy: Symbolic Mathematics in Python by toolslive on Wednesday March 06, 2024 @05:04PM (#39622272)
Lisp has quote, unquote, and friends allowing you to turn code into data, then manipulate it and then turn it back into code. These are all the tools you need to create on-the-fly compilers. Here's an article explaining the lost art:

http://gms.freeshell.org/peval.html