I have an implicit equation in Mathematica, which I solve by using NSolve. Now, I need to weigh the various solutions according to a Gaussian, but I can’t quite make it work. Here is my suggestion so far:
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}]
However, this does not work. Does anyone know what I am doing wrong? What I want is pretty straightforward, but I’ve had some problems implementing it.
Best,
Niles.
Try this; the main points are to use the third argument to
NSolveto specify the domain and to make sure the functionsol2is called only on a numerical argument.