Obvious Result Wrong in Matlab - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Obvious Result Wrong in Matlab

quigonjinn23quigonjinn23 Posts: 2Member
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.

I'm clueless. Please, help.


Comments

  • cdigcdig Posts: 11Member
    2.7918e-017 means 2.7918 x 10^-17

    In practical terms 2.7918e-017 = 0

    You'll find small inaccuracies in computers very often.

Sign In or Register to comment.