symbolic cubic polynomial solver

조회 수: 24 (최근 30일)
Sakai
Sakai 2015년 3월 15일
댓글: John D'Errico 2015년 3월 15일
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?

채택된 답변

John D'Errico
John D'Errico 2015년 3월 15일
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
Sakai
Sakai 2015년 3월 15일
Now I understand what you really mean. Thank you very much!
John D'Errico
John D'Errico 2015년 3월 15일
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.

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

추가 답변 (1개)

Andrew Newell
Andrew Newell 2015년 3월 15일
편집: Andrew Newell 2015년 3월 15일
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
Andrew Newell
Andrew Newell 2015년 3월 15일
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 2015년 3월 15일
I see. Thank you very much!

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by