我研究了Mathematica.StackExchange上的所有主题(例如大多数"着名"主题是https://mathematica.stackexchange.com/questions/23854/how-to-speed-up-the-plot-of-nintegrate),但我的例子比较复杂,所提议的方法都没有。工作。我的最小例子如下。
我首先解决一个等式:
eqn = j - Sqrt[q^2 + qp^2 - 2*q*qp*Cos[\[Theta]]] -
Sqrt[qp^2 + (1/2)*(16*m5^2 + ma^2 + mp^2 -
Sqrt[(-(16*m5^2) - ma^2 - mp^2)^2 -
4*(ma^2*mp^2 - 16*m5^2*qp^2)])] == 0;
With[{gensol = Solve[eqn, qp]},
Block[{m = 5.5, M = 300, Nc = 3,
c = ScientificForm[-44687.3983417778],
b = ScientificForm[161593.81818181818],
k1 = ScientificForm[16.485010961790245],
k2 = ScientificForm[-13.131344420001051], ma, mp, j},
{j = Sqrt[q^2 + (1/2)*(16*m5^2 + ma^2 + mp^2 +
Sqrt[(-(16*m5^2) - ma^2 - mp^2)^2 -
4*(ma^2*mp^2 - 16*m5^2*q^2)])],
ma = Sqrt[-2*(M^2 - 2*(3*k1 + k2)*
(Sqrt[(c + M^2 + 2*m5^2)/(2*(k1 + k2))] +
m*(b/(2*(c + M^2 + 2*m5^2))))^2 - c +
2*m5^2)], mp = Sqrt[(2*b*m)/
(Sqrt[(c + M^2 + 2*m5^2)/(2*(k1 + k2))] +
m*(b/(2*(c + M^2 + 2*m5^2))))]};
sols = gensol]];
qpC12 = Compile[{{q, _Complex}, {m5, _Complex},
{\[Theta], _Complex}}, Evaluate[qp /. sols[[2]]],
RuntimeOptions -> "EvaluateSymbolically" -> False];
qp32 = Re[qpC12[q, m5, \[Theta]]];
然后我做NIntegrate:
qqq[(q_)?NumericQ, (m5_)?NumericQ] :=
NIntegrate[(q^2*qp32^2*Sin[\[Theta]]^2)/((2*(2*Pi)^2)*
Sqrt[-(2*q*Cos[\[Theta]]*qp32) + qp32^2 + q^2]),
{\[Theta], 0, Pi/2}];
并密谋:
Plot3D[qqq[q, m5], {q, 0.8, 150}, {m5, 0, 150}]
米 这需要大约80秒,对我来说这是一个大问题,因为当我使用更复杂的功能时,Mathematica解决了大约3个小时。