-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpendulum.html
122 lines (87 loc) · 3.69 KB
/
pendulum.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html>
<head>
<title>Pendulums in HTML5</title>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<script src=pendulum-simple.js></script>
<script src=pendulum-rational.js></script>
</head>
<body>
<p>On this page I'll try to solve the two-dimensional pendulum problem
in various ways, including using <a href=https://en.wikipedia.org/wiki/Rational_trigonometry>rational trigonometry</a>.</p>
<p>I'll start with the simple pendulum, and then maybe the double one and arbitrary long ones.</p>
<h1>The Simple Pendulum</h1>
<h2>Lagrangian</h2>
<p>The Lagrangian for the simple pendulum is
$$ L = \frac{1}{2}mv^2 - mgh $$
</p>
<p>With an appropriate choice of length, mass and time units, this
can be written:
$$ L = \frac{v^2}{2} - h $$
</p>
<h2>Using trigonometric functions</h2>
<p>With trigonometric functions, the speed \(v\) and elevation \(h\) become respectively \(\dot\theta\) and
\(1 - \cos(\theta)\).
</p>
<p>The Lagrangian then becomes:
$$ L = \frac{\dot{\theta}^2}{2} + \cos(\theta) - 1 $$
</p>
<p>The <a href="https://en.wikipedia.org/wiki/Euler%E2%80%93Lagrange_equation">Euler-Lagrange equation</a>
then gives:</p>
$$ \ddot{\theta} = -\sin{\theta} $$
<p>which we can turn into a first order derivative by considering
\(\dot{\theta}\) as an additional variable.</p>
<canvas id="simple-pendulum" width=400 height=300>
Your browser can't display canvas.
</canvas>
<script>simple_pendulum();</script>
<h2>Using only rational numbers</h2>
<p>We're going to use the following rational parametrization of the circle:</p>
$$\mathrm{M}(\mu) = (\frac{1-\mu^2}{1+\mu^2}, \frac{2\mu}{1+\mu^2}) $$
<p>The squared speed becomes:
$$ v^2 = \frac{4\dot{\mu}^2}{(1+\mu^2)^2} $$
</p>
<p>Thus the Lagragian is now:
$$ L = \frac{2\dot{\mu}^2}{(1+\mu^2)^2} + \frac{1-\mu^2}{1+\mu^2} $$
</p>
<p>And the Euler-Lagrange equation:</p>
$$ \frac{d}{dt}(\frac{4\dot{\mu}}{(1+\mu^2)^2}) =
-\frac{8\dot{\mu}^2\mu}{(1+\mu^2)^3}
- \frac{4\mu}{(1+\mu^2)^2}
$$
<p>...turns into:</p>
$$ \frac{4\ddot{\mu}}{(1+\mu^2)^2} - \frac{16\dot{\mu}^2\mu}{(1+\mu^2)^3} =
-\frac{8\dot{\mu}^2\mu}{(1+\mu^2)^3}
- \frac{4\mu}{(1+\mu^2)^2}
$$
$$ \ddot{\mu} = \frac{2\dot{\mu}^2\mu}{1+\mu^2} - \mu $$
<h3>Dealing with the exceptional case</h3>
<p>The naive approach described above has a major issue : it can not
deal with full swings. Indeed the point
$$\lim_{\mu\to\infty}\mathrm{M}(\mu) = (-1, 0)$$
can never be reached with that parametrization.</p>
<p>A simple solution is to switch to a different parametrization when it is
expedient.
$$\mathrm{N}(\nu) = (-\frac{1-\nu^2}{1+\nu^2}, -\frac{2\nu}{1+\nu^2}) $$
</p>
<p>The dynamics should not be much different. Indeed there is only one sign change:
$$ \ddot{\nu} = \frac{2\dot{\nu}^2\nu}{1+\nu^2} + \nu $$
</p>
<p>We then need a relation between \(\mu\) and \(\nu\). That is, we must find the solution
to
$$ \mathrm{M}(\mu) = \mathrm{N}(\nu)$$
</p>
<p>It is not too hard to see that
$$ \nu = -\frac{1}{\mu} $$
is a solution, as long as \(\mu\ne 0\).
</p>
<p>From this we can derive the relation between the generalized velocities
$$ \dot{\nu} = \frac{\dot\mu}{\mu^2},\qquad \dot{\mu} = \frac{\dot\nu}{\nu^2} $$
<canvas id="rational-pendulum" width=400 height=300>
Your browser can't display canvas.
</canvas>
<script>rational_pendulum();</script>
</body>
</html>