Symbolics.jl - solve_for not defined

When I tried to use Symbolics.jl to sovle a simple equation, I ran into the error saying that solve_for was not defined. Below you can see the package status and a screenshot from the docs. Am I wrong, or is something not adding up?


A more general question - can this function only solve linear equations? Are there plans to make it able to solve more general equations?

I am not very sure what the future plans are, but I can answer some of the concrete questions.

solve_for is not exported, so to call it, it requires to be called as Symbolics.solve_for as follows

julia> using Symbolics

julia> @variables x y
(x, y)

julia> Symbolics.solve_for([x + y ~ 3, x - y ~ 1], [x, y])
2-element Array{Num,1}:
 2.0
 1.0

julia> Symbolics.solve_for([x^2 ~ 1], [x])
ERROR: AssertionError: islinear(ex, vars)
Stacktrace:
 [1] A_b(::Array{Equation,1}, ::Array{Num,1}, ::Bool) at /home/syx/.julia/packages/Symbolics/knY95/src/linear_algebra.jl:62
 [2] solve_for(::Array{Equation,1}, ::Array{Num,1}; simplify::Bool, check::Bool) at /home/syx/.julia/packages/Symbolics/knY95/src/linear_algebra.jl:88
 [3] solve_for(::Array{Equation,1}, ::Array{Num,1}) at /home/syx/.julia/packages/Symbolics/knY95/src/linear_algebra.jl:88
 [4] top-level scope at REPL[4]:1
 [5] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.3/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

as you can see, it currently only works on Linear equations.

2 Likes

Needs more work for nonlinear. It’s planned.

1 Like

I’m looking into a problem (WENO reconstruction) where I have, say, 5 linear equations and 3 unknowns. The solution exists and is unique, though.

Since solver_for appears to require the same number of equations and unknowns (statement above), would it be better for now to write a simple function for setting this in matrix form, and solve it using the LinearAlgebra package?