From e6075efc3cd1ea45721383f6f4372c45db77b847 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Thu, 29 May 2025 01:14:30 +0100 Subject: [PATCH] Write Maxima script for symbolic processing --- ham.mac | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ham.mac diff --git a/ham.mac b/ham.mac new file mode 100644 index 0000000..dcbadb2 --- /dev/null +++ b/ham.mac @@ -0,0 +1,15 @@ +/* + * Copyright (c) Camden Dixie O'Brien + * SPDX-License-Identifier: AGPL-3.0-only + */ + +ham(L, qs) := block([ps, qdots, H], + ps: maplist(lambda([q], concat(p_, q)), qs), + qdots: maplist(lambda([q], 'diff(q, t)), qs), + H: subst(solve(maplist(lambda([p,qdot], p = diff(L, qdot)), ps, qdots), + qdots), + apply("+", maplist("*", ps, qdots)) - L), + maplist(trigsimp, flatten(maplist(lambda([q], [ + 'diff(q,t) = diff(H, concat(p_, q)), + 'diff(concat(p_, q),t) = -diff(H, q) + ]), qs))));