From 3ab8b298bb87850babe8cfc3329c4e3630649b9b Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Wed, 14 Dec 2022 23:59:02 +0100 Subject: [PATCH] added section references --- LL1/2-the-principle-of-least-action.md | 2 +- LL1/4-the-lagrangian-for-a-free-particle.md | 4 +- ...he-lagrangian-for-a-system-of-particles.md | 8 +-- tools/pf-filter.py | 52 +++++++++++++------ 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/LL1/2-the-principle-of-least-action.md b/LL1/2-the-principle-of-least-action.md index d3e268f..02f96d8 100644 --- a/LL1/2-the-principle-of-least-action.md +++ b/LL1/2-the-principle-of-least-action.md @@ -88,7 +88,7 @@ This additivity of the Lagrangian expresses the fact that the equations of motio It is evident that the multiplication of the Lagrangian of a mechanical system by an arbitrary constant has no effect on the equations of motion. -From this, it might seem, the following important property of arbitrariness can be deduced: the Lagrangians of different isolated mechanical systems may be multiplied by different arbitrary constants. The additive property, however, removes this indefiniteness, since it admits only the simultaneous multiplication of the Lagrangians of all the systems by the same constant. This corresponds to the natural arbitrariness in the choice of the unit of measurement of the Lagrangian, a matter to which we shall return in §4 (TODO LINK). +From this, it might seem, the following important property of arbitrariness can be deduced: the Lagrangians of different isolated mechanical systems may be multiplied by different arbitrary constants. The additive property, however, removes this indefiniteness, since it admits only the simultaneous multiplication of the Lagrangians of all the systems by the same constant. This corresponds to the natural arbitrariness in the choice of the unit of measurement of the Lagrangian, a matter to which we shall return in `LL1/4`. One further general remark should be made. Let us consider two functions $L'(q,\dot{q},t) and $L(q,\dot{q},t)$, differing by the total derivative with respect to time of some function $f(q,t)$ of co-ordinates and time: diff --git a/LL1/4-the-lagrangian-for-a-free-particle.md b/LL1/4-the-lagrangian-for-a-free-particle.md index 15b539c..c0af398 100644 --- a/LL1/4-the-lagrangian-for-a-free-particle.md +++ b/LL1/4-the-lagrangian-for-a-free-particle.md @@ -2,7 +2,7 @@ title: The Lagrangian for a free particle --- -Let us now go on to determine the form of the Lagrangian, and consider first of all the simplest case, that of the free motion of a particle relative to an inertial frame of reference. As we have already seen, the Lagrangian in this case can depend only on the square of the velocity. To discover the form of this dependence, we make use of Galileo's relativity principle. If an inertial frame $K$ is moving with an infinitesimal velocity $\v{\epsilon}$ relative to another inertial frame $K'$, then $\v{v}' = \v{v}+\v{\epsilon}$. Since the equations of motion must have the same form in every frame, the Lagrangian $L(v^2)$ must be converted by this transformation into a function $L'$ which differs from $L(v^2)$, if at all, only by the total time derivative of a function of co-ordinates and time (see the end of §2 TODO LINK). +Let us now go on to determine the form of the Lagrangian, and consider first of all the simplest case, that of the free motion of a particle relative to an inertial frame of reference. As we have already seen, the Lagrangian in this case can depend only on the square of the velocity. To discover the form of this dependence, we make use of Galileo's relativity principle. If an inertial frame $K$ is moving with an infinitesimal velocity $\v{\epsilon}$ relative to another inertial frame $K'$, then $\v{v}' = \v{v}+\v{\epsilon}$. Since the equations of motion must have the same form in every frame, the Lagrangian $L(v^2)$ must be converted by this transformation into a function $L'$ which differs from $L(v^2)$, if at all, only by the total time derivative of a function of co-ordinates and time (see the end of `LL1/2`). We have $L' = L(v'^2) = L(v2+2\v{v}\cdot\v{\epsilon}+\v{\epsilon}^2)$. Expanding this expression in powers of $\v{\epsilon}^2$ and neglecting terms above the first order, we obtain @@ -41,7 +41,7 @@ The second term is a total time derivative and may be omitted. The quantity m wh LL1/4.2 ``` -It should be emphasised that the above definition of mass becomes meaningful only when the additive property is taken into account. As has been mentioned in §2 (TODO link), the Lagrangian can always be multiplied by any constant without affecting the equations of motion. As regards the function `LL1/4.2`, such multiplication amounts to a change in the unit of mass; the ratios of the masses of different particles remain unchanged thereby, and it is only these ratios which are physically meaningful. +It should be emphasised that the above definition of mass becomes meaningful only when the additive property is taken into account. As has been mentioned in `LL1/2`, the Lagrangian can always be multiplied by any constant without affecting the equations of motion. As regards the function `LL1/4.2`, such multiplication amounts to a change in the unit of mass; the ratios of the masses of different particles remain unchanged thereby, and it is only these ratios which are physically meaningful. It is easy to see that the mass of a particle cannot be negative. For, according to the principle of least action, the integral diff --git a/LL1/5-the-lagrangian-for-a-system-of-particles.md b/LL1/5-the-lagrangian-for-a-system-of-particles.md index 1b97c45..f319291 100644 --- a/LL1/5-the-lagrangian-for-a-system-of-particles.md +++ b/LL1/5-the-lagrangian-for-a-system-of-particles.md @@ -8,11 +8,11 @@ Let us now consider a system of particles which interact with one another but wi LL1/5.1 ``` -where $\v{r}_a$ is the radius vector of the $a$th particle. This is the general form of the Lagrangian for a closed system. The sum $T=\sum\mfrac{1}{2}m_av_a^2$ is called the kinetic energy, and U the potential energy, of the system. The significance of these names is explained in (§6 TODO link). +where $\v{r}_a$ is the radius vector of the $a$th particle. This is the general form of the Lagrangian for a closed system. The sum $T=\sum\mfrac{1}{2}m_av_a^2$ is called the kinetic energy, and U the potential energy, of the system. The significance of these names is explained in `LL1/6`. The fact that the potential energy depends only on the positions of the particles at a given instant shows that a change in the position of any particle instantaneously affects all the other particles. We may say that the interactions are instantaneously propagated. The necessity for interactions in classical mechanics to be of this type is closely related to the premises upon which the subject is based, namely the absolute nature of time and Galileo's relativity principle. If the propagation of interactions were not instantaneous, but took place with a finite velocity, then that velocity would be different in different frames of reference in relative motion, since the absoluteness of time necessarily implies that the ordinary law of composition of velocities is applicable to all phenomena. The laws of motion for interacting bodies would then be different in different inertial frames, a result which would contradict the relativity principle. -In §3 (TODO link) only the homogeneity of time has been spoken of. The form of the Lagrangian `LL1/5.1` shows that time is both homogeneous and isotropic, i.e. its properties are the same in both directions. For, if $t$ is replaced by $-t$, the Lagrangian is unchanged, and therefore so are the equations of motion. In other words, if a given motion is possible in a system, then so is the reverse motion (that is, the motion in which the system passes through the same states in +In `LL1/3` only the homogeneity of time has been spoken of. The form of the Lagrangian `LL1/5.1` shows that time is both homogeneous and isotropic, i.e. its properties are the same in both directions. For, if $t$ is replaced by $-t$, the Lagrangian is unchanged, and therefore so are the equations of motion. In other words, if a given motion is possible in a system, then so is the reverse motion (that is, the motion in which the system passes through the same states in the reverse order). In this sense all motions which obey the laws of classical mechanics are reversible. Knowing the Lagrangian, we can derive the equations of motion: @@ -82,6 +82,6 @@ is said to be uniform. The potential energy in such a field is evidently LL1/5.8 ``` -To conclude this section, we may make the following remarks concerning the application of Lagrange's equations to various problems. It is often necessary to deal with mechanical systems in which the interaction between different bodies (or particles) takes the form of constraints, i.e. restrictions on their relative position. In practice, such constraints are effected by means of rods, strings, hinges and so on. This introduces a new factor into the problem, in that the motion of the bodies results in friction at their points of contact, and the problem in general ceases to be one of pure mechanics (see $25 TODO link). In many cases, however, the friction in the system is so slight that its effect on the motion is entirely negligible. If the masses of the constraining elements of the system are also negligible, the effect of the constraints is simply to reduce the number of degrees of freedom $S$ of the system to a value less than $3N$. To determine the motion of the system, the Lagrangian `LL1/5.5` can again be used, with a set of independent generalised co-ordinates equal in number to the actual degrees of freedom. +To conclude this section, we may make the following remarks concerning the application of Lagrange's equations to various problems. It is often necessary to deal with mechanical systems in which the interaction between different bodies (or particles) takes the form of constraints, i.e. restrictions on their relative position. In practice, such constraints are effected by means of rods, strings, hinges and so on. This introduces a new factor into the problem, in that the motion of the bodies results in friction at their points of contact, and the problem in general ceases to be one of pure mechanics `LL1/25`. In many cases, however, the friction in the system is so slight that its effect on the motion is entirely negligible. If the masses of the constraining elements of the system are also negligible, the effect of the constraints is simply to reduce the number of degrees of freedom $S$ of the system to a value less than $3N$. To determine the motion of the system, the Lagrangian `LL1/5.5` can again be used, with a set of independent generalised co-ordinates equal in number to the actual degrees of freedom. -[^1]: This statement is valid in classical mechanics. Relativistic mechanics is not considered in this book. (See LL2, TODO link) +[^1]: This statement is valid in classical mechanics. Relativistic mechanics is not considered in this book. (See `LL2`) diff --git a/tools/pf-filter.py b/tools/pf-filter.py index 3ac5df5..5e4446f 100644 --- a/tools/pf-filter.py +++ b/tools/pf-filter.py @@ -1,11 +1,10 @@ import panflute as pf import subprocess - +import os def prepare(doc): pass - def action(elem, doc): # .md to .html # if isinstance(elem, pf.Table): @@ -17,19 +16,42 @@ def action(elem, doc): # reference if isinstance(elem, pf.Code): - book, eq = elem.text.split('/') - res = subprocess.run(["./tools/tex_to_html.sh", "inline", f"{book}/equations/{eq}.tex"], capture_output=True) - tooltiptext = res.stdout.decode('utf-8') - book, eq = elem.text.split('/') - html = f''' - - \(({eq})\) - {tooltiptext} - - ''' - # {tooltiptext} - elem = pf.RawInline(html, format='html') - return elem + # todo sketchy if/else, replace with regex + if '.' in elem.text: + # equation ref + book, eq = elem.text.split('/') + res = subprocess.run(["./tools/tex_to_html.sh", "inline", f"{book}/equations/{eq}.tex"], capture_output=True) + tooltiptext = res.stdout.decode('utf-8') + book, eq = elem.text.split('/') + html = f''' + + \(({eq})\) + {tooltiptext} + + ''' + # {tooltiptext} + elem = pf.RawInline(html, format='html') + return elem + elif '/' in elem.text: + # section ref + book, pnum = elem.text.split('/') + try: + slug = [f for f in os.listdir(book) if f.startswith(pnum)][0] + except: + return elem + title = [l for l in open(f"{book}/{slug}", 'r').readlines() if l.startswith('title:')][0] + title = title.strip("title: ") + slug = slug.replace(".md", ".html") + html = f''' + + §{pnum} {title} + + ''' + elem = pf.RawInline(html, format='html') + return elem + else: + # todo reference to whole book + return elem # load equation if isinstance(elem, pf.CodeBlock):