How do I solve solve an equation for the first complex root?

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?

 채택된 답변

Star Strider
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

추가 답변 (2개)

Roger Stafford
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".
John D'Errico
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

What year MATLAB are you running? I have tried this method on both R2010 and R2012. Both gave me an empty sym vector.
John D'Errico
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

질문:

2014년 11월 26일

편집:

2014년 12월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by