-
Notifications
You must be signed in to change notification settings - Fork 141
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
symbolics_to_sympy() and variable constrains #347
Comments
We need to make a constraints system 😅 |
I made a small workaround if anyone stumbles on the same problem. I replaced the symbols created with sx = symbols("x")
sy = symbols("y")
sa = symbols("a", positive = True)
sb = symbols("b")
subsymbols(ex) = subs(ex, sx=>sa, sy=> sb)
eqns_ab = [subsymbols(symbolics_to_sympy(eq.lhs)) for eq in eqns] The solve(eqns_ab, sa, sb) # (1/4, 1/16) The nonlinsolve(eqns_ab, sa, sb) # {(1/4, 1/16)} However, solve(eqns_ab, sa, sb) # Any[]
nonlinsolve(eqns_ab, sa, sb) # {(-1/4, 1/16)} I guess my original problem can be fixed by passing a list of known, constrained SymPy symbols |
It would probably be good for those values to be stored in the variable metadata. @variables x [positive = true] |
I'd like to solve a set on nonlinear equations. As this is not implemented yet (JuliaSymbolics/SymbolicUtils.jl#63) I am trying to use SymPy to do that. This is just a MWE, real problem is a bit more complex.
Here I do a conversion to SymPy:
This solves correctly to
{(1/4,1/16)}
However, if I add additional constrains on the variables I get bad results:
This solves to an empty set:
∅
I assume this is because
symbolics_to_sympy()
creates a variablex
without constrains but I add these constrains later, insx
. Any ideas how to solve this problem?┆Issue is synchronized with this Trello card by Unito
The text was updated successfully, but these errors were encountered: