필터 지우기
필터 지우기

Between ei(vpa(5)) and vpa (ei(5) ) which command would provide a higher precision for the integral ei(5) ?

조회 수: 1 (최근 30일)
Between ei( vpa(5) ) and vpa( ei(5) ) which command would provide a higher precision for the integral ei(5) ?

채택된 답변

John D'Errico
John D'Errico 2020년 11월 16일
편집: John D'Errico 2020년 11월 16일
Is this a homework assignment? My spidey sense is tingling. However, a quick glance at your other questions suggests you are hopefully past that point. But then you should understand how to know the answer. In any case, think about how MATLAB works. What does the first case do?
ei(vpa(5))
ans =
40.185275355803177455091421793796
This converts the number 5, to a high precision symbolic representatino of the number 5. Then it calls the symbolic version of ei.
Instead, what does the latter case do? It first computes
ei(5)
ans =
40.1852753558032
It uses the DOUBLE PRECISION version of ei. And then passes that result directly to vpa.
vpa(ei(5))
ans =
40.185275355803177887992205796763
And while they look the same to 16 digits or so, after that point, the second case is the one that is in error. The first one used the symbolic version of ei to compute the result to high precision.
Remember that in the second case MATLAB does not know that eventually, it will want a symbolic result. So you get a result that is accurate in DOUBLE PRECISION. And THEN it passes the result to vpa. This is how all function calls in MATLAB work. They don't look beyond that point to know what will be done with the result. MATLAB computes the result from the inside call, and only then does it worry about the next step.
  댓글 수: 1
Tuong Nguyen Minh
Tuong Nguyen Minh 2020년 11월 16일
Haha thank you, this is not a homework assignments. Actually, I do not understand the way symbolic calculation work so I really appreciate your careful and detail answer

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

추가 답변 (0개)

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by