Tweak ham() function to return results in nested list

This commit is contained in:
2025-05-29 01:14:30 +01:00
parent b471f7f70b
commit 8aff3754e0

View File

@@ -9,7 +9,7 @@ ham(L, qs) := block([ps, qdots, H],
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))));
maplist(trigsimp, maplist(lambda([q], [
diff(H, concat(p_, q)),
-diff(H, q)
]), qs)));