I have recently been doing some research on flight and aerodynamics for a project that’s in the pipeline, in particular how to calculate lift under varying conditions. According to **Wikipedia**:

“The total Lift force is the integral of vertical pressure forces over the entire wetted surface area of the wing.”

This got me wondering about how to calculate the definite integral of a function programatically, so I wrote this program which aproximates the area under a curve to a given degree of accuracy by breaking the area up into a number of trapezoids.

### Download

**Source**: integral.cpp (3.0 KB)

**Update**

This post is now [3 July 2008] the most popular on the whole blog. If you find it helpful (or not) please leave a comment. Thanks.

Thanks man, needed this for a side project, was looking for a library or something, but this is great.

You’re welcome

thanks implemented a length of curve function using your ideas it helped a bit to give me some ideas on how to integrate the sqrt() functions.

Thank you for the code. It helped me create a definite complex integral function.