How to solve equation?

조회 수: 5 (최근 30일)
dan chen
dan chen 2020년 5월 8일
댓글: Ameer Hamza 2020년 5월 8일
equ = x^3 + (29*x^2)/100 - (1351*x)/100 + 359/50 == 0
Spectrum = solve(equ, x)
Hi, trying to solve this equation but get something like that.
Spectrum =
root(z^3 + (29*z^2)/100 - (1351*z)/100 + 359/50, z, 1)
root(z^3 + (29*z^2)/100 - (1351*z)/100 + 359/50, z, 2)
root(z^3 + (29*z^2)/100 - (1351*z)/100 + 359/50, z, 3)

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 8일
편집: Ameer Hamza 2020년 5월 8일
First
You can force MATLAB to write its explicit form using MaxDegree with solve()
syms x
equ = x^3 + (29*x^2)/100 - (1351*x)/100 + 359/50 == 0
Spectrum = solve(equ, x, 'MaxDegree', 3)
Result
Spectrum =
406141/(90000*(- 114584939/27000000 + (1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000)^(1/3)) + ((1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000 - 114584939/27000000)^(1/3) - 29/300
- (3^(1/2)*(406141/(90000*(- 114584939/27000000 + (1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000)^(1/3)) - ((1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000 - 114584939/27000000)^(1/3))*1i)/2 - 406141/(180000*(- 114584939/27000000 + (1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000)^(1/3)) - ((1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000 - 114584939/27000000)^(1/3)/2 - 29/300
(3^(1/2)*(406141/(90000*(- 114584939/27000000 + (1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000)^(1/3)) - ((1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000 - 114584939/27000000)^(1/3))*1i)/2 - 406141/(180000*(- 114584939/27000000 + (1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000)^(1/3)) - ((1200000000^(1/2)*88664127737^(1/2)*1i)/1200000000 - 114584939/27000000)^(1/3)/2 - 29/300
Second
Or you can get output in variable precision numeric format
syms x
equ = x^3 + (29*x^2)/100 - (1351*x)/100 + 359/50 == 0
Spectrum = vpa(solve(equ, x, 'MaxDegree', 3))
Result
Spectrum =
3.2163511711964122946143841774131 + 3.6734198463196484624023016788195e-40i
- 4.056644260843024929305472877667 + 3.6734198463196484624023016788195e-40i
0.55029308964661263469108870025384 - 7.346839692639296924804603357639e-40i
The solution has a tiny complex part, probably due to numeric errors. You can extract the real part like this
real(Spectrum)
Third
Directly convert to floating-point format using double
syms x
equ = x^3 + (29*x^2)/100 - (1351*x)/100 + 359/50 == 0
Spectrum = double(solve(equ, x, 'MaxDegree', 3))
Spectrum = real(Spectrum)
Result
Spectrum =
3.2164
-4.0566
0.5503
  댓글 수: 2
dan chen
dan chen 2020년 5월 8일
Thanks!
Ameer Hamza
Ameer Hamza 2020년 5월 8일
I am glad to be of help.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by