2
$\begingroup$

I'm integrating a positive function f(t) times sin(t) from 0 to pi/5 and get -38.

Actually f is slightly negative for a short time (smallest value ~ -0.0005), but far from enough to explain this. Here is the code for the function:

NormFact[k_, S_] := 
Sqrt[(4 S - 2 k - 1) (4 S - k) (4 S - k + 1) (k + 
  1) (k + 2)/(4*Pi*S)];

xi[k_, j_, S_] := (-1)^j*
 Binomial[k, j]*(4*S - k - 1)!/((j + 2)!*(4*S - k - j - 1)!);

Ofunc[t_, S_, coeffs_] := 
1 - Cos[t/2]^(4*S) + 
coeffs.Table[
 NormFact[k, S]*
  Sum[xi[k, j, S]*Sin[t/2]^(2*j + 2)*Cos[t/2]^(4*S - 2*j - 2), {j,
     0, k}], {k, 0, Length[coeffs] - 1}];

cfs = {-2.6155133, 0.9614036, 0.100279, -0.432464, 
0.39887624, -0.2508507, 0.10555472, -0.0007824, -0.0526054, 
0.0703274, -0.0688152, 0.05138949, -0.03833719, 
0.02062684, -0.0018939, -0.0027808};

And here's the result when I integrate:

In:= Integrate[Ofunc[t, 58.5, cfs]*Sin[t], {t, 0, Pi/5}]
Out:= -38.132 + 0. I

Can anyone see my mistake?

$\endgroup$
  • 2
    $\begingroup$ On v9.0.1, I get 37.8958. What version are you using? Run "ReleaseID" /. ("Kernel" /. SystemInformation["Small"]) $\endgroup$ – rcollyer Aug 8 '13 at 16:27
  • $\begingroup$ Hm! I get 8.0.1.0 (2063990, 2063802). Note: I tried restarting the program and get the same negative answer. $\endgroup$ – jorgen Aug 8 '13 at 16:30
  • 1
    $\begingroup$ I confirmed I get that answer on 8.0.1, but I don't get it on v9. So, it is likely a bug in v8. Although, I haven't tried v8.0.4. My only advice: upgrade. $\endgroup$ – rcollyer Aug 8 '13 at 16:36
  • $\begingroup$ Thanks for advice! Note: it seems to me the answer you get must also be wrong, since the function and sine are both too small on the interval to give 38 (try plotting it) $\endgroup$ – jorgen Aug 8 '13 at 16:37
  • 1
    $\begingroup$ Hmm, I hadn't paid attention to that. NIntegrate gives an answer I'm comfortable with (0.13956), and it works fine on v8.0.1, too. So, I'd use that, especially considering the coefficients in your function have vastly different scales, and may be confusing things. $\endgroup$ – rcollyer Aug 8 '13 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.