0

Consider $g(x)$ which is mathematically defined as

$g(x) = \int^{x}_{x_0} f(x') dx'$ such that $x\in\{x_0,x_{max}\}$.

If $f(x)$ can only be integrated numerically, one could define the following Mathematica function

g[x_]:= NIntegrate[f[xPrime],{xPrime,x0,x}]

Plotting this would take an eternity since every time x increases by an increment, the integral must be re-evaluated from x0 to the new x again and again. How can one efficiently plot $g(x)$ such that the plotting time is on the order of evaluating $g(x_{max})$? Equivalently, what is the most efficient way to generate an InterpolatingFunction for $g(x)$ over the range $x_0$ to $x_{max}$?


Note: Conversion to differential equation and using NDSolve is not a valid method as suggested here.

Note: Related but not a duplicate of "Plotting results of NIntegrate with variable integration limit".

Miladiouss
  • 1,883
  • 11
  • 26

0 Answers0