1
$\begingroup$

Some functions (such as Erf) appear to use NIntegrate internally. In such cases, is there a way to control such options of NIntegrate as PrecisionGoal and AccuracyGoal?

Edit in response to the comment by J.M.: I did use such a command for numerical evaluation. The function of interest was f[x_] = (x/((2 + x^2) Sqrt[1 + x^2]))InverseFunction[Erf][ArcTan[1/Sqrt[1 + x^2]] ]. A calculation involving the values of f[x] and some of its derivatives of order <=24 at x about 3.5 10^9 produced this message:

NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in i near {i} = {150.979}. NIntegrate obtained 0.0019560456659259958and 7.756174544177548*^-8 for the integral and error estimates.

I thought that message probably concerned the function Erf, which is defined as a certain integral. If not Erf, it must then be ArcTan that triggered the NIntegrate::ncvb: message.

In any case, the essence of my question was as follows: Some built-in functions appear to use NIntegrate internally. In such cases, is there a way to control such options of NIntegrate as PrecisionGoal and AccuracyGoal?

$\endgroup$
6
  • 3
    $\begingroup$ No, Erf[] does not use NIntegrate[]. Just do N[Erf[z], {prec, acc}] if you must. $\endgroup$ Commented Apr 2, 2017 at 16:26
  • 2
    $\begingroup$ Solving sometimes uses NIntegrate. Consider the message Solve::nint. My guess is that it's InverseFunction. Without code to reproduce the error, it might be impossible to say definitively. I'm up to something like the 20th derivative of f[x] and still no errors. $\endgroup$
    – Michael E2
    Commented Apr 2, 2017 at 21:19
  • 1
    $\begingroup$ SetOptions is the standard way. Sometimes they are set explicitly by the built-in function, and unfortunately you might not have a way to change it. Two examples in which I overrode behavior: mathematica.stackexchange.com/a/63676/4999, mathematica.stackexchange.com/a/120650/4999. A case where I failed, because the option setting is hard-coded internally: mathematica.stackexchange.com/a/95106/4999 $\endgroup$
    – Michael E2
    Commented Apr 2, 2017 at 21:25
  • $\begingroup$ @MichaelE2 : Thank you for your helpful comments. The entire code is, alas, too long to be reproduced here. In the first of the two examples you refer to, you knew that Reduce is an allowable value for Method ->. In general, is there a way to get the list of all such values for a given option? (Trying to learn more from you.) $\endgroup$ Commented Apr 2, 2017 at 21:40
  • 1
    $\begingroup$ For documented options & settings (such as Reduce), check the "Details and Options" section, as well as the "Options" subsection of the "Examples", in the documentation for the function (such as Solve). For undocumented options & settings, some are listed here. $\endgroup$
    – Michael E2
    Commented Apr 2, 2017 at 21:50

0

Your Answer

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