A few comments to the posted comments and answers follow.
Faster computations without messages
@Turgo Ah, you mean Method -> {Automatic, "SymbolicProcessing" -> False}. Yes. Unfortunately, that does not remove the error messages. – Henrik Schumacher Jul 27 at 13:57
Using Method -> {Automatic, "SymbolicProcessing" -> False} indeed does not eliminate the error messages, but does reduce the number of them to two when applied to the outer integration. It seems to have no effect on the inner integration. – bbgodfrey Jul 27 at 18:32
Here is a definition that produces faster results without messages. The setting
Method -> {Automatic, "SymbolicProcessing" -> 0} is used for both integrals.
Clear[f];
f[y_?NumericQ] :=
Exp[-NIntegrate[x, {x, 0, y}, Method -> {Automatic, "SymbolicProcessing" -> 0}]];
AbsoluteTiming[
res = NIntegrate[f[y], {y, 0, 2.8}, Method -> {Automatic, "SymbolicProcessing" -> 0}]
]
(* {0.00553, 1.24691} *)
Precision of the results
OP says the computation in his post is a simplified example of a computation with more complicated integrands. Depending on the integrands and precision goal requirements the NDSolve approach
might be not precise enough.
Illustrating computations follow. (I show WorkingPrecision->30 and PrecisionGoal->20, but similar results are obtained with machine precision and PrecisionGoal->12.)
Integrate
F[y0_] := Integrate[Exp[-Integrate[x, {x, 0, y}]], {y, 0, y0}]
F[y0]
(* Sqrt[\[Pi]/2] Erf[y0/Sqrt[2]] *)
F[2.8]
(* 1.24691 *)
NDSolve:
sol2 = NDSolveValue[{z'[x] == x, z[0] == 0, int'[x] == Exp[-z[x]],
int[0] == 0}, int, {x, 0, 28/10}, WorkingPrecision -> 30,
PrecisionGoal -> 20];
sol2[28/10]
(* 1.24690937538389563405549789088 *)
Abs[sol2[2.8] - F[28/10]]
(* 1.3322710^-14 )
NIntegrate
f[y_?NumericQ] :=
Exp[-NIntegrate[x, {x, 0, y},
Method -> {Automatic, "SymbolicProcessing" -> 0},
WorkingPrecision -> 30, PrecisionGoal -> 20]];
res = NIntegrate[f[y], {y, 0, 28/10},
Method -> {"GlobalAdaptive", "SymbolicProcessing" -> 0},
MaxRecursion -> 20, WorkingPrecision -> 30, PrecisionGoal -> 20]
(* 1.24690937538388234380595431698 *)
Abs[res - F[28/10]]
(* 0.10^-30 )
SymbolicProcessing, would this error still present? – Turgon Jul 27 '19 at 08:34SymbolicProcessingis not an option ofNIntegrate. – Henrik Schumacher Jul 27 '19 at 12:59NIntegrate. Check the help page, it's under Options->Method->SymbolicProcessing. – Turgon Jul 27 '19 at 13:41Method -> {Automatic, "SymbolicProcessing" -> False}. Yes. Unfortunately, that does not remove the error messages. – Henrik Schumacher Jul 27 '19 at 13:57Method -> {Automatic, "SymbolicProcessing" -> False}indeed does not eliminate the error messages, but does reduce the number of them to two when applied to the outer integration. It seems to have no effect on the inner integration. – bbgodfrey Jul 27 '19 at 18:32NIntegrate. – Michael E2 Jul 27 '19 at 20:13