symbolic cubic polynomial solver

22 visualizaciones (últimos 30 días)
Sakai
Sakai el 15 de Mzo. de 2015
Comentada: John D'Errico el 15 de Mzo. de 2015
Cubic polynomial always has a zero point on the real line, so I run something like
syms x a
solve(x^3+x^2-x+a,'real',true)
ans =
sin(atan((2*(1/27 - a^2/4)^(1/2))/a)/3) -...
1/(3*((a^2/4 - 1/27)^(1/2) - a/2)^(1/3)) + ...
sin(atan((2*(1/27 - a^2/4)^(1/2))/a)/3 - pi/3)...
- 1/(3*(a/2 - (a^2/4 - 1/27)^(1/2))^(1/3))...
- sin(atan((2*(1/27 - a^2/4)^(1/2))/a)/3)...
- sin(atan((2*(1/27 - a^2/4)^(1/2))/a)/3 - pi/3) -...
(2*3^(1/2)*cos(atan((2*(1/27 - a^2/4)...
(2*3^(1/2)*cos(atan((2*(1/27 - a^2/4)^(1/2))...
I cut the ... part b/c it's too long, but my point is that Matlab gave me 8 solutions. Can somebody tell me what is going on? Where is the fundamental theorem of algebra?

Respuesta aceptada

John D'Errico
John D'Errico el 15 de Mzo. de 2015
Hmm. Did you tell it what to solve for? Should MATLAB magically know that x was your unknown, and a only a symbolic constant, for which you have chosen not to supply a value?
solve(x^3+x^2-x+a,x)
This returns 3 solutions. A problem is that 1 or 3 of them MAY be real, depending on the value of a. Since you won't tell MATLAB what is a, it can't know yet which one(s) are real.
  6 comentarios
Sakai
Sakai el 15 de Mzo. de 2015
Now I understand what you really mean. Thank you very much!
John D'Errico
John D'Errico el 15 de Mzo. de 2015
Good. I do admit that until I decided to do those last few things, I think there was some confusion as to why MATLAB was returning 8 solutions, or what appeared to be 8 of them.

Iniciar sesión para comentar.

Más respuestas (1)

Andrew Newell
Andrew Newell el 15 de Mzo. de 2015
Editada: Andrew Newell el 15 de Mzo. de 2015
I ran the same code and got 3 solutions:
syms x a
xsols = solve(x^3+x^2-x+a,'real',true);
size(xsols)
ans =
3 1
I think you're interpreting those eight lines as one solution per line, but the triple dots at the end of the line mean that the solution continues on the next line. You are really just displaying one of the three solutions.
  4 comentarios
Andrew Newell
Andrew Newell el 15 de Mzo. de 2015
It appears that in 2014a, the option 'real',true didn't have any effect; but in 2014b, the engine is trying to figure out what parts of the solution are real.
Consider: in complex space, for each value of a (which, as far as solve knows might be complex) you have three complex solutions. Without 'real',true, solve is returning the equations for (real(x), imag(x)) as a function of (real(a), imag(a)) - not a line, but a surface. With 'real',true, it is trying to determine where this surface intersects imag(x) = 0. That could be any number of line segments.
Sakai
Sakai el 15 de Mzo. de 2015
I see. Thank you very much!

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by