How to use SymPy (by PyCall) for solve equation, case: solve(x^2 - 4, x).
如何使用SymPy(通过PyCall)求解方程,case:solve(x ^ 2 - 4,x)。
2 个解决方案
#1
4
There are other ways, but this will work:
还有其他方法,但这将有效:
julia> using PyCall
julia> @pyimport sympy
julia> x = sympy.Symbol("x")
PyObject x
julia> convert(Function, sympy.solve)(pyeval("x**2-2", x=x))
2-element Array{Any,1}:
PyObject -sqrt(2)
PyObject sqrt(2)
#2
0
Thanks for this ;)
谢谢你;)
I modified your answer and it's working:
我修改了你的答案,它正在运作:
sympy.solve(pyeval("x**2 - 4", x = x), x)
sympy.solve(pyeval(“x ** 2 - 4”,x = x),x)
#1
4
There are other ways, but this will work:
还有其他方法,但这将有效:
julia> using PyCall
julia> @pyimport sympy
julia> x = sympy.Symbol("x")
PyObject x
julia> convert(Function, sympy.solve)(pyeval("x**2-2", x=x))
2-element Array{Any,1}:
PyObject -sqrt(2)
PyObject sqrt(2)
#2
0
Thanks for this ;)
谢谢你;)
I modified your answer and it's working:
我修改了你的答案,它正在运作:
sympy.solve(pyeval("x**2 - 4", x = x), x)
sympy.solve(pyeval(“x ** 2 - 4”,x = x),x)