I am trying to solve for \[Epsilon], given three input paramters n, x and eps. Only FindInstance provides a solution for me whereas NSolve and NSolveValues fail.
Why does this happen?
$PreRead = (# /.
s_String /;
StringMatchQ[s, NumberString] &&
Precision@ToExpression@s == MachinePrecision :> s <> "`50." &);
kldFunc[x_, y_] := x Log[x/y] + (1 - x) Log[(1 - x)/(1 - y)];
n = 10.^13.; x = 6. 10.^9.; eps = 10.^-20.;
Clear[[Epsilon], [Mu], p];
[Mu] = x + n [Epsilon];
p = [Mu]/n;
[Epsilon] = [Epsilon] /.
Flatten[FindInstance[
Exp[-kldFunc[p - [Epsilon], p] n] == eps &&
1. > [Epsilon] > 0., [Epsilon], Reals] ]
Clear[[Epsilon], [Mu], p];
[Mu] = x + n [Epsilon];
p = [Mu]/n;
[Epsilon] =
NSolveValues[
Exp[-kldFunc[p - [Epsilon], p] n] == eps &&
1. > [Epsilon] > 0., [Epsilon], Reals]
Clear[[Epsilon], [Mu], p];
[Mu] = x + n [Epsilon];
p = [Mu]/n;
[Epsilon] =
NSolve[Exp[-kldFunc[p - [Epsilon], p] n] == eps &&
1. > [Epsilon] > 0., [Epsilon], Reals]
EDIT
I tried plotting the two function to find the intersection
$PreRead = (# /.
s_String /;
StringMatchQ[s, NumberString] &&
Precision@ToExpression@s == MachinePrecision :>
s <> "`100." &);
kldFunc[x_, y_] := x Log[x/y] + (1 - x) Log[(1 - x)/(1 - y)];
n = 10.^13.; x = 6. 10.^9.; eps = 10.^-20.;
Clear[[Epsilon], [Mu], p];
[Mu] = x + n [Epsilon];
p = [Mu]/n;
Plot[{10^-20, Exp[-kldFunc[p - [Epsilon], p] n]}, {[Epsilon],
7 10^-8, 8 10^-8}, WorkingPrecision -> 50]
I tried to extract the intersection point using
plot1 = Plot[
Exp[-kldFunc[p - \[Epsilon], p] n], {\[Epsilon], 7 10^-8,
8 10^-8}, WorkingPrecision -> 50];
plot2 = Plot[10^-20, {\[Epsilon], 7 10^-8, 8 10^-8},
WorkingPrecision -> 50];
intersections = GraphicsMeshFindIntersections[{plot2, plot1}]
but it does'nt give an output.(I'm running on 13.3. See related)

NSolve, Details and Options bullet item: "NSolvedeals primarily with linear and polynomial equations.` It has only limited capabilities for handling transcendental equations. – Daniel Lichtblau Sep 26 '23 at 14:51FindInstanceworks most of the time but sometimes it runs for a couple of minutes without being able to find a solution. – Dotman Sep 26 '23 at 15:01E^(1.0...00*10^13 (-((1 +\[Epsilon] - 1.0...00*10^-13 (6.00...0*10^9 + 1.000...000*10^13\[Epsilon])) Log[( 1 + \[Epsilon] - 1.0000..0000*10^-13 (6.0000...00*10^9 + 1.0000...000*10^13 \[Epsilon]))/( 1 - 1.0000..000*10^-13 (6.00...0*10^9 + 1.000...0000*10^13 \[Epsilon]))]) - (-\[Epsilon] + 1.0000..0000*10^-13 (6.0000...0000*10^9 + 1.00...000*10^13 \[Epsilon])) Log[( 1.000...000*10^13 (-\[Epsilon] + 1.0000...0000*10^-13 (6.00...000*10^9 + 1.00...00000*10^13 \[Epsilon])))/( 6.00000...0000*10^9 + 1.000..000000*10^13 \[Epsilon])])) == 1.0..0000000*10^-20. – user64494 Sep 26 '23 at 16:15FindRootwould be my go-to for this. `kldFunc[x_, y_] := x Log[x/y] + (1 - x) Log[(1 - x)/(1 - y)]; n = 10^13; x = 6 *10^9; eps = 10^-20; [Mu] = x + n [Epsilon]; p = [Mu]/n;In[59]:= FindRoot[ N[Exp[-kldFunc[p - [Epsilon], p] n] - eps, 50] == 0, {[Epsilon], 0, 1}, WorkingPrecision -> 30]
Out[59]= {[Epsilon] -> 7.43192053584110156413007451123*10^-8}`
– Daniel Lichtblau Sep 26 '23 at 20:09n = 10^15; x = 6*10^9; eps = 10^-20; \[Mu] = x - n \[Epsilon]; p = \[Mu]/n;, the code failed to converge to a solution. – Dotman Sep 26 '23 at 22:15