1. Use matplotlib.pyplot.plot to produce a plot of the functions f(x) = e−x/10 sin(πx) and g(x) = xe−x/3 over the interval [0, 10]. Include labels for the x- and y-axes, and a legend explaining which line is which plot.
import matplotlib.pyplot as plt
import numpy as np
def main():
x = np.arange(0.0, 10.0, 0.01)
f = np.e - x / 10 * np.sin(x * np.pi)
g = x * np.e - x / 3
plt.plot(x, f)
plt.plot(x, g)
plt.show()
if __name__ == '__main__':
main()
Comments
Leave a comment