1

我在 Mathematica 中有一个隐式方程,我使用 NSolve 求解。现在,我需要根据高斯权衡各种解决方案,但我不能让它发挥作用。到目前为止,这是我的建议:

a = (4.2*10^(-5));
b = 4067;
c = 112;
sol[d_] := Select[NSolve[s == (1 + a^2*(2*Pi*1000*d)^2)/((1 + c/(1 + (s*b)/(1 + a^2*(2*Pi*1000*d)^2)))^2 + a^2*(2*Pi*1000*d)^2), {s}], Chop[(Im[s] /. #)] == 0 &][[1]][[1]][[2]];

NIntegrate[Exp[-v^2]*sol[v], {v, -2, 2}]

但是,这不起作用。有谁知道我做错了什么?我想要的非常简单,但我在实现它时遇到了一些问题。

最好的,奈尔斯。

4

1 回答 1

3

试试这个; 要点是使用第三个参数来NSolve指定域并确保sol2仅在数字参数上调用函数。

sol2[d_?NumericQ] := NSolve[s == (1 + 
     a^2*(2*Pi*1000*d)^2)/((1 + 
        c/(1 + (s*b)/(1 + a^2*(2*Pi*1000*d)^2)))^2 + 
     a^2*(2*Pi*1000*d)^2), {s}, Reals][[1]][[1]][[2]]

NIntegrate[Exp[-v^2]*sol2[v], {v, -2, 2}]
(* 1.66556 *)


Plot[Exp[-v^2]*sol2[v], {v, -2, 2}]

阴谋

于 2012-12-15T14:05:39.437 回答