# Charges_on_Equilateral_Triangle.ipynb

In [1]:
from sympy import symbols, pi
import xv.km

In [2]:
rA, rB, rP = symbols('r_A, r_B, r_P')
display(rA, rB, rP)

$\displaystyle r_{A}$
$\displaystyle r_{B}$
$\displaystyle r_{P}$
In [3]:
epsilon0 = symbols('epsilon_0')
epsilon0

Out[3]:
$\displaystyle \epsilon_{0}$
In [4]:
k = 1/(4*pi*epsilon0)
k

Out[4]:
$\displaystyle \frac{1}{4 \pi \epsilon_{0}}$
In [5]:
qA = 1
qB = 2
qC = 3

xA, yA, xB, yB, xP, yP = symbols('x_A, y_A, x_B, y_B, x_P, y_P') display(xA, yA, xB, yB, xP, yP)
In [6]:
xP, yP = symbols('x_P, y_P')
# m = symbols('m', positive = True, real = True)
m=1

xA = -m
yA = 0

xB = m
yB = 0

xC = 0
yC = 1.73 * m

In [7]:
from sympy.vector import CoordSys3D, Vector

In [8]:
N = CoordSys3D('N')
N

Out[8]:
$\displaystyle CoordSys3D\left(N, \left( \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right], \ \mathbf{\hat{0}}\right)\right)$
In [9]:
r0 = 0 * N.i + 0 * N.j
r0

Out[9]:
$\displaystyle \mathbf{\hat{0}}$
In [10]:
rA = xA * N.i + yA * N.j
rA

Out[10]:
$\displaystyle - \mathbf{\hat{i}_{N}}$
In [11]:
rB = xB * N.i + yB * N.j
rB

Out[11]:
$\displaystyle \mathbf{\hat{i}_{N}}$
In [12]:
rC = xC * N.i + yC * N.j
rC

Out[12]:
$\displaystyle (1.73)\mathbf{\hat{j}_{N}}$
In [13]:
rP = xP * N.i + yP * N.j
rP

Out[13]:
$\displaystyle (x_{P})\mathbf{\hat{i}_{N}} + (y_{P})\mathbf{\hat{j}_{N}}$
In [14]:
rAP = rP - rA
rAP

Out[14]:
$\displaystyle (x_{P} + 1)\mathbf{\hat{i}_{N}} + (y_{P})\mathbf{\hat{j}_{N}}$
In [15]:
EA = k * (qA/rAP.magnitude()**3 )*rAP
EA

Out[15]:
$\displaystyle (\frac{x_{P} + 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{i}_{N}} + (\frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{j}_{N}}$
In [16]:
rCP = rP - rC
rCP

Out[16]:
$\displaystyle (x_{P})\mathbf{\hat{i}_{N}} + (y_{P} - 1.73)\mathbf{\hat{j}_{N}}$
In [17]:
EC = k * (qA/rCP.magnitude()**3 )*rCP
EC

Out[17]:
$\displaystyle (\frac{0.0482838285676873 x_{P}}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{i}_{N}} + (\frac{0.0482838285676873 \left(y_{P} - 1.73\right)}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{j}_{N}}$
In [18]:
rBP = rP - rB
rBP

Out[18]:
$\displaystyle (x_{P} - 1)\mathbf{\hat{i}_{N}} + (y_{P})\mathbf{\hat{j}_{N}}$
In [19]:
EB = k * (qA/rBP.magnitude()**3 )*rBP
EB

Out[19]:
$\displaystyle (\frac{x_{P} - 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{i}_{N}} + (\frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{j}_{N}}$
In [20]:
E = EA + EB + EC
E

Out[20]:
$\displaystyle (\frac{0.0482838285676873 x_{P}}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{x_{P} - 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{x_{P} + 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{i}_{N}} + (\frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{0.0482838285676873 \left(y_{P} - 1.73\right)}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{j}_{N}}$
In [ ]:


In [21]:
from sympy import Eq,solve
import xv.km

In [22]:
eq = Eq(E, r0)
eq

Out[22]:
$\displaystyle (\frac{0.0482838285676873 x_{P}}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{x_{P} - 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{x_{P} + 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{i}_{N}} + (\frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{0.0482838285676873 \left(y_{P} - 1.73\right)}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}})\mathbf{\hat{j}_{N}} = \mathbf{\hat{0}}$
In [23]:
eq1 = Eq(eq.lhs.dot(N.i), eq.rhs.dot(N.i))
eq1

Out[23]:
$\displaystyle \frac{0.0482838285676873 x_{P}}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{x_{P} - 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{x_{P} + 1}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}} = 0$
In [27]:
eq2 = Eq(eq.lhs.dot(N.j), eq.rhs.dot(N.j))
eq2

Out[27]:
$\displaystyle \frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} + 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{y_{P}}{4 \pi \epsilon_{0} \left(y_{P}^{2} + \left(x_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} + \frac{0.0482838285676873 \left(y_{P} - 1.73\right)}{\pi \epsilon_{0} \left(0.334124093688396 x_{P}^{2} + \left(0.578034682080925 y_{P} - 1\right)^{2}\right)^{\frac{3}{2}}} = 0$
In [25]:
solve((eq1, eq2), xP, yP)

Out[25]:
[]
In [ ]:


In [ ]:


In [ ]:


In [ ]: