How do I solve solve an equation for the first complex root?
2 次查看(过去 30 天)
显示 更早的评论
I need to be able to solve the following equation for its first root
15.36*L^2 + L*(19592.58957620995934121310710907*i - 1919917.6232407807483900796796661) + (14998852.92303687865065071910875 - 82922.533414158501558648943613169*i)
However, when I use the solve function
solve(15.36*L^2 + L*(19592.58957620995934121310710907*i - 1919917.6232407807483900796796661) + (14998852.92303687865065071910875 - 82922.533414158501558648943613169*i))
Warning: Explicit solution could not be found.
> In solve at 169
ans =
[ empty sym ]
is displayed.
I know the answer is L=7.81235+.0365383i. How can I make MATLAB display this answer?
0 个评论
采纳的回答
Star Strider
2014-11-26
You’re not asking it correctly:
syms L
p = 15.36*L^2 + L*(19592.58957620995934121310710907*i - 1919917.6232407807483900796796661) + (14998852.92303687865065071910875 - 82922.533414158501558648943613169*i);
L = roots(sym2poly(p))
L =
124.9868e+003 - 1.2756e+003i
7.8124e+000 + 36.5383e-003i
0 个评论
更多回答(2 个)
Roger Stafford
2014-11-26
This is a quadratic equation of the form "a*x^2+b*x+c=0" with complex-valued coefficients, b and c. The same formula as for reals is valid:
x = (-b+(+1or-1)*(b^2-4*a*c)^(1/2))/(2*a)
and very likely both roots are complex-valued. Why don't you use that instead of bothering with 'solve'?
The 'sort' function documentation says "The sort function sorts complex elements first by absolute value (magnitude), then by phase angle", so perhaps that is the ordering you had in mind when you said "first root".
0 个评论
John D'Errico
2014-11-26
编辑:John D'Errico
2014-11-26
You have formulated the problem for solve ENTIRELY correctly, despite what Star said. However, there are often many ways to solve any problem, and a quadratic polynomial is pretty easy any way you do it.
Make sure both i and L are as they should be. Since i is often used as a variable...
syms L
i = sqrt(-1);
res = solve(15.36*L^2 + L*(19592.58957620995934121310710907*i - 1919917.6232407807483900796796661) + (14998852.92303687865065071910875 - 82922.533414158501558648943613169*i))
res =
206149585070830075/3298534883328 - (25*(23201164600960114908747505178983141/928455029464035206174343168 - (555078919214256089878496645717587*i)/1088033237653166257235558400)^(½))/2 - (67319625179017825*i)/105553116266496
(25*(23201164600960114908747505178983141/928455029464035206174343168 - (555078919214256089878496645717587*i)/1088033237653166257235558400)^(½))/2 + 206149585070830075/3298534883328 - (67319625179017825*i)/105553116266496
It works fine for me.
vpa(res)
ans =
7.8123531480905849356308465638994 + 0.036538267898098900099620705189207*i
124986.82457659024169482817452297 - 1275.5957554690674215826927161319*i
Take your pick of the roots.
2 个评论
John D'Errico
2014-12-4
编辑:John D'Errico
2014-12-4
The latest/current release (R2014b). It should work on any release that has the symbolic toolbox. Nothing of note has changed that I know of.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!