[next] [prev] [prev-tail] [tail] [up]
Problem: Integrate
\[ \int _{-2}^{2}\frac {1}{5}\left ( \frac {1}{100}\left ( 322+3x\left ( 98+x\left ( 37+x\right ) \right ) \right ) -24\frac {x}{1+x^{2}}\right ) dx \]
The exact answer is \(94/25=3.76\)
Mathematica
f[x_] := (1/5)(1/100(322+3*x(98+x(37+x)))- 24(x/(1+x^2))) r = Integrate[f[x],{x,-2,2}]
Out[15]= 94/25
N[r]
Out[17]= 3.76
To compare with Matlab, replace \(1\) by \(1.0\) in the expression (or use N)
f[x_]:=(1.0/5)(1/100(322+3*x(98+x(37+x)))- 24(x/(1+x^2))) r = Integrate[f[x],{x,-2,2}]; InputForm[r]
Out[62]= 3.7600000000000007
Matlab
clear all; format long f=@(x)(1/5)*(1/100*(322+3*x.*(98+x.*(37+x)))... -24*(x/(1+x.^2))); integral(f,-2,2)
ans = 3.760000000000001
integral(f,-2,2,'AbsTol',1e-6,'RelTol',1e-6)
[next] [prev] [prev-tail] [front] [up]