Skip to main content

equation solving - Backslide in NSolve in V11.1?


Bug introduced in 11.1.0 and persisting through 11.1.1





In V11.1,


NSolve[BesselJ[0, x] == 0 && 0 < x < 20, x]

returns no solutions:


Mathematica graphics


But in V11.0 (and earlier), it returns all solutions:


Mathematica graphics


Is there anyway to get NSolve to solve this equation in V11.1?


(Interestingly, Solve[BesselJ[0, x] == 0 && 0 < x < 20, x] works in both, but I was particularly interested NSolve, since I was wanting to compare it with other numerical methods.)



Answer




It is a bug in V11.1. As a workaround, you can put the following in your init.m file.


Reduce`RealTNRoots;
nonElementaryQ[f_] := Module[{x}, !ListQ[Simplify`FunctionSingularities[f[x], x, "ELEM"]]]
System`TRootsDump`NIntervalRoots[f_?nonElementaryQ, ii_, prec_] := $Failed

This will disable the offending code for non-elementary functions.


In[4]:= NSolve[BesselJ[0, x] == 0 && 0 < x < 20, x]
Out[4]= {{x -> 2.40483}, {x -> 5.52008}, {x -> 8.65373}, {x -> 11.7915},
> {x -> 14.9309}, {x -> 18.0711}}

Comments