import numpy as np import matplotlib.pyplot as plt # Generate x values from 0 to 4π x = np.linspace(0, 4*np.pi, 1000) # Calculate y values for both functions y1 = np.sin(x) y2 = np.cos(x) # Create the plot plt.figure(figsize=(10, 6)) plt.plot(x, y1, color='blue', label='sin(x)') plt.plot(x, y2, color='red', label='cos(x)') # Add labels and title plt.xlabel('x') plt.ylabel('y') plt.title('Sine and Cosine Functions') # Add legend plt.legend() # Add grid for better readability plt.grid(True, alpha=0.3) # Display the plot plt.show()