I am having trouble with the UnitStep function as in the title. My problem is very simple, but I am not able to get a numerical result.
I have
f1[y] = 1/(E^((-1 + y)^2/2)*Sqrt[2*Pi])
g1[y] = (1.0028877725946312*^6*UnitStep[-7.963235463105154 - y])/
E^((-1 + y)^2/2) + (0.12147136083763578*UnitStep[-7.963235463105154 + y])/
E^((-1 + y)^2/2) +
1.001393070562657*
(0.3484061634773921*Sqrt[E^(-(-1 + y)^2/2)] +
0.3484061634773921*Sqrt[E^(-(1 + y)^2/2)])^2*
(-UnitStep[-7.963235463105154 + y] + UnitStep[7.963235463105154 + y])
and I want to solve the problem
$$N\left[\frac{1}{2}\int_{-\infty}^{\infty}\left(\sqrt{f1[y]}-\sqrt{g1[y]}\right)^2dy\right]$$
However, I did not get any result although I waited for a long time. I can plot $g1$ without any problem as well as $f1$, but I can not calculate the simple integral.
f1[y_] =instead off1[y] =– Thies Heidecke Feb 27 at 20:37f1[y_]:=, but as long as theNIntegrateusesy, that actually doesn't matter. I suspect the real problem is trying to useN[Integrate[...]]instead ofNIntegrate. – Xerxes Feb 27 at 20:39SetandSetDelayedare both fine. But you have a point with theN[Integrate[...]]construct. – Thies Heidecke Feb 27 at 20:41Noutside of an integral, it first tries to evaluate it symbolically and only after it realises it can't (or until it succeeds), it tries numerical. UsingNIntegrateit is done numerically from the start. The symbolic attempt is what takes long – Rojo Feb 27 at 20:46