Computing the length of plane curves - Integration

In order to approximate the pressure on either side of the airfoil, we must be able to compute the lengths of the aforementioned splines, given as function $x \rightarrow f(x)$. To this purpose, we will compute a specific integral depending on the function $f$. As a reminder, the length of the graph of a function $y=f(x)$ defined and differentiable on an interval $[0;T]$ is given by the following integral :

$$L([0;T]) = \displaystyle \int_0^T \sqrt{1+f’(x)^2} ~dx$$

Note that it is necessary to compute the derivative of the function $f$, which is relatively easy when $f$ has been interpolated by a cubic spline first.

In order to compare the results and the speeds of convergence, several integration methods must be implemented. In terms of coding, the following should be considered :

  • the genericity of the functions (it must be possible to pass the integration method as a parameter)
  • the efficiency of the integration method (more efficient methods perform fewer evaluations of the function $f$ for the same level of precision)
  • Questions :
    1. Implement the integration methods seen in class for a defined number of points $N$ : left and right rectangle, middle point, trapezoidal, and Simpson. (integration_n_<name>( f, a, b, N ))
    2. Implement the iterative method seen in class for each of these method to be able to compute an integration at a given $\epsilon$. (integretion_epsilon( f, a, b, eps, meth )) Don’t forget to limit the maximum value of N that can be used.
    3. Validate your methods on known functions such as polynomial of different orders, or non polynomial as cos, sin, tan.
    4. You must provide correct graphs that shows and validate the convergence speed of the different methods.