In [6]:
import numpy as np
import matplotlib.pyplot as plt
# Define x values
x = np.linspace(-10, 10, 400)
# Define functions
f = x**2
g = np.cos(x)
# Plot both functions
plt.figure(figsize=(8,6))
plt.plot(x, f, label="f(x) = x^2", color="pink")
plt.plot(x, g, label="g(x) = sin(x)", color="purple")
# Add labels and title
plt.xlabel("x")
plt.ylabel("y")
plt.title("Graph of f(x) = x^2 and g(x) = sin(x)")
plt.legend()
plt.grid(True)
plt.show()
In [ ]: