Message Boards Message Boards

Get an accurate answer by using the ''NIntegrate''?

Posted 6 years ago

The Mathematica codes

The function contains an Error function.

Theoretically, M should be infinity. But the function is almost 0 at t<-M and t>M. So I choose to calculate it in the interval [-M,M].

I have tried M=50; M=100; and M=200, then the Mathematica gave different answers. I don't know how to get an accurate answer.

Thanks very much for any comments.

POSTED BY: zy dong
4 Replies
Posted 6 years ago

If choose the interval of k to be [0,1], we will get the maximum value.

POSTED BY: zy dong
Remove["Global`*"]; ClearAll["Global`*"];

? = 1;
?[t_] := (?^2/(2 Pi))^(1/4)*Exp[-?^2/4*(t^2)];
?[t_, ?_] := ?[t] - ?*(?^2/(2 Pi))^(1/4)*((E^((? (? - 2 t ?^2))/(4 ?^2)) Sqrt[?]*Erfc[(? - t ?^2)/(2 ?)])/?);

tbar[?_?NumericQ] := NIntegrate[t*(?[t, ?]^2), {t, -Infinity, Infinity}]/NIntegrate[?[t, ?]^2, {t, -Infinity, Infinity}];
tsquare[?_?NumericQ] := NIntegrate[(t^2)*(?[t, ?]^2), {t, -Infinity, Infinity}]/NIntegrate[?[t, ?]^2, {t, -Infinity, Infinity}];
?t[?_?NumericQ] := Sqrt[tsquare[?] - tbar[?]^2];

Plot[?t[?], {?, 0, 2}, PlotRange -> {Automatic, {0, 10}}] // Quiet

enter image description here

I don't see any maximum ?

FindMaximum[?t[?]*(?/2), {?, 1/10}] (* ??? *)
POSTED BY: Mariusz Iwaniuk
Posted 6 years ago

Sorry for the inconvenience, the codes has been copied as follows, thanks for your reply.

Remove["Global`*"]
M = 100;
\[CapitalOmega] = 1;
\[Xi][t_] := (\[CapitalOmega]^2/(2 Pi))^(1/4)*
   Exp[-\[CapitalOmega]^2/4*(t^2)];
\[Eta][t_] := \[Xi][t] - \[Kappa]*(\[CapitalOmega]^2/(2 Pi))^(1/4)*\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(-\[Infinity]\), \(t\)]\(Exp[
\*FractionBox[\(-\[Kappa]\), \(2\)] \((t - r)\)]*Exp[
\*FractionBox[\(-\[CapitalOmega]^2\), \(4\)]*\((r^2)\)] \
\[DifferentialD]r\)\);
tbar = Simplify[NIntegrate[t*(\[Eta][t]^2), {t, -M, M}]/
   NIntegrate[\[Eta][t]^2, {t, -M, M}]];
tsquare = 
  Simplify[NIntegrate[(t^2)*(\[Eta][t]^2), {t, -M, M}]/
   NIntegrate[\[Eta][t]^2, {t, -M, M}]];
\[CapitalDelta]t = Sqrt[tsquare - (tbar)^2];
FindMaximum[\[CapitalDelta]t*(\[CapitalOmega]/2), {\[Kappa], 0, 0.1}]
POSTED BY: zy dong

People here generally like users to post code as Mathematica code instead of images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you.

POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract