3 ms·
Practice, just like you learned programming. "The Context" gives you the meaning for the notation, sadly. You have to kind of know it to understand the notatio
by solmag 5y ago
Practice, just like you learned programming.
"The Context" gives you the meaning for the notation, sadly. You have to kind of know it to understand the notation properly.
- solmag 5y agoYou can also get sufficiently angry and just write out linear algebra books and what not in Agda / Coq / Lean if it pisses you off so much (I've done a bunch of exercises in Coq)
- db48x 5y agoI like the approach they took in Structure and Interpretation of Classical Mechanics, where the whole book is done in Scheme: (define ((Lagrange-equations Lagrangian) q) (- (D (compose ((partial 2) Lagrangian) (Gamma q))) (compose ((partial 1) Lagrangian) (Gamma q))))
- kergonath 5y agoI have no idea what the hell that means, and I am quite familiar with Lagrangian mechanics.
- Jtsummers 5y agohttps://mitpress.mit.edu/sites/default/files/titles/content/sicm_edition_2/chapter001.html#h1-6 https://mitpress.mit.edu/sites/default/files/titles/content/... It's formula 1.12 at the start of section 1.5 on this page converted into a Scheme representation, in section 1.5.2.
- kergonath 5y agoThanks! I am not sure I like the Scheme-like notation, but the effort is interesting.
- Jtsummers 5y agoIt's actually executable, which is part of why they wrote this particular book. The intent was to have a more uniform syntax for presenting the math and being able to (programmatically) use it.
- db48x 5y agoCompare it to D(∂₂L∘Γ[q]) − ∂₁L∘Γ[q] = 0. Of course, even that isn’t quite the standard notation; it’s using a less ambiguous notation which they invented for the book. From the preface (https://mitpress.mit.edu/sites/default/files/titles/content/sicm_edition_2/preface001.html https://mitpress.mit.edu/sites/default/files/titles/content/...): --- Classical mechanics is deceptively simple. It is surprisingly easy to get the right answer with fallacious reasoning or without real understanding. Traditional mathematical notation contributes to this problem. Symbols have ambiguous meanings that depend on context, and often even change within a given context.¹ For example, a fundamental result of mechanics is the Lagrange equations. In traditional notation the Lagrange equations are written d/dt ∂L/∂q̇ⁱ − ∂L/∂qⁱ = 0. The Lagrangian L must be interpreted as a function of the position and velocity components qⁱ and q̇ⁱ, so that the partial derivatives make sense, but then in order for the time derivative d/dt to make sense solution paths must have been inserted into the partial derivatives of the Lagrangian to make functions of time. The traditional use of ambiguous notation is convenient in simple situations, but in more complicated situations it can be a serious handicap to clear reasoning. In order that the reasoning be clear and unambiguous, we have adopted a more precise mathematical notation. Our notation is functional and follows that of modern mathematical presentations.² An introduction to our functional notation is in an appendix. Computation also enters into the presentation of the mathematical ideas underlying mechanics. We require that our mathematical notations be explicit and precise enough that they can be interpreted automatically, as by a computer. As a consequence of this requirement the formulas and equations that appear in the text stand on their own. They have clear meaning, independent of the informal context. For example, we write Lagrange’s equations in functional notation as follows:³ D(∂₂L ∘ Γ[q]) − ∂₁L ∘ Γ[q] = 0. The Lagrangian L is a real-valued function of time t, coordinates x, and velocities v; the value is L(t, x, v). Partial derivatives are indicated as derivatives of functions with respect to particular argument positions; ∂₂L indicates the function obtained by taking the partial derivative of the Lagrangian function L with respect to the velocity argument position. The traditional partial derivative notation, which employs a derivative with respect to a “variable,” depends on context and can lead to ambiguity.⁴ The partial derivatives of the Lagrangian are then explicitly evaluated along a path function q. The time derivative is taken and the Lagrange equations formed. Each step is explicit; there are no implicit substitutions. --- (define ((Lagrange-equations Lagrangian) q) (- (D (compose ((partial 2) Lagrangian) (Gamma q))) (compose ((partial 1) Lagrangian) (Gamma q)))) I think you can see that the Scheme code is a direct and very simple translation of the equation. And it has the advantage that you can run it immediately after typing it in, assuming you have a coordinate path to pass to it. They immediately go to a concrete example: (define ((L-free-particle mass) local) (let ((v (velocity local))) (* 1/2 mass (dot-product v v)))) (define (test-path t) (up (+ (* 'a t) 'a0) (+ (* 'b t) 'b0) (+ (* 'c t) 'c0))) (((Lagrange-equations (L-free-particle 'm)) test-path) 't) ⇒ (down 0 0 0) As the book says, “That the residuals are zero indicates that the test path satisfies the Lagrange equations.” They then give another example, symbolic this time: (show-expression (((Lagrange-equations (L-free-particle 'm)) (literal-function 'x)) 't)) ⇒ (* (((expt D 2) x) t) m) Quoted from https://mitpress.mit.edu/sites/default/files/titles/content/sicm_edition_2/chapter001.html https://mitpress.mit.edu/sites/default/files/titles/content/...
- solmag 5y agoI should really pick that one up some day. It had an inspiring story, I believe the author wanted to understand the classical mechanics and just wrote them out in Scheme.
- db48x 5y agoPretty much, yea. And because they are literally a 100× programmer, they also extended Scheme to support stuff you usually use a computer algebra system for at the same time. After all, if your CAS can take the derivative of a function, why can’t your programming language?
- dqpb 5y agoUltimately I think this is the right answer.