JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://docs.sciml.ai/Symbolics/stable/
Other
1.35k stars 151 forks source link

`solve_for` fails for fractions #424

Open jkosata opened 2 years ago

jkosata commented 2 years ago

for @variables a,b

the following works fine

solve_for([b] .~ [a], [b]) ---> a

however

solve_for([b/a] .~ [1], [b]) ---> AssertionError: islinear

┆Issue is synchronized with this Trello card by Unito

owiecc commented 2 years ago

It is not working for nonlinear equations yet. See the docs.

jkosata commented 2 years ago

I know, but both equations above are linear in b I was just wondering whether not multiplying by a is intentional here (in case a ends up being 0) or not.

owiecc commented 2 years ago

True. I made the same mistake as the algorithm. I saw a / and blindly assumed it is a non-linear equation.

linear_expansion function first converts the b/a~1 equation to 1-b/a and then goes down the computation tree. When it reaches b/a it proclaims the equation nonlinear.

Needs a test/linear_solver.jl

A, b, islinear = Symbolics.linear_expansion(x/y ~ 1, x)
@test_broken isequal(islinear, true)