# Numerical vs Symbolic Integration: Loss of precision

I am trying to integrate the following expression over the time interval $0\leq t \leq \text{period}$.

(Cl - Cn)/Cl*(b Sin[2 Pi/peroid*t] f[t] - 2 (wl/peroid) Pi^2 b^2/wl^2)


where

f[t_] := ((Cl - Cn)^2/Cl 2 Pi^2 b^2/wl - Cn wl) b (wl/peroid)
Sin[2 Pi (wl/peroid)*t/wl]/((Cl - Cn)^2/Cl*b^2*
wl*(Sin[2*Pi*(wl/peroid)*t/wl]^2) + (Cn - Cl) wl b^2/2*
Cos[4 Pi (wl/peroid) t/wl] - Cl b^2 wl/2 - Cn wl^3/12)


$Cl, Cn, b, period, wl$ are all parameters and $t$ is the only variable.

I tried to perform the integration symbolically and Mathematica gave me the following result:

-(((Cl - Cn) (2 b^2 (Cl - Cn) \[Pi]^2 + Cn wl^2))/((2 Cl^2 - 3 Cl Cn + Cn^2) wl))


To further verify that this symbolical expression is correct, I performed the above integration again but numerically with both Mathematica and Matlab with the following parameter values:

Cn = 0.001903418147340
Cl = 8.265172296997836/10000
b = 10/1000000
wl = 1000/1000000
peroid = 0.5


and I also evaluated the symbolic expression with the above set of values. The numerical integration performed by Mathematica and Matlab agrees with each other. However, both numerical integration performed by Mathematica and Matlab are 4 orders of magnitude different from the result obtained by evaluating the symbolic expression with the same set of parameter values. There's something going on, but I don't know what. Any suggestions ?

So far, I have checked that the function that I want to evaluate is smooth.

Any suggestions are greatly appreciated.

-
Welcome to Mathematica.SE! Please take a moment to format your post for readability. Use code blocks. You'll find formatting help on the right of the edit box or by pressing the (?) button. – Szabolcs Jun 5 '14 at 0:07
I don't do anything special and I get the same result for both methods. – Mahdi Jun 5 '14 at 3:50

ClearAll["Global*"];

f[t_] := ((Cl - Cn)^2/Cl 2 Pi^2 b^2/wl - Cn wl) b (wl/peroid)
Sin[2 Pi (wl/peroid)*
t/wl]/((Cl - Cn)^2/Cl*b^2*
wl*(Sin[2*Pi*(wl/peroid)*t/wl]^2) + (Cn - Cl) wl b^2/2*
Cos[4 Pi (wl/peroid) t/wl] - Cl b^2 wl/2 - Cn wl^3/12);

eq = (Cl - Cn)/
Cl*(b Sin[2 Pi/peroid*t] f[t] - 2 (wl/peroid) Pi^2 b^2/wl^2);

Integrate[eq, {t, 0, peroid}]

% /. {b -> 10/1000000, Cn -> 0.001903418147340,
Cl -> 8.265172296997836/10000, wl -> 1000/1000000}

Block[{Cn = 0.001903418147340, Cl = 8.265172296997836/10000,
b = 10/1000000, wl = 1000/1000000, peroid = 0.5},
NIntegrate[eq, {t, 0, peroid}]]

%% - %

(*
-((2 b^2 (Cl - Cn) π^2)/(Cl wl))
2.5719*10^-6
2.5719*10^-6
-2.96462*10^-21
*)
`
-