Define the following functions,
f(x) = 1 / 1 + x2
and g(x) = x − x2
Produce plots of the graphs of each of f ◦ g and g ◦ f. You should choose settings (eg domain, number of samples) to make a smooth plot which displays the key features - try experimenting with different settings to work out what looks good.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(1,100,20)
f = 1/(1+x**2)
g = x - x**2
h = 1/(1+(x-x**2)**2)
s = (1/(1+x**2)) - (1/(1+x**2))**2
plt.plot(x,h)
plt.xlabel('x-axis')
plt.ylabel('f o g')
plt.plot(x,s)
plt.xlabel('x-axis')
plt.ylabel('g o f')
Comments
Leave a comment