using SymPy
t = symbols(“t”,real=true)
N=6
x=float(solve(diff((t^2-1)^N,t,N)))
提示如下错误,但当N<6时又可以算,不知道这是啥问题
MethodError: no method matching zero(::Type{Any})
Closest candidates are:
zero(::Type{Union{Missing, T}}) where T at missing.jl:104
zero(!Matched::Type{Pkg.Resolve.FieldValue}) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Resolve\fieldvalues.jl:38
zero(!Matched::Type{Sym}) at C:\Users\yhcqy.julia\packages\SymPy\fI5pg\src\generic.jl:64
…
谢谢提醒,这应该是Julia中solve函数的问题。
但当N=6时,还是算不了
using SymPy
t = symbols(“t”)
rts=float(solve(406080t^6-129600t^4-475200t^2+244800))
用matlab试了一下,这个多项式是有虚根的
syms t;
rts=double(solve(406080t^6-129600t^4-475200*t^2+244800))
0.7771 + 0.0000i
0.9311 + 0.0000i
0.0000 + 1.0731i
-0.7771 + 0.0000i
-0.9311 + 0.0000i
0.0000 - 1.0731i
那很有可能是封装出现了问题,solve
函数应该是SymPy
包里的
如果可以提取出系数,那建议用Polynomialsj.jl
包:
julia>p = Polynomial([244800, 0, -475200, 0, -129600, 0, 406080]);
julia> roots(p)
6-element Array{Complex{Float64},1}:
-0.9310514761322325 + 0.0im
-0.7770999104151376 + 0.0im
-2.498001805406602e-16 - 1.0731226331622161im
-2.498001805406602e-16 + 1.0731226331622161im
0.7770999104151378 + 0.0im
0.9310514761322328 + 0.0im