Length of a Curve
A major use of derivatives and integrals is finding the length of a curve. There's a formula for this:
The preceding formula contains an integral and a derivative. To find the length of a curve, we'll need both our derivative and integral functions. Copy and paste them into your code if you don't have them yet:
from math import sqrt def derivative(f,x): """Returns the value of the derivative of the function at a given x-value.""" delta_x = 1/1000000 return (f(x+delta_x) - f(x))/delta_x def trap_integral(f,a,b,num): """Returns the sum of num trapezoids under f between a and b""" width = (b-a)/num area = 0.5*width*(f(a) + f(b) + 2*sum([f(a+width*n) \ ...