1
$\begingroup$

A quick check for the options of NSolve yields:

 Options[NSolve]
 {Method -> Automatic, RandomSeed -> 0, 
  VerifySolutions -> Automatic, WorkingPrecision -> Automatic}

Does anyone know what VerifySolutions -> Automatic means in this case? Automatic to me usually means 'make reasonable guess', as in PlotRange -> Automatic, but I don't know what Mathematica thinks is reasonable, and I don't know how to dig any deeper into the underlying code in Mathematica.

I should add that I know how to verify solutions by hand by feeding them back into the original equations. I also know that I can force the option by setting VerifySolutions -> True. I have found that this typically takes a bit longer for the equations I am solving which makes me think Automatic means False in my case. But in either case, I am none-the-less still curious about my original question.

$\endgroup$
5
  • $\begingroup$ Have you looked at the documentation for VerifySolutions? $\endgroup$ Commented Nov 9, 2017 at 15:17
  • $\begingroup$ @ J.M. I did... it says automatic means it 'automatically determine whether to verify'...which seems a bit tautological unless I am missing something... $\endgroup$
    – DJBunk
    Commented Nov 9, 2017 at 15:31
  • $\begingroup$ The docs for NSolve[] also give a short demo. $\endgroup$ Commented Nov 9, 2017 at 15:34
  • $\begingroup$ @ J.M. I saw that too. It says 'NSolve verifies solutions obtained using non-equivalent transformations...' I wasn't sure if I should interpret that as 'NSolve will verify under certain unstated conditions ' or 'NSolve will always verify under any conditions '. I suppose I could restate my question as, 'if NSolve always verifies the solutions, why isn't VerifySolutions->True the default? $\endgroup$
    – DJBunk
    Commented Nov 9, 2017 at 15:51
  • 2
    $\begingroup$ Typical cases that get the attention of the verifier include presence of denominators or radicals in the original equations. $\endgroup$ Commented Nov 9, 2017 at 16:08

1 Answer 1

2
$\begingroup$

From the documentation of VerifySolutions:

VerifySolutions controls whether the solutions obtained using non-equivalent transformations or numerical methods should be verified.

One example of a non-equivalent transformation is when inverse functions are being used. Here is an example. First the default case with VerifySolutions->Automatic:

TracePrint[
    NSolve[Sin[x] == .5, x],
    Sin[_Real],
    TraceInternal->True
]

Sin[0.52359877559830]

NSolve::ifun: Inverse functions are being used by NSolve, so some solutions may not be found; use Reduce for complete solution information.

{{x -> 0.523599}}

Now, repeat with VerifySolutions->False:

TracePrint[
    NSolve[Sin[x] == .5, x, VerifySolutions->False],
    Sin[_Real],
    TraceInternal->True
]

NSolve::ifun: Inverse functions are being used by NSolve, so some solutions may not be found; use Reduce for complete solution information.

{{x -> 0.523599}}

Notice that this time the solution isn't verified (i.e., this time Sin[0.52359877559830] is not evaluated to check whether it's zero).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.