Message Boards Message Boards

GROUPS:

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

Posted 6 months ago
611 Views
|
4 Replies
|
1 Total Likes
|

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.

4 Replies

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 6 months 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}]
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 6 months ago

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

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