---
# Einstein Notation
> ### $a_i, a^i$ (a super i), $(i = \text{ index}) $
>> ### Lots of expressions involve sumation over particular indices.
>> ### $$ \sum_{i=1}^{3} a_{i} x_{i} = a_1x_1 + a_2x_2 + a_3x_3 \iff a_{i}x_{i}$$

> ### Rule 1:
>> ### Any twice-repeated index in a single term is summed over, Index = 1,2,...,n Typically n =3.
>>> ### $a_{ij}b_{j} = a_{i1}b_{1} + a_{i2}b_{2} + a_{i3}b_{3} = a_{ir}b_{r}: $
>>>> ### j is dummy index
>>>> ### i is free index
> ## dummy index $\iff$ can replace it with any index
>> ### Not already in the expression
>> ### that is over the same range

> ## free index $\iff$ can take an any value that j takes on 
>> ### e.g) i = 1,2,3 but only ONE value
>> ## occurs only once in the expression and can not be replaced by another free index
>>> ### $ a_{ij}b_{j} \neq a_{kj}b_{j}$

> ## Rule 2 : definitions of indices
> ## Rule 3:
>> ### No index may occur 3 or more times on a given term.
> ### $ 
a_{ij}b_{ij} \to \text{ right} \\
a_{ii}b{ij}, \quad a_{ij}b_{jj} \to \text{worng} \\
a_{j}^{j} : \text{ j is a dummy index} \\
a_{i}^{jj} \to \text{ i = free, j = dummy}$
> ## in Multiple terms
>> ### $a_{ij}b_{j} + a_{ji}b{j} \to \text{ right: index counter resets after each term}$
>>> ### j is dummy index in both terms

# Rule 4:
> ### In equation involving Einsein notation, 
>> ### the free indices on both sides must match.
>> ### $
x_{i} = a_{ij}b{j} \to \text{ free: i = free: i} \\
a_{i} = A_{ki}B_{kj}x_{j} + C_{ik}u{k} \to \text{ free: i = free: i, dummy: j,k} \\
$
>> ### Wrong 
>>> ### $
x_{i} = A_{ij} \to \text{ free:i = free: i,j} \\
x{j} = A{ik}u{k} \to \text{ free:j = free: i} \\
x_{i} = A_{ik}u_{k} + C_{j} \to \text{ free:i = free:i,j}
$

# Brackets in Einstein Notaion
> ### $ a_{ij}(b_{i} + c_{j} + d{k})$
>> ### step 1: combine terms oustside parentheses with each term inside parentheses separately
>>> ### $ a_{ij} b_{i} \to \text{ i: 2, j: 1} \\
a_{ij} c_{j} \to \text{ i: 1, j: 2} \\
a_{ij}d_{k} \to \text{ i: 1, j: 1, k:1} \\
\therefore \text{ total = i: 2, j: 2, k:1 } \\
\therefore \text{ i,j is dummy index, k is free index}
$

# Kronecker Delta
> ### $\delta_{ij} \equiv \delta_{j}^{i} \equiv \delta^{ij} \equiv \begin{cases} 1, & i=j \\ 0,& i \neq j\end{cases}$

# Linear Transformations:
> ### $ C \overset{\text{linear}}{\underset{\text{transformation}}{\longrightarrow}} C' \\
\vec{x'} = L\vec{x}, \quad L \text{ is transformation matrix}$
>> Linear Transformations map lines to lines 


# General Transformations
> ### bijective transformation
>> ### is one-to-one
>>> ### every x in the original coordinate system corresponds to a unique x' in the image coordinate system and every x' in image coordinate system corresponds tto a unique x in the original coordinate system.
> ### $
\vec{x}' = T(\vec{x}) \quad x'_i = T_i(x_1, x_2, ... , x_n)\\
\text{If T is linear, the } x'_{i} \text{ coordinate system is called affine coordinate system.}\\
\text{If T is nonlinear, the } x'_{i} \text{ coordinate system is called a set of curvilinear coordinate system. (e.g. polar, cylindrical, spherical)}\\
$ 

# Chain Rule Partial Derivative
> ### Suppose $ w = f(u_1, u_2,..., u_n)$, 
where $u_i = u_i(x_1, x_2, ..., x_n)$ , 
i is an integer index from 1 to n
>> ### $\frac{\partial w}{\partial x_j} = 
\frac{\partial f}{\partial u_1} \frac{\partial u_1}{\partial x_j} +  
\frac{\partial f}{\partial u_2} \frac{\partial u_2}{\partial x_j} +  ... +
\frac{\partial f}{\partial u_n} \frac{\partial u_n}{\partial x_j}
$
> ### Einstein Notation
>> ### $ \frac{\partial w}{\partial x_j} = \frac{\partial f}{\partial u_i} \frac{\partial u_i}{\partial x_j}$

# Coordinate Transformation for Tensors
> ## New Notaion
>> ### A vector in $\mathbb{R}^n$
>>> ### $\vec{PG} = \vec{x} = \begin{bmatrix}x^1 \\ x^2 \\ \vdots \\ x^n \end{bmatrix}$
>>> ### $A = ( a^1, a^2, \cdots, a^n) $

# Rectangular Coordinates
> ### $ \sqrt{(x^1 - y^1)^2 + (x^2 - y^2)^2 + ...} = 
\sqrt{\delta_{ij} \Delta x^i \Delta x^j }\\
\quad \text{ where } \Delta x^i = x^i - y^i$

# Polar Coordinate system

> ### $ P: (x^1,x^2), \quad \text{where, }\quad x^1, x^2 \text{ is rectangular coordinates} \\ 
\left.\begin{aligned}\bar{x}^1 &= \sqrt{(x^{1})^2 + (x^{2})^2} \\
\bar x^2 &= atan(\frac{x^2}{x^1}) \end{aligned} \quad \right \} T_p$

> ### $ \left.\begin{aligned} x^1 &= \bar{x}^{1}cos(\bar{x}^{2}) \\
x^2 & = \bar{x}^{1}sin(\bar{x}^{2}) \end{aligned} \quad \right \} T_p^{-1}$

> ### $ T_p $ is a curvilinear coordinate transformation

# Cylindrical Coordinate System
> ### $ P:(x^1, x^2, x^3) $ - rectangular coordinates
>> ### $ \left.
\begin{aligned}
\bar{x^1} &= \sqrt{(x^1)^2 + (x^2)^2} \\
\bar{x^2} &= atan(\frac{x^2}{x^1})\\
\bar{x^3} &= x^3 \end{aligned} \quad \right \} T_c$


```python
# Shperical Coordinate system
```

# Curvilinear Coordiante
> ### suppose
>> ### $P$ is a point in a coordiante system($x^i$)  in $\mathbb R^n$ given by $P:(x^1, x^2,...,x^n)$
>> ### $(\bar{x}^i)$ is another coordiante system  in $\mathbb R^n$ such that the coordinates of $P$ in this system are $P:(\bar{x}^1,\bar{x}^2,...,\bar{x}^n)$

>> ### $\text{suppose that } \bar{x}^i = \bar{x}^i(x^1, x^2,...,x^n)\big\} F \text{ is a transformation.}$
>>> ### - If the function $ \bar x^i (x^1, x^2, ..., x^n)$ are all real-value, have continuous 2nd partial derivatives everywhere, and are all invertible, then $F$ is called a coordinate transformation}


```python
# polar coordinate system
import sympy as sm
import sympy.vector
N = sm.vector.CoordSys3D('R')
P = N.create_new('P', transformation='cylindrical')
P.base_scalars()
P.transformation_to_parent()
```




    (P.r*cos(P.theta), P.r*sin(P.theta), P.z)



# [Jacobian](https://www.youtube.com/watch?v=kzKQUVNEPhc&list=PL0q7DjoZohFuMRNxE9nvU16nx607cRGxI)
> ### Suppose that $\bar{x}^i = \bar{x}^i(x^1, x^2,...,x^n) $


```python
# a(1,2,0)
a = N.i + 2*N.j
a.to_matrix(N)
# b(-1,1,0)
b = -1*N.i + N.j
b.to_matrix(N)

M = sm.vector.CoordSys3D('M')

# am(2,2,0)
am = 2*M.i + 2*M.j
# bm(0,2,0)
bm = 2*M.j
am.cross(bm)
a.cross(b)
# Foreward Matrix(N.e -> M.e)
l = N.i + 1/2*N.j
m = -1/2*N.i + 1/2*N.j
mm = m.to_matrix(N)
lm = l.to_matrix(N)

F = sm.Matrix([
    [1,1/2,0],
    [-1/2,1/2,0],
    [0,0,1]])
F*am.to_matrix(M)
# Backward Matrix(M.e -> N.e)
B = F.inv()
B*a.to_matrix(N) == am.to_matrix(M)

# area
da = a.cross(b).subs(N.k,1) / am.cross(bm).subs(M.k,1)
F.det()
```




$\displaystyle 0.75$




```python
# Jacobian 2 Polar CoordSys3D
P = N.create_new('P',transformation='cylindrical')
P
```




$\displaystyle CoordSys3D\left(P, cylindrical, CoordSys3D\left(N, \left( \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right], \  \mathbf{\hat{0}}\right)\right)\right)$



# Jacobian Matrix
> ## $ 
J = 
\begin{bmatrix} 
\frac{\partial f}{\partial x_{1}} \cdots \frac{\partial f}{\partial x_{n}}
\end{bmatrix}
= 
\begin{bmatrix} 
\nabla^{T}f_{1} \\ \vdots \\ \nabla^{T}f_{m}
\end{bmatrix}
=
\begin{bmatrix} 
\frac{\partial f_{1}}{\partial x_{1}} & \cdots & \frac{\partial f_{1}}{\partial x_{n}} \\
\vdots & \ddots & \vdots  \\
\frac{\partial f_{m}}{\partial x_{1}} & \cdots & \frac{\partial f_{m}}{\partial x_{n}}
\end{bmatrix}
$
>> ## gradient at f(p)
$
\nabla f(p) = 
\begin{bmatrix} 
\frac{\partial f}{\partial x_{1}}(p) \\ \vdots \\ \frac{\partial f}{\partial x_{n}}(p)
\end{bmatrix}
$

# jacobian 
> ### $ J \equiv \text{ det J}$


```python
# Variant
> ### Contravariant Tensors

> ### Covariant Tensors
```


```python
N
```




$\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)$




```python

```

92ae301ac77ffc21cb5b4cee54abe05012f4e95a
ipynb
Jupyter Notebook
python/Vectors/EinsteinNotations.ipynb
karng87/nasm_game
a97fdb09459efffc561d2122058c348c93f1dc87
MIT
python/Vectors/EinsteinNotations.ipynb
karng87/nasm_game
a97fdb09459efffc561d2122058c348c93f1dc87
MIT
python/Vectors/EinsteinNotations.ipynb
karng87/nasm_game
a97fdb09459efffc561d2122058c348c93f1dc87
MIT
Qwen/Qwen-72B
1. YES
2. YES