7

Is the solution set returned by NSolve usually complete? Can I assume that there are no more solutions than what it returns? Consider systems of equations e.g. like this one.

I expect that the answer is either generally "no" or that it depends on the type of equations (polynomial? exact coefficients?), on the method being used, and on other settings (such as VerifySolutions). So the better question is: in which cases (if any) can I assume that NSolve found all solutions?

It is clear that the solution values are approximate but it is not clear that the number of solutions is also approximate. Multiple roots are generally returned with the correct multiplicity.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
  • 3
    Here's a relatively innocuous case where it fails: NSolve[Product[1.1^n x - 1., {n, 20}] == 0 && 0 < x < 1, x] // Length. I don't know how to predict that it would fail.... – Michael E2 Oct 26 '16 at 10:48
  • @MichaelE2 Not only NSolve, but also Solve fails for this. It's strange that after removing the constraint of 0 < x < 1 it works. With exact coefficients it also works. – Szabolcs Oct 26 '16 at 11:12
  • @MichaelE2 NRoots also works with all three documented methods. Maybe the constraint triggers a switch to a different method? Somehow this really feels like a bug but then I am not familiar with the numerical intricacies of finding polynomial roots and the coefficients do span 10 orders of magnitude. – Szabolcs Oct 26 '16 at 11:15
  • Another example is ClearAll; NSolve[Sin[1/(x + 10^(-5))] == 0 && x > 0 && x < 1, x] // Length – user64494 Oct 26 '16 at 11:32
  • @user64494 OK, it's clear enough that there are many examples when it fails. I wonder if there are any cases when we can trust it, e.g. polynomial with exact coefficients and no inequalities. Or things like Sqrt[x] == 2 which is not exactly polynomial but clearly related as its solutions are a subset of the solutions of x == 2^2. (Not sure what these are called). With a single polynomial equation the number of roots is clear. I don't know about a system or cases like the $\sqrt{x} = 2$ above. – Szabolcs Oct 26 '16 at 11:36
  • 2
    @user64494 There are internal constraints that limit the number of solutions found. This gets them all: SetSystemOptions["ReduceOptions" -> {"IntervalRootsOptions" -> {"MaxIncomplete" -> 35000, "MaxSteps" -> 150000}}]; NSolve[Sin[1/(x + 10^(-5))] == 0 && x > 0 && x < 1, x] // Length. – Michael E2 Oct 26 '16 at 12:33
  • @ Micael E2: Thank you. Now I know more. However, one may decrease 10^(-5) to 10^(-20). In general, the total number of solutions is apriori unknown. – user64494 Oct 26 '16 at 12:42
  • @Szabolcs I would have thought NSolve would be reliable on polynomials up to precision constraints. Perhaps it is on unbounded problems. I would also have thought NSolve would be reliable on the roots of transcendental functions over a compact domain, provided the function is analytic in a sufficiently large complex neighborhood of the domain and working precision is sufficiently high. My example, which is similar to Wilkinson's second polynomial, rather undermines my assumptions. – Michael E2 Oct 26 '16 at 12:45
  • 1
    @user64494 My point is simply that there are such limits that are programmed and not numerical limitations of the algorithms. However, when you get exactly 1000 solutions, you might wonder if you hit the limit and try increasing it. The other limits are harder to detect. It does not appear there is a way to get NSolve to tell you when it's run into such a limit, which is too bad. -- A site tip: if you don't put a space between the @ and my name, I'll get notified of your reply. – Michael E2 Oct 26 '16 at 12:59
  • There might be version dependence, too. In the comments and answers to this question, NSolvefound all answers in an interval in v10.0 but not in v10.4. Now, granted, NSolve is not designed to solve transcendental equations, but the version-dependence is still a little strange. – march Oct 26 '16 at 18:24

0 Answers0