Recently, I have tried to find minima of some functions with FindMinimum
, but those are so flat that the results cannnot be reliable.
So I switched the method to apply FindRoot
on their derivatives. Although it is so fast way, but potentially it has some problems. As you know, FindRoot
depends on initial values severely. Unfortunately, I cannot submit my own .nb
file because it contains data not published yet. Instead I can give a simple example; For
f = 1/x^4 (x^3 - 3 x^2*y + 6 x*y + 3*x*y^2 + y^3)
and g = (x^3 + 3 x^2*y - 6 x*y - 3*x*y^2 + y^3)
,
FindRoot[{f == 0, g == 0}, {{x, 1}, {y, -0.482}},MaxIterations -> 10000, WorkingPrecision -> 100] // AbsoluteTiming
results as
{0.351312, {x -> 0.0123426, y -> -0.0000255474}}
with an error (FindRoot::cvmit).
However if we start this calculation with initial values {{x, 1}, {y, -0.483}}
, we can get a correct answer:
{0.0009858, {x -> 1.00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000, y -> -1.000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000}}
. Only what I did is shifting initial value of y
with 0.001
.
Please look a figure below. The orange line is f
, the blue one is g
evaluated at x=1
respectively.
Actually, there is an extremum at y -> -0.414214
, but it is far from initial point a bit.
Is there any way to deal with this kind of problems with FindRoot
? General solutions are welcomed.
Of course I can use NSolve
, but it often takes very long time compared to FindRoot
, and I need only one solution so I don't want to use it.
findAllRoots
function from here: mathematica.stackexchange.com/questions/16439/… $\endgroup$ – SPPearce Jun 17 '20 at 12:10NSolve
did you include bounds, e.g.,NSolve[{f[x, y] == 0, g[x, y] == 0, -2 < x < 2, -2 < y < 2}, {x, y}, WorkingPrecision -> 100]
? $\endgroup$ – Bob Hanlon Jun 17 '20 at 14:36NSolve
takes so long time even if there are additional conditions. Indeed, I've been advised to useFindRoot
instead ofNSolve
in my past question. $\endgroup$ – Keyspire Jun 17 '20 at 17:17