Code and Graph Explanation
Code and Graph Explanation
- These x values will serve as the independent variable for plotting functions.
y1 = np.sin(x)
y2 = np.cos(x)
y3 = y1 + y2
- Computes sine, cosine, and their sum element-wise, creating three separate waveforms.
plt.figure(figsize=(10, 6))
- Plots the sine, cosine, and combined waveforms, assigning a dashed style to the sum.
plt.title('Trigonometric Functions')
plt.xlabel('x-axis')
plt.ylabel('y-axis')
plt.legend()
plt.grid(True)
plt.show()
- The result of adding sine and cosine values at each x, creating a new waveform.
4. Grid:
- Helps analyze the behavior of functions.
5. Legend:
1. numpy methods:
2. matplotlib methods: