Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbolic solution of linear equation system returns wrong results #447

Open
hpaantee opened this issue Jun 29, 2023 · 2 comments
Open

Symbolic solution of linear equation system returns wrong results #447

hpaantee opened this issue Jun 29, 2023 · 2 comments

Comments

@hpaantee
Copy link

Related to #442. Solving a linear system Ax=b symbolically via A.LUsolve(b) returns a wrong result. Both when using .subs or Lambdify. The result contains values of up to e+100. When solving the linear system numerically I get the correct result, with no value exceeding e-02.

What causes this difference? In this comment (sympy/sympy#25208 (comment)) one contributor of sympy also mentions the accuracy difference. Where does this come from?

@hpaantee
Copy link
Author

Small update: By converting every number in A and b from python's float to sympy's (and later symengine's) Float and specifying a precision via the dps argument, I got quite some improvement in the result. However, the result is still quite off and not yet usable. Even setting dps=1000 does not help.

@isuruf
Copy link
Member

isuruf commented Jun 30, 2023

With symbolic values, you can't do pivoting correctly. LU decomposition using Gaussian elimination can be numerically unstable when small values are chosen as pivots and roundoff errors become larger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants