Write a C algorithm that calculates the area under the curve y = f (x) for c ≤ x ≤ d:
- f is a 4th order polynomial function f (x) = a0 + a1x + a2x2 + a3x3 + a4x4
- With x ∈ R and ak ∈ R
The algorithm must use the trapezoidal integration method describes by the following curves: Area = c∫df(x)dx
- We divide the integration range [d - c] into N trapezes and we calculate the area of each trapeze alone then we add all the areas calculated to obtain the total area under the curve. The more trapezes considered in the range [d - c] the more accurate the result of area calculation is
- The user will enter the polynomial coefficients a0, a1, a2, a3, a4 as well as the integration limits c and d
- Your algorithm will start with N = 1, calculate the area then increase by 1 the number of trapezes used until the difference between two calculations is less than 1%.