Why isn't sum of logs == log of product?

4 views (last 30 days)
James Mooney
James Mooney on 3 May 2022
Answered: Image Analyst on 3 May 2022
Why am I getting false for this when the answers are equal?
>> log(3) + log(4) == log(3*4)
ans =
logical
0
>> log(3) + log(4)
ans =
2.4849
>> log(3*4)
ans =
2.4849

Answers (2)

Image Analyst
Image Analyst on 3 May 2022

the cyclist
the cyclist on 3 May 2022
Edited: the cyclist on 3 May 2022
They are equal to within double precision:
log(3) + log(4) - log(3*4)
ans = -4.4409e-16
There are many places on this forum that discuss this in more detail, e.g. this question/answer.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!