I compute the little program in matlab
clear; clf;
syms a b
f1 = 96*pi - 16*pi * (log(a)-log(b)+1)
f1_ = subs(f1,[a b],[12 2])
f1_ = vpa(f1_)
f2 = 96*pi - 16*pi*(log(12)-log(2)+1)
with the output
f1 =
f1_ =
f1_ =
f2 = 161.2638
Why the results are different?

댓글 수: 2

Walter Roberson
Walter Roberson 2020년 6월 8일
Ah, sorry, somehow when I formatted your code, the special characters disappeared!! If you could repost that part, that would be good.
When I test, I get
f1_ =
161.26375811875458240605931894947
f2 =
161.263758118755
The first of those has been computed to higher precision.
The first has also been computed in a mode that recognized pi as being the indefinitely precise transcendental number, whereas the second one that was calculated purely numeric was calculated with the 16-digit numeric approximation of pi.

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

 채택된 답변

Christian Muth
Christian Muth 2020년 6월 8일

0 개 추천

With the newest Update R2020a Update 2 the problem is solved. The new output is ok
f1 =
f1_ =
f1_ =
161.26375811875458240605931894947
f2 = 161.2638

댓글 수: 3

Walter Roberson
Walter Roberson 2020년 6월 8일
.. and I do happen to be using Update 2.
Which release was the problem observed with?
The answer must be modified. I found the problem is come, if I give the commend digits(2) sometimes in matlab,see:
clear; clf;
syms a b
digits(2)
f1 = 96*pi - 16*pi * (log(a)-log(b)+1)
f1_ = subs(f1,[a b],[12 2])
f1_ = vpa(f1_)
f2 = 96*pi - 16*pi*(log(12)-log(2)+1)
f3 = 96*sym(pi) - 16*sym(pi)*(log(sym(6)) + 1)
f3 = vpa(f3)
digits(32)
f1 = 96*pi - 16*pi * (log(a)-log(b)+1)
f1_ = subs(f1,[a b],[12 2])
f1_ = vpa(f1_)
f2 = 96*pi - 16*pi*(log(12)-log(2)+1)
f3 = 96*sym(pi) - 16*sym(pi)*(log(sym(6)) + 1)
f3 = vpa(f3)
gives the output
f1 =
f1_ =
f1_ =
160.0
f2 = 161.2638
f3 =
f3 =
160.0
f1 =
f1_ =
f1_ =
161.26375811875458240605931894947
f2 = 161.2638
f3 =
f3 =
161.26375811875458240605931894947
madhan ravi
madhan ravi 2020년 6월 8일
You didn't reply to sir Walter's comment though.

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

추가 답변 (1개)

Christian Muth
Christian Muth 2020년 6월 10일

0 개 추천

why should I give an answer if digit(2) is problem?

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

질문:

2020년 6월 8일

답변:

2020년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by