Filter löschen
Filter löschen

Solve not finding trivial zero

2 Ansichten (letzte 30 Tage)
HiWave
HiWave am 30 Aug. 2019
Kommentiert: John D'Errico am 30 Aug. 2019
I have a symbolic function
syms x
f = -25*x*(- 32*x^10 + 660*x^8 + 27400*x^6 + 304500*x^4 + 900000*x^2 - 2671875)
I want to solve for the zeros...
solve(f == 0,x)
and it returns an empty set. For some weird reason, if I divide f(x) by -25x, it spits out 10 complex roots as expected.
solve(f/(-25*x) == 0,x)
6.6919693149784015130684514768684
1.3248772524381469976203144660927
-1.3248772524381469976203144660927
-6.6919693149784015130684514768684
1.1011196125836762425306399367927 - 3.1220589588466888838496981405409*i
- 1.1011196125836762425306399367927 - 3.1220589588466888838496981405409*i
1.1011196125836762425306399367927 + 3.1220589588466888838496981405409*i
- 1.1011196125836762425306399367927 + 3.1220589588466888838496981405409*i
2.9737480666733788426010418554987*i
-2.9737480666733788426010418554987*i
If I recall, a 10th order polynomial is to large for an analytic solution, but I can not figure out why Matlab fails to find the trivial root x=0 ??? The reason why I ask this is because I'm trying to make plots for an arbitrary order polynomial. You give me an polynomial and I make the plot with a red X at the root locations. In the case above, I can see the roots exists in the plot, but unfortunately, Matlab fails to find the roots in my script using the solve command. How do fix this such that my script is more robust?

Akzeptierte Antwort

John D'Errico
John D'Errico am 30 Aug. 2019
Bearbeitet: John D'Errico am 30 Aug. 2019
As always, you absolutely need to tell what release you are using, because this works with no problem. Done using R2019a:
syms x
f = -25*x*(- 32*x^10 + 660*x^8 + 27400*x^6 + 304500*x^4 + 900000*x^2 - 2671875);
R = solve(f == 0,x);
vpa(R,10)
ans =
0
-1.324877252
-2.973748067i
- 1.101119613 - 3.122058959i
- 1.101119613 + 3.122058959i
-6.691969315
1.324877252
2.973748067i
1.101119613 + 3.122058959i
1.101119613 - 3.122058959i
6.691969315
numel(R)
ans =
11
So 11 roots. As expected. One of which is zero. As expected.
It is possible that your real problem which is causing an issue also may be due to needing to expand some product (rather then doing the divide by x.) Or, it may be possible that you have an old release. We cannot know what issue you are tripping on, because MATLAB has no problem with what you claim to have done.
  2 Kommentare
HiWave
HiWave am 30 Aug. 2019
Bearbeitet: HiWave am 30 Aug. 2019
To answer your question, I'm using an older version (2013a).
As for your answer, you explicitly introduced the "vpa" command, which was not part of my original question. That being said, it did clue me into using "vpasolve" avaialbe in release 2013a, as opposed to "solve", and it worked as expected.
I know the degree of the polynomial requires a numerical solution (should have though "vpasolve" earlier), but I'm surprised that "solve" works when I remove the trivial root but fails when present. Must be something "under the hood" in newer releases which addresses such scenarios? Nevertheless, problem fixed. Thanks for the feedback.
John D'Errico
John D'Errico am 30 Aug. 2019
I was wondering about an older release, so I cannot easily verify what you are seeing. Without checking, I'm not even sure that R2013 even runs on my current computer. That is a long way back in computer generations.
Note that had you used expand, there would still have been no problem, using solve. The use of vpa is relevant though.
syms x
f = -25*x*(- 32*x^10 + 660*x^8 + 27400*x^6 + 304500*x^4 + 900000*x^2 - 2671875);
>> expand(f)
ans =
800*x^11 - 16500*x^9 - 685000*x^7 - 7612500*x^5 - 22500000*x^3 + 66796875*x
First, see that expand turns this into a simple 11th degree polynomial, which solve will be able to deal with, although no matter what, it generally cannot give you an analytical solution, because the degree of the polynomial is too high. If we extract the zero root, we can see this is a 5th degree polynomial in x^2, and Abel-Ruffini tells us that that problem is in general analytically unsolvable.
See that solve returns a rather unreadable mess here, but vpa resolves that into a set of numeric roots.
solve(expand(f))
ans =
0
-root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 1)^(1/2)
-root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 2)^(1/2)
-root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 3)^(1/2)
-root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 4)^(1/2)
-root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 5)^(1/2)
root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 1)^(1/2)
root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 2)^(1/2)
root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 3)^(1/2)
root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 4)^(1/2)
root(z^5 - (165*z^4)/8 - (3425*z^3)/4 - (76125*z^2)/8 - 28125*z + 2671875/32, z, 5)^(1/2)
>> vpa(solve(expand(f)))
ans =
0
-1.3248772524381469976203144660927
-2.9737480666733788426010418554987i
- 1.1011196125836762425306399367927 + 3.1220589588466888838496981405409i
- 1.1011196125836762425306399367927 - 3.1220589588466888838496981405409i
-6.6919693149784015130684514768684
1.3248772524381469976203144660927
2.9737480666733788426010418554987i
1.1011196125836762425306399367927 - 3.1220589588466888838496981405409i
1.1011196125836762425306399367927 + 3.1220589588466888838496981405409i
6.6919693149784015130684514768684
And, tyes, you can use vpasolve too.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by