Michael Sazonov
Michael Sazonov

Reputation: 1533

Misunderstanding the integration of MATLAB

everybody!

Could you, guys, please explain why the answer for the exact integration

quad( @(x)x.^3-2.*x,0,2)

is

-2.220446049250313e-016

istead of a zero, just like it should be?

Upvotes: 0

Views: 112

Answers (1)

Jeffrey Sax
Jeffrey Sax

Reputation: 10323

The quad function computes the integral numerically, not symbolically.

Even though most integration methods will compute the integral of a 3rd degree polynomial 'exactly' , that is only true if all the calculations are done exactly as well. When doing the calculation on a computer, round-off error still is a factor.

Upvotes: 2

Related Questions