How to solve this equation with MATLAB

来源:百度知道 编辑:UC知道 时间:2024/05/14 14:21:34
x^4-3*x^3+x-1=0

display the solutions to 10 digits.

( I need the steps in details.. thx.. XD..)

至少三种算法 下面我依依列出

1.roots()

format long
p=[1 -3 0 1 -1];
roots(p)

ans =

2.922999610168974
-0.777825957360212
0.427413173595619 + 0.507101559314036i
0.427413173595619 - 0.507101559314036i

2.solve()

>> root=solve('x^4-3*x^3+x-1=0') ;
>> vpa(root,10)

ans =

2.922999610
-.777825958
.4274131736+.5071015593*i
.4274131736-.5071015593*i

3.fsolve()

>>fun=@(x)x^4-3*x^3+x-1;
>> fsolve(fun,3)
Optimization terminated: first-order optimality is less than options.TolFun.

ans =

2.922999611237489

>> fsolve(fun,-1)
Optimization terminated: first-order optimality is less than options.TolFun.

ans =

-0.777825959457477

>> vpa(roots([1 -3 0 1 -1]), 10)