level 1
单变量积分代码如下:
xt = 3.7; yt = 1.3;
a = 0.5; b = 1; M = 50; pr = 20;
tt[\[Alpha]_] :=
Exp[-(\[Alpha]^2/4)] Exp[I (\[Alpha] xt + Sqrt[1 - \[Alpha]^2] yt)]
GaussQ1[f_, {x_, a_, b_}, n_Integer: 10, prec_: MachinePrecision] :=
Module[{nodes, weights}, {nodes, weights} =
Most[NIntegrate`GaussRuleData[n, prec]];
(b - a) weights.Map[Function[x, f], Rescale[nodes, {0, 1}, {a, b}]]]
GaussQ1[tt[x], {x, a, b}, M, pr]
NIntegrate[tt[x], {x, a, b}]
可以验证二者是相等的
2018年04月23日 03点04分