# NSolve for complicated non-linear equation

I want to solve a nonlinear equation involving the Real part and imaginary part of the Exponentialintegralfunction, i.e. $\mathcal{R}[\text{Ei}[a(1+ib)]]$ and some other complicated terms. As it is not possible to solve my problem analytically, I wanted to use NSolve...but it doesnt work. The thing is: If i look at my plot, the solution is very evident. How can i solve this problem?

The explicit form i want to solve is

 E^(t (0.001998 Im[ExpIntegralEi[0.001 (1 + I t)]] + (
2 (t Cos[0.001 t] - Sin[0.001 t]))/(1 + t^2)) +
2000. (-1 + (Cos[0.001 t] + t Sin[0.001 t])/(1 + t^2)) -
999. (-2.01265 - 0.001998 Re[ExpIntegralEi[0.001 (1 + I t)]] + (
2 (Cos[0.001 t] + t Sin[0.001 t]))/(
1 + t^2))) (-E^(-t (0.001998 Im[
ExpIntegralEi[0.001 (1 + I t)]] + (
2 (t Cos[0.001 t] - Sin[0.001 t]))/(1 + t^2)) -
2000. (-1 + (Cos[0.001 t] + t Sin[0.001 t])/(1 + t^2)) +
999. (-2.01265 - 0.001998 Re[ExpIntegralEi[0.001 (1 + I t)]] + (
2 (Cos[0.001 t] + t Sin[0.001 t]))/(1 + t^2))) + 1/(1 + t^2))==0.2


Just an example...of course i want to use some different values. I can plot the r.h.s. and 'see' my result;

edit: Here is the actual command that gives me { } as solution

    NSolve[{E^(t (0.001998 Im[
ExpIntegralEi[
0.001 (1 + I t)]] + (2 (t Cos[0.001 t] -
Sin[0.001 t]))/(1 + t^2)) +
2000. (-1 + (Cos[0.001 t] + t Sin[0.001 t])/(1 + t^2)) -
999. (-2.01265 -
0.001998 Re[
ExpIntegralEi[
0.001 (1 + I t)]] + (2 (Cos[0.001 t] +
t Sin[0.001 t]))/(1 +
t^2))) (-E^(-t (0.001998 Im[
ExpIntegralEi[
0.001 (1 + I t)]] + (2 (t Cos[0.001 t] -
Sin[0.001 t]))/(1 + t^2)) -
2000. (-1 + (Cos[0.001 t] + t Sin[0.001 t])/(1 + t^2)) +
999. (-2.01265 -
0.001998 Re[
ExpIntegralEi[
0.001 (1 + I t)]] + (2 (Cos[0.001 t] +
t Sin[0.001 t]))/(1 + t^2))) + 1/(1 + t^2)) ==
0.2 && 0 < t < 50 }, t]


The Plot suggest that the solution lies at about $t\approx 30$ Thanks already!

• There is no root in-between 0 and 50 (the roots is around 62, see my answer). – anderstood Feb 21 '18 at 15:23

## 1 Answer

Your equation is not very complicated for a numerical problem. Try:

f[t_?NumericQ] :=
E^(t (0.001998 Im[ExpIntegralEi[0.001 (1 + I t)]] + (
2 (t Cos[0.001 t] - Sin[0.001 t]))/(1 + t^2)) +
2000. (-1 + (Cos[0.001 t] + t Sin[0.001 t])/(1 + t^2)) -
999. (-2.01265 - 0.001998 Re[ExpIntegralEi[0.001 (1 + I t)]] + (
2 (Cos[0.001 t] + t Sin[0.001 t]))/(
1 + t^2))) (-E^(-t (0.001998 Im[
ExpIntegralEi[0.001 (1 + I t)]] + (
2 (t Cos[0.001 t] - Sin[0.001 t]))/(1 + t^2)) -
2000. (-1 + (Cos[0.001 t] + t Sin[0.001 t])/(1 + t^2)) +
999. (-2.01265 - 0.001998 Re[ExpIntegralEi[0.001 (1 + I t)]] + (
2 (Cos[0.001 t] + t Sin[0.001 t]))/(1 + t^2))) + 1/(1 + t^2))-0.2

FindRoot[f[t], {t, 50}] // AbsoluteTiming
(* {0.003991, {t -> 62.2356}} *)


It also has another root at approx. -62.2356, since f is even (I think---haven't proven it).

• Thanks! Why does this work but not Nsolve? – Martin Feb 21 '18 at 14:53
• @Martin NSolve and FindRoot are different functions; FindRoot finds one root for an initial point (using e.g. Newton-Raphson) but NSolve try to find all roots, which is much more difficult. But I don't know specifically why NSolve returns an error, I guess it would be because f has complex terms. You could try simplifying f use only real terms and see if it works. – anderstood Feb 21 '18 at 14:57
• Thanks for the answer! Simplifying to only real terms doesn't work, as there is no expression for Im[Ei[a+bi]]. But it thanks, you solved my problem! – Martin Feb 21 '18 at 15:32
• @Martin Well, there is, but it is not elementary :) functions.wolfram.com/GammaBetaErf/ExpIntegralEi/19/02 – anderstood Feb 21 '18 at 15:35