### Exercise 1.13: Higher-derivative Lagrangians

**a. Write a procedure to compute the Lagrange equations for Lagrangians that depend upon acceleration, as in exercise 1.10. Note that Gamma can take an optional argument giving the length of the initial segment of the local tuple needed. The default length is 3, giving components of the local tuple up to and including the velocities.**

Lagrange’s equations for Lagrangians that depend on acceleration was derived as:

```
(defn Lagrange-equations-accel [L]
(fn [q]
(let [state-path (Gamma q 4)]
(+ (D (D (compose ((partial 3) L) state-path)))
(-(D (compose ((partial 2) L) state-path)))
(compose ((partial 1) L) state-path))
)))
```

```
#'user/Lagrange-equations-accel
```

**b. Use your procedure to compute the Lagrange equations for the Lagrangian:**

```
(defn L-accel [m k]
(fn [ [_ [x] [v] [a]] ]
(- (* -1/2 m x a) (* 1/2 'k (square x)))))
(def eom-L-accel
(Lagrange-equations-accel (L-accel 'm 'k)))
(rendertexvec (let [state (up (literal-function 'x))]
((eom-L-accel state) 't)))
```

**c. For more fun, write the general Lagrange equation procedure that takes a Lagrangian that depends on any number of derivatives, and the number of derivatives, to produce the required equations of motion.**

The Generaized Lagrange’s Equation seems like a sum of alternate signed terms based on examination.