SciPy - Integration with Scientific Ecosystem
The following code is intended to plot the cumulative integral of cos(x) from 0 to 2π, but it raises an error. What is the error and how to fix it?
import numpy as np import matplotlib.pyplot as plt from scipy.integrate import cumtrapz x = np.linspace(0, 2*np.pi, 100) y = np.cos(x) integral = cumtrapz(y, x) plt.plot(x, integral) plt.show()
