Numerical integration

The antiderivative of ex is, of course, itself. That makes evaluation of 10exdx by the Fundamental Theorem trivial.

using FundamentalsNumericalComputation
Copy to clipboard
exact = exp(1)-1
Copy to clipboard
1.718281828459045
Copy to clipboard

The Julia package QuadGK has a good all-purpose numerical integrator that estimates the value numerically without finding the antiderivative first. As you can see here, it’s often just as accurate.

Q,errest = quadgk(x->exp(x),0,1)
@show Q;
Copy to clipboard
Q = 1.718281828459045
Copy to clipboard

The numerical approach is far more robust. For example, esinx has no useful antiderivative. But numerically it’s no more difficult.

Q,errest = quadgk(x->exp(sin(x)),0,1)
@show Q;
Copy to clipboard
Q = 1.6318696084180515
Copy to clipboard

When you look at the graphs of these functions, what’s remarkable is that one of these areas is the most basic calculus while the other is almost impenetrable analytically. From a numerical standpoint, they are practically the same problem.

plot([exp,x->exp(sin(x))],0,1,fill=0,leg=:none,
    ylabel=["exp(x)" "exp(sin(x))"],ylim=[0,2.7],layout=(2,1))
Copy to clipboard