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

2 views (last 30 days)
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?

Accepted Answer

Star Strider
Star Strider on 26 Nov 2014
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

More Answers (2)

Roger Stafford
Roger Stafford on 26 Nov 2014
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 on 26 Nov 2014
Edited: John D'Errico on 26 Nov 2014
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 Comments
Austin Hazelrig
Austin Hazelrig on 4 Dec 2014
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 on 4 Dec 2014
Edited: John D'Errico on 4 Dec 2014
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.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!