```python
from sympy import symbols, sin, cos, Abs
from galgebra.ga import Ga
from galgebra.printer import Format, Fmt
from IPython.display import Latex
Format()
```


```python
xyz_coords = (x, y, z) = symbols('x y z', real=True)
(o3d, ex, ey, ez) = Ga.build('e', g=[1, 1, 1], coords=xyz_coords, norm=True)
o3d.g
```




$\displaystyle \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$




```python
f = o3d.mv('f', 'scalar', f=True)
f
```




\begin{equation*} f = f  \end{equation*}




```python
F = o3d.mv('F', 'vector', f=True)
lap = o3d.grad*o3d.grad
lap.Fmt(1,r'\nabla^{2}')
```




\begin{equation*} \nabla^{2} = \frac{\partial^{2}}{\partial x^{2}} + \frac{\partial^{2}}{\partial y^{2}} + \frac{\partial^{2}}{\partial z^{2}} \end{equation*}




```python
lap.Fmt(1,r'\nabla^{2}')
```




\begin{equation*} \nabla^{2} = \frac{\partial^{2}}{\partial x^{2}} + \frac{\partial^{2}}{\partial y^{2}} + \frac{\partial^{2}}{\partial z^{2}} \end{equation*}




```python
lapf = lap*f
lapf
```




\begin{equation*} \partial^{2}_{x} f  + \partial^{2}_{y} f  + \partial^{2}_{z} f  \end{equation*}




```python
lapf = o3d.grad | (o3d.grad * f)
lapf.Fmt(1,r'\nabla \cdot (\nabla f)')
```




\begin{equation*} \nabla \cdot (\nabla f) = \partial^{2}_{x} f  + \partial^{2}_{y} f  + \partial^{2}_{z} f  \end{equation*}




```python
divF = o3d.grad|F
divF.Fmt(1,'x =')
```




\begin{equation*} x = = \partial_{x} F^{x}  + \partial_{y} F^{y}  + \partial_{z} F^{z}  \end{equation*}




```python
gradF = o3d.grad * F
gradF.Fmt(1,r'\nabla F')
```




\begin{equation*} \nabla F = \left ( \partial_{x} F^{x}  + \partial_{y} F^{y}  + \partial_{z} F^{z} \right )  + \left ( - \partial_{y} F^{x}  + \partial_{x} F^{y} \right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{y} + \left ( - \partial_{z} F^{x}  + \partial_{x} F^{z} \right ) \boldsymbol{e}_{x}\wedge \boldsymbol{e}_{z} + \left ( - \partial_{z} F^{y}  + \partial_{y} F^{z} \right ) \boldsymbol{e}_{y}\wedge \boldsymbol{e}_{z} \end{equation*}




```python
sph_coords = (r, th, phi) = symbols('r theta phi', real=True)
(sp3d, er, eth, ephi) = Ga.build('e', g=[1, r**2, r**2 * sin(th)**2], coords=sph_coords, norm=True)
sp3d.g_raw
```




$\displaystyle \left[\begin{matrix}1 & 0 & 0\\0 & r^{2} & 0\\0 & 0 & r^{2} \sin^{2}{\left(\theta \right)}\end{matrix}\right]$




```python
sp3d.grad.Fmt(1,r'\nabla')
```




\begin{equation*} \nabla = \boldsymbol{e}_{r} \frac{\partial}{\partial r} + \boldsymbol{e}_{\theta } \frac{1}{r} \frac{\partial}{\partial \theta } + \boldsymbol{e}_{\phi } \frac{1}{r \sin{\left (\theta  \right )}} \frac{\partial}{\partial \phi } \end{equation*}




```python
f = sp3d.mv('f', 'scalar', f=True)
F = sp3d.mv('F', 'vector', f=True)
B = sp3d.mv('B', 'bivector', f=True)
sp3d.grad.Fmt(1,r'\nabla')
lap = sp3d.grad*sp3d.grad
lap.Fmt(1,r'\nabla^{2} ')
```




\begin{equation*} \nabla^{2}  = \frac{1}{r^{2} \tan{\left (\theta  \right )}} \frac{\partial}{\partial \theta } + \frac{2}{r} \frac{\partial}{\partial r} + \frac{1}{r^{2} {\sin{\left (\theta  \right )}}^{2}} \frac{\partial^{2}}{\partial \phi ^{2}} + r^{-2} \frac{\partial^{2}}{\partial \theta ^{2}} + \frac{\partial^{2}}{\partial r^{2}} \end{equation*}




```python
Lapf = lap*f
Lapf.Fmt(1,r'\nabla^{2} f')
```




\begin{equation*} \nabla^{2} f = \frac{r^{2} \partial^{2}_{r} f  + 2 r \partial_{r} f  + \partial^{2}_{\theta } f  + \frac{\partial_{\theta } f }{\tan{\left (\theta  \right )}} + \frac{\partial^{2}_{\phi } f }{{\sin{\left (\theta  \right )}}^{2}}}{r^{2}} \end{equation*}




```python
lapf = sp3d.grad | (sp3d.grad * f)
lapf.Fmt(1,r'\nabla \cdot (\nabla f)')
```




\begin{equation*} \nabla \cdot (\nabla f) = \frac{r^{2} \partial^{2}_{r} f  + 2 r \partial_{r} f  + \partial^{2}_{\theta } f  + \frac{\partial_{\theta } f }{\tan{\left (\theta  \right )}} + \frac{\partial^{2}_{\phi } f }{{\sin{\left (\theta  \right )}}^{2}}}{r^{2}} \end{equation*}




```python
dviF = sp3d.grad | F
divF.Fmt(1,r'\nabla F')
```




\begin{equation*} \nabla F = \partial_{x} F^{x}  + \partial_{y} F^{y}  + \partial_{z} F^{z}  \end{equation*}




```python
curlF = sp3d.grad ^ F
curlF.Fmt(1,r'\nabla \wedge F')
```




\begin{equation*} \nabla \wedge F = \frac{r \partial_{r} F^{\theta }  + F^{\theta }  - \partial_{\theta } F^{r} }{r} \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\theta } + \frac{r \partial_{r} F^{\phi }  + F^{\phi }  - \frac{\partial_{\phi } F^{r} }{\sin{\left (\theta  \right )}}}{r} \boldsymbol{e}_{r}\wedge \boldsymbol{e}_{\phi } + \frac{\frac{F^{\phi } }{\tan{\left (\theta  \right )}} + \partial_{\theta } F^{\phi }  - \frac{\partial_{\phi } F^{\theta } }{\sin{\left (\theta  \right )}}}{r} \boldsymbol{e}_{\theta }\wedge \boldsymbol{e}_{\phi } \end{equation*}




```python
divB = sp3d.grad | B
divB.Fmt(1,r'\nabla \cdot B')
```




\begin{equation*} \nabla \cdot B = - \frac{\frac{B^{r\theta } }{\tan{\left (\theta  \right )}} + \partial_{\theta } B^{r\theta }  + \frac{\partial_{\phi } B^{r\phi } }{\sin{\left (\theta  \right )}}}{r} \boldsymbol{e}_{r} + \frac{r \partial_{r} B^{r\theta }  + B^{r\theta }  - \frac{\partial_{\phi } B^{\theta \phi } }{\sin{\left (\theta  \right )}}}{r} \boldsymbol{e}_{\theta } + \frac{r \partial_{r} B^{r\phi }  + B^{r\phi }  + \partial_{\theta } B^{\theta \phi } }{r} \boldsymbol{e}_{\phi } \end{equation*}




```python
F
```




\begin{equation*} F = F^{r}  \boldsymbol{e}_{r} + F^{\theta }  \boldsymbol{e}_{\theta } + F^{\phi }  \boldsymbol{e}_{\phi } \end{equation*}




```python
F.Fmt(3,'F')
```




 \begin{align*}   F =& F^{r}  \boldsymbol{e}_{r} \\  &  + F^{\theta }  \boldsymbol{e}_{\theta } \\  &  + F^{\phi }  \boldsymbol{e}_{\phi }  \end{align*} 





```python
F.norm()
```




$\displaystyle \sqrt{\operatorname{F^{\phi}}^{2}{\left(r,\theta,\phi \right)} + \operatorname{F^{r}}^{2}{\left(r,\theta,\phi \right)} + \operatorname{F^{\theta}}^{2}{\left(r,\theta,\phi \right)}}$



f9c5f1c272e1a8590e12cd8cfc3d2c4bfa222c4e
ipynb
Jupyter Notebook
examples/ipython/dop.ipynb
EAR-Development/galgebra
f30de3069a28d99c759d15a6574919855921931d
BSD-3-Clause
examples/ipython/dop.ipynb
EAR-Development/galgebra
f30de3069a28d99c759d15a6574919855921931d
BSD-3-Clause
examples/ipython/dop.ipynb
EAR-Development/galgebra
f30de3069a28d99c759d15a6574919855921931d
BSD-3-Clause
Qwen/Qwen-72B
1. YES
2. YES