I know that Mathematica has great built-in precision tracking, so when you do calculations with arbitrary-precision numbers, Mathematica keeps track of the precision on the result. Given this careful attention to numerical error and precision tracking, I am surprised that, say
InputForm[NIntegrate[E^(-x^2), {x, 0, Infinity},PrecisionGoal -> 20, WorkingPrecision -> 100]]
returns a number with precision 100, not 20. I know Mathematica is using precision-100 numbers in its numerical calculations for NIntegrate, but the function is built to return a number whose actual precision is at least 20. In the spirit of useful precision tracking, wouldn't it make more sense for NIntegrate to return a number with a precision of PrecisionGoal, not WorkingPrecision?
This question is more about numerical coding philosophy than about how NIntegrate works. But this is important as Wolfram presumably makes these decisions with use cases in mind, so I want to know if I'm missing something.
EDIT:
To add context, I've started manually setting the precision of my NIntegrate results to PrecisionGoal, and I want to know if/why this would be a bad idea. It seems perfectly logical to me, but it concerns me that this isn't already the default behavior.
PrecisionGoalare pretty well defined in its function page. So, I think it is a clear "no". (But I am very biased. Also, the word "precision" as technical term is overloaded, so I can see how questions similar to the posted one can arise...) – Anton Antonov Jan 28 '21 at 01:04PrecisionGoalwould be a bad idea. For one, it might not be reached. Then, as @AntonAntonov notes, it need not mean quite what you expect. In a solver it could, say, involve relative error of a residual. Would it be a good design to have different output precision conventions forNIntegratevsNSolve? I could probably come up with more objections but these are what first came to mind. – Daniel Lichtblau Jan 28 '21 at 14:48PrecisionGoal"specifies how many effective digits of precision should be sought in the final result." And the function page forPrecisionclaims that it "gives the effective number of digits of precision in the number x." This reads to me as ifPrecisionGoalis the right thing to use as thePrecisionof the final result. – WillG Jan 28 '21 at 17:13PrecisionGoal<WorkingPrecision, one could argue thatPrecisionGoalis still the better option since it overestimates the true precision by less, in these cases. As for your 2nd objection, I would sayNSolveshould also usePrecisionGoalfor the precision of its output, by the same logic. – WillG Jan 28 '21 at 17:15PrecisionGoalinNSolve. (First question: what does it mean? Second question: Once you have answered the first, how do you then attain it?) I think know the answers at least for the case of polynomial systems. Again, not easy. – Daniel Lichtblau Jan 28 '21 at 17:30NSolve. I don't know how this function works, or what the answers to your questions should be. ButPrecisionGoalis an option forFindRoot, so there must exist answers to your questions forFindRoot. PerhapsNSolveshould be similar? – WillG Jan 28 '21 at 17:37FindRootthe meaning is probably not what you would expect. If I remember correctly, theXXXGoaloptions are gauged by residuals (relative to root for precision, absolute residual for accuracy). This is not the same as counting correct digits of the result. – Daniel Lichtblau Jan 28 '21 at 17:53FindRootfunction page is: "The setting for PrecisionGoal specifies the number of digits of precision to seek in the value of the position of the root." – WillG Jan 28 '21 at 18:00PrecisionGoalandAccuracyGoalhere: https://mathematica.stackexchange.com/questions/118249/is-manual-adjustment-of-accuracygoal-and-precisiongoal-useless/139311#139311 -- They have different meanings inFindRootandNIntegrate. – Michael E2 Jan 29 '21 at 03:31