Untitled
unknown
plain_text
2 years ago
471 B
7
Indexable
import numpy as np
import matplotlib.pyplot as plt
# Constants
k = 8.99e9 # Coulomb's constant in N·m²/C²
q = -1.0 # Charge of particle in Coulombs
d = np.linspace(0.01, 1, 1000) # Distance from particle in meters
# Calculate potential energy as a function of distance
U = k * q**2 / d
# Plot the graph
plt.plot(d, U)
plt.xlabel('Distance from particle (m)')
plt.ylabel('Potential energy (J)')
plt.title('Potential energy of a negative point charge')
plt.show()
Editor is loading...