# Obvious Result Wrong in Matlab

1. Apr 5, 2012

### knowLittle

clf;
clear all;
syms x
%t=linspace(0, pi);
%x=t;

f=@(x) exp(-x).*cos(2*x)

h1=ezplot(f,[ 0, pi]); %plots the function f

f(pi./4)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
My output gives me:

f =

@(x)exp(-x).*cos(2*x)

ans =

2.7918e-017
%%%%%%%%%%%%%%%%%
But, the real answer is 0.

2. Apr 5, 2012

### jhae2.718

Your result is equivalent to zero within the precision of double precision floating point arithmetic.

3. Apr 5, 2012

### knowLittle

Ok. Could you explain me, how to read 2.7918e-017?

4. Apr 5, 2012

### Dickfore

$$2.7918 \times 10^{-17} = 1.000000011_{2} \times 2^{-55}$$

Last edited: Apr 5, 2012
5. Apr 5, 2012

### jhae2.718

It's $2.7918\times10^{-17}$, which is an order of magnitude less than the minimum number representable under double precision, which is of the order 10-16. This value is called the machine epsilon, and you can find it using the MATLAB eps command.

6. Apr 5, 2012

Thank you.

7. Apr 5, 2012

### jhae2.718

If you're interested in floating point arithmetic, most computers conform to the IEEE754 standard.

8. Apr 5, 2012

### knowLittle

Thank you, I'll take a look.