필터 지우기
필터 지우기

exp(log(x))-x?

조회 수: 3 (최근 30일)
Hoon
Hoon 2016년 4월 22일
답변: John D'Errico 2016년 4월 22일
Analytically, exp(log(x))-x should give zero.
But In matlab, it is not zero
x=linspace(1,10,10);
exp(log(x))-x;
for x=1 to 10, the answer is
0
0
-4.44089209850063e-16
0
0
0
0
-1.77635683940025e-15
1.77635683940025e-15
1.77635683940025e-15
what is happening?
and how can I fix this?
  댓글 수: 1
Adam
Adam 2016년 4월 22일
It is 0 to within a certain precision. The results of mathematical operations involving doubles rarely produce the exact results due to the precision of the representation.
Why do you need to "fix it"? In what context are you using it?

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

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 22일

John D'Errico
John D'Errico 2016년 4월 22일
You cannot "fix" it, not as long as you work with numbers represented in floating point arithmetic. Floating point arithmetic is not mathematics. The two look a lot alike, but they are not the same.
The only fix available is in your mind, learning what you can and cannot do. Of course, if you are willing to always work in symbolic form, then you can resolve this. Your code will be painfully slow then.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by