```python
'''
    File name          : Math HW 1A -- Dimensional Analysis.ipynb
    Author             : Ming-Feng Ho 
    Date created       : 9/30/2018
    Date last modified : 10/2/2018
    Python Version     : 3.6
    Sympy Version      : 1.3
'''

import sympy as sp

# pretty print the latex formula in notebook
sp.init_printing()

# this function is like the print function in Jupyter notebook,
# you can check the Jupyter display document.
from IPython.display import display
```





```python
# (a) use the Coulomb law in cgs unit
F, q1, q2, r = sp.symbols("F q1 q2 r", real=True)
coulomb_law = sp.Eq(F, q1 * q2 * r**-2)
print("(a) Coulomb law in cgs unit")
display(coulomb_law)

# use symbols to represent the dimensions: length, mass, time
L, M, T = sp.symbols("L M T")

# convert into dimension
coulomb_law_dimension = coulomb_law.subs({
    F : M * L * T**-2, 
    q1: sp.symbols("[q]"),
    q2: sp.symbols("[q]"),
    r : L
})
print("Substitute the dimensions")
display(coulomb_law_dimension)

# solve for [q]
sol = sp.solve(coulomb_law_dimension, sp.symbols("[q]"), rational=False)[1]
coulomb_law_dimension = sp.Eq(sp.symbols("[q]"), sol)
print("Solve for [q]")
display(coulomb_law_dimension.expand(force=True))
```


```python
# (b) Lagrangian L = Kinetic energy - potential energy, so it is in the same unit of energy.
Lagrangian = M * (L * T**-1)**2
print("(b) Lagrangian is in the same unit of energy, so I use m*v**2 to express the dimension of Lagrangian: [Lagrangian] =")
display(Lagrangian)

# Action is [S] = [Lagrangian] * T
S = sp.symbols("[S]")
display(sp.Eq(S, Lagrangian * T, ))
```


```python
# (c) Recall the F = q (v x B) equation
B, v, q = sp.symbols("B v q")
print("(c) Recall the F = q (v x B) equation")

# damn ... sympy's cross product is in vetor form.
display(sp.Eq(
    sp.symbols("[B]"), 
    (F * q**-1 * v**-1).subs({
        F : M * L * T**-2, 
        q : coulomb_law_dimension.rhs,
        v : L * T**-1
    })
).expand(force=True))
```


```python
# (d) Energy is in the same unit of Largrangian
print("(d) Energy is in the same unit of Largrangian")
display(sp.Eq(
    sp.symbols("[E]"), 
    Lagrangian
))
```




```python
# (a) dessert animal
```

(a) dessert animal

I played a video game called "Zelda : Breath of the Wild" on Nintendo switch before. It is a really nice game. "Zelda" allows players to explore the world of Hyrule Kingdom with limited constraints. Anyway, there's a town called Gerudo on the southern area of the Hyrule Kingdom. The town is located in a harsh dessert. While the players is running in the dessert area, because it is too hot, their life (or Health Point (HP)) will decrease until they die. 

So, we may assume that the maximal distance an animal can run depends on the how many HPs they have and the rate of decreasing HPs under the hot desert weather.


```python
# maximal distance = velocity * time = velocity * (number of HPs) / (rate of decreasing HP)
HP, rate = sp.symbols("HP rate")
maximal_distance = v * HP / rate
print("maximal distance = velocity * time = velocity * (number of HPs) / (rate of decreasing HP) =\n= {}\n".format(maximal_distance))

# assume: number of HPs is proportional to the volume size of an animal.
HP_expr = L**3
print("Assume: number of HPs is proportional to the volume size of an animal. \nLarger animals get more HPs. \nIn the game, the Bosses are usually bigger and have more HPs, so there may have a correlation here.")
display(sp.Eq(sp.symbols("[HP]"), HP_expr))

# assume: rate of decreasing HPs is proportional to the surface size of an animal.
rate_expr = L**2
print("Assume: rate of decreasing HPs is proportional to the surface size of an animal. \nLarger surface area usually more easily suffer from dehydration. \nAnd when you dehydration in the dessert, you die.")
display(sp.Eq(sp.symbols("[rate]"), rate_expr))

# combine all information, and recall that time is proportional to (number of HPs) / (rate of decreasing HP)
maximal_distance_dimension = maximal_distance.subs({
    v    : L * T**-1,
    HP   : HP_expr,
    rate : rate_expr,
}).subs({
    T : HP_expr * rate_expr**-1
})
print("Combine all information, and recall that time is proportional to (number of HPs) / (rate of decreasing HP)")
display(sp.Eq(
    sp.symbols("[MaximalDistance]"), 
    maximal_distance_dimension
))
```

(b) Height of the jump of a animal


```python
# (b) Height of the jump of a animal
# recall the equation of Work and Energy
dx, W, m, g, h = sp.symbols("dx W m g h")
work_energy_expr = sp.Eq(F * dx, m * g * h)
print("Recall the equation of Work and Energy: \nWork = force * distance = mass * gravitational_acceleration * height")
display(work_energy_expr)

h_expr = sp.Eq(h, sp.solve(work_energy_expr, h)[0])
display(h_expr)

# set the force proportional to the cross section
print("Force is proptional to the cross section, which means the force is proportional to the size square, ")
c = sp.symbols("c")
F_expr = sp.Eq(F, c * L**2)
display(F_expr)
print("where L is the size and c is just a constant.")

# set the mass is proportional to the size^3, distance for the force pushing to floor is proportional to size
print("Say if the density of any animal is just a constant, we can set the mass is just proportional to the size^3.")
print("And, the dx, a displacement in a straight line in the direction of the force, is just proportional to the size.")
print("We get, ")

display(h_expr.subs({
    F : F_expr.rhs,
    m : L**3,
    g : 1, 
    dx : L
}).subs({
    c : sp.symbols("c'")
}))
print("Surprisingly, we get the height an animal can jump is a constant.")

```

I guess it is the problem of the body density. If we take density into account, we get

\begin{equation}
    h \propto \frac{1}{\rho},
\end{equation}

where $\rho$ is the body density. The above relation is more promising than $h$ is just a constant.

04c0ac59e3075d42cbf73721c0fc63c6ed32e9e9
ipynb
Jupyter Notebook
Math HW 1A -- Dimensional Analysis.ipynb
jibanCat/math_homework
228fd61a84d03cdd8944d348e98662f1033e97ef
MIT
Math HW 1A -- Dimensional Analysis.ipynb
jibanCat/math_homework
228fd61a84d03cdd8944d348e98662f1033e97ef
MIT
Math HW 1A -- Dimensional Analysis.ipynb
jibanCat/math_homework
228fd61a84d03cdd8944d348e98662f1033e97ef
MIT
Qwen/Qwen-72B
1. YES
2. YES