Integral Calculus
Integral Calculus is concerned with the measurement of areas and volumes..
The general form of a definite integral equation over a specific range is:
Integration is performed by using iterative estimates across the integration range.
As shown below, rectangles the height of the curve and width of the integration steps are summed together to calculate the integral result. For each rectangle, there is an error shape containing the area difference between the rectangle and actual function curve.
Python Example using SciPy
An example integration equation is:
To download the code below that performs integration for this function, click here.
""" integration_with_scipy.py calculates the integral of a sine function """ # Import needed functions." import numpy as np from scipy import integrate import matplotlib.pyplot as plotlib # Define parameters. x_start = 0 x_stop = 12 x_steps_interval = 0.01 # Define an array of data points. x_values = np.arange(x_start, x_stop, x_steps_interval) y_values = 2 + np.sin(x_values) # Plot the function curve. plotlib.plot(x_values, y_values) # Define a lambda function for integration over x values. integration_function = lambda x: 2 + np.sin(x) # Calculate the integral. integral, error = integrate.quad(integration_function, x_start, x_stop) # Print the integration results. print("Integral Value:") print(integral) print("Integration Error:") print(error) # Display the plot. plotlib.xlabel('x') plotlib.ylabel('y') plotlib.show()
Results are shown below:
Integral Value:
24.1561460413
Integration Error:
3.44463457729e-10