I am getting this really weird error when using NIntegrate. I am trying to integrate the composition of these two functions

Temp[t_] := 285. - 15.*Sin[2*Pi*t/365.];
bT[Tmp_] := 5.0*Exp[-(Tmp - 290.)^2/(2*7.^2)];
Plot[bT[Temp[t]], {t, 0, 365.}]

enter image description here

This is a highly non-linear function but when trying to integrate with NIntegrate I get a linear function

tt[t_?NumericQ] := NIntegrate[bT[Temp[s]], {s, 0, t}];
Plot[tt[t], {t, 0, 365.}]

enter image description here

This sounds like it is some stupid mistake, but I can't for the life of me figure out what I am doing wrong. Can anyone help me find out what I am doing wrong?

  • 5
    $\begingroup$ I cannot reproduce the problem. Maybe there is a hanging definition. Please try to restart the kernel with Exit[] and try the computations again. $\endgroup$ – Henrik Schumacher Nov 26 '18 at 21:50
  • $\begingroup$ Consider Plot[tt[t], {t, 50, 120.}]. $\endgroup$ – user64494 Nov 27 '18 at 4:22
  • $\begingroup$ @HenrikSchumacher using Exit[] worked like a charm! I am just confused as I was already using ClearAll["Global`*"]. Doesn't it also clear the hanging definitions? $\endgroup$ – Guilherme Casas Gonçalves Nov 27 '18 at 23:24
  • 1
    $\begingroup$ Hm. ClearAll["Global*"]` clears only symbols in the global context. Usually, that should suffice. But sometimes, it is better to "turn it off and on again". ("It" is Mathematica's kernel in this cases.) $\endgroup$ – Henrik Schumacher Nov 28 '18 at 6:09

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.