Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
471 B
1
Indexable
Never
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()