Interactive Scheme Mechanics
(define (html-show-expression x)
(display (string-append "<exp>" (expression->tex-string (simplify x)) "</exp>"))
x)
(set! print-expression html-show-expression)
Scheme Mechanics, also known
as SCMUTILS
, has been used in two books, Structure and Interpretation of Classical Mechanics (), and Functional Differential Geometry (, ).
Exercise 1.9a ()
We derive the Lagrange equations for the following system. A particle of mass \(m\) moves in a two-dimensional potential \(V(x, y) = (x^2 + y^2)/2 + x^2 y - y^3/3\), where \(x\) and \(y\) are rectangular coordinates of the particle. A Lagrangian is \(L(t; x, y; v_x, v_y) = (1/2) m (v_x^2 + v_y^2) - V(x, y)\).
(define (Lagrange-eq L q)
(- (D (compose ((partial 2) L) (Gamma q)))
(compose ((partial 1) L) (Gamma q))))
(define (V x y)
(+ (/ (+ (square x) (square y)) 2)
(* (square x) y)
(- (/ (cube y) 3))))
(define ((L m) local)
(let ((vx (ref (velocity local) 0))
(vy (ref (velocity local) 1))
( x (ref (coordinate local) 0))
( y (ref (coordinate local) 1)))
(- (/ (* m (+ (square vx) (square vy))) 2)
(V x y))))
(define (q t)
(up
((literal-function 'x) t)
((literal-function 'y) t)))
(print-expression
((Lagrange-eq (L 'm) q) 't))
)