feat: add solution for task2 with sin and cos plot
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
parent
1166790801
commit
731062d3c6
28
rozw
Normal file
28
rozw
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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()
|
||||||
Loading…
Reference in New Issue
Block a user