September 2026
1051 pages
35h 4m
English
We’ll use a simple model program. For the function f(x) = x3 – 10 sin(x) – 4, it calculates the derivative and an antiderivative numerically and displays them graphically in the interval [-3,3].
Using this model program, we’ll explain typical procedures for working with numpy, scipy, and matplotlib:
import numpy as npimport scipy as spimport matplotlib as mplimport matplotlib.pyplot as pltdef f(x): return x**3 - 10*np.sin(x) - 4def df(x): return sp.differentiate.derivative(f, x).df@np.vectorizedef F(x): return sp.integrate.quad(f, 0, x)[0] X = np.linspace(-3, 3, 200)Y = f(X)Y1 = df(X)Y2 = F(X)plt.plot(X, Y, linewidth=2, label="$f$")plt.plot(X, Y1, linewidth=2, linestyle="dashed", label="$f'$")plt.plot(X, Y2, linewidth= ...
Read now
Unlock full access