I want to solve the following integral equations for $m$ and $q$, with parameters $J_0$ and $T$: $$q(J_0,T)=\int_{-\infty}^{\infty} \frac{1}{2\pi}e^{-\frac{z^2}{2}}\,\mbox{tanh}^2\left(\frac{z\sqrt{q(J_0,T)}+J_0 m(J_0,T)}{T}\right) dz$$
$$m(J_0,T)=\int_{-\infty}^{\infty} \frac{1}{2\pi}e^{-\frac{z^2}{2}}\,\mbox{tanh}\left(\frac{z\sqrt{q(J_0,T)}+J_0 m(J_0,T)}{T}\right) dz$$
There is a way to solve them using FindRoot, but the computation time is very large, so I need an alternative. What I wanted to use is NSolve which can solve equations for multiple variables at the same time. I tried with the following code:
precision = 100;
Maxit = 500;
accuracy = Round[precision/2];
NSolve[{
q == NIntegrate[
1/Sqrt[2 Pi] Exp[-z^2/2] Tanh[SetPrecision[(Sqrt[q] z + 0.5 m)/0.5, precision + 1]]^2,
{z, -Infinity, Infinity},
WorkingPrecision -> precision,
AccuracyGoal -> accuracy],
m == NIntegrate[
1/Sqrt[2 Pi] Exp[-z^2/2] Tanh[SetPrecision[(Sqrt[q] z + 0.5 m)/0.5, precision + 1]],
{z, -Infinity, Infinity},
WorkingPrecision -> precision, AccuracyGoal -> accuracy] },
{q, m}]
but it seems that NSolve cannot use NIntegrate since it doesn't give any result. Can someone help me?
FindRoot
can solve for multiple variables at the same time. (2)NSolve
is not designed to solve such problems as this. (3) Why not code theTanh[]
factor asTanh[2 (Sqrt[q] z + m/2)]
? (It won't solve the root problem, but it makes the code easier to manage, imho.) $\endgroup$FindRoot
which in my view is problematic as the routine may not converge to the desired root depending on what basin the seed is in. However, if instead you used the values of that algorithm as seeds to a second iteration ofFindRoot
then the convergence problem is greatly reduced. $\endgroup$