Numerical integration

The integral $ \int_{-2}^3 (x^3-x^2-3\arctan(x) + 1) dx$ can be calculated exactly. Its value is $ \frac{115}{12}-9\arctan(3) + \frac{3}{2} \log(2) + 6 \arctan(2) \approx 6.0245344593535$ . However, integrals of the form $ \int_a^b f(x) dx$ can in general not be determined exactly.

There are different commands to approximate an integral numerically. Also refer to the help facilities. We will use the command quad (which is an abbreviation of quadrature) and let the result appear with 15 digits.
>> format long
>> quad('f',-2,3)

ans =
It is not possible to use `f(x)' as the first argument. The approximation already differs from the exact value above after the fifth digit. In principle, quad tries to give the first four decimal points correctly. The precision of the approximation can be improved by using some extra input arguments. Refer to the help facilities to find out the meaning of these extra input arguments.
>> quad('f',-2,3,[10^-7 10^-7])

ans =

Previous      Next      Up      Contents

Esteur 2010-03-22