How can I increase the decimal digits in the result of my program ? for example 50 or 80 digits .

2 ビュー (過去 30 日間)
format long
x=(pi);
for i=1:10
fx=cos(x(i))-3*x(i)+1;
fxx=-sin(x(i))-3;
x(i+1)=x(i)-(fx/fxx);
end
x(10)
% THE RESULT IS = 0.607101648103123

回答 (1 件)

Star Strider
Star Strider 2017 年 1 月 27 日
If you have the Symbolic Math Toolbox, you can use it. Another option is John D’Errico’s HPF - a big decimal class in the File Exchange.
  2 件のコメント
khalid boureeny
khalid boureeny 2017 年 1 月 27 日
編集済み: per isakson 2017 年 1 月 27 日
Hi, Star Strider ...thanks a lot for your help ...
I do have Symbolic math toolbox , but the problem is I'm beginner and I don't know how ... can you modify this program for me ...
format long
x=(pi);
for i=1:10
fx=cos(x(i))-3*x(i)+1;
fxx=-sin(x(i))-3;
x(i+1)=x(i)-(fx/fxx);
end
x(10)
% THE RESULT IS = 0.607101648103123
THANKS again , I really need that help ... khalid_boureeny@yahoo.com
Star Strider
Star Strider 2017 年 1 月 27 日
My pleasure.
Declare ‘x’ as as symbolic object, and the result will be symbolic with the precision defined by the digits function:
digits(50);
x= sym(pi);
for i=1:10
fx=cos(x(i))-3*x(i)+1;
fxx=-sin(x(i))-3;
x(i+1)=x(i)-(fx/fxx);
end
x_10 = vpa(x(end))
x_10 =
0.60710164810312263122482837345049072888916774532395

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by