You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 18, 2025. It is now read-only.
Here's a reproduction. You can make this test fail by redefining the existing seq:- in series.cljc:
(defn-seq:- [f g]
(seq:+ f (seq:negate g)))
to:
(defn- seq:- [f g]
(map g/- f g))
Which should be equivalent. Here's the check:
(deftestch6-repro"Evaluate this in sicmutils.sicm.ch6_test.cljc. If you defined g/- for series as `(map g/- f g)`, this test will return a different result than if you define it as `(g/+ f (g/negate g))`."
(let [L (e/Lie-derivative
(fn [[_ theta ptheta]]
(/ (*-1 'a 'b (sin theta))
ptheta)))
H (e/series
(fn [[_ _ ptheta]]
(/ (square ptheta)
(*2 'a)))
(fn [[_ theta _]]
(*-1 'e 'b (cos theta))))
E (((exp (* 'e L)) H) (up 't 'theta 'p_theta))]
(is (= '((/ (expt p_theta 2) (*2 a))
0
(/ (* a (expt b 2) (expt e 2) (expt (sin theta) 2))
(*2 (expt p_theta 2))))
(take3 (simplify E))))))
With the existing definition, the 3rd sequence entry is
(/ (* a (expt b 2) (expt e 2) (expt (sin theta) 2)) (*2 (expt p_theta 2)))
If you use the new g/- based definition, you pick up a factor of 3 in the third term:
(/ (*3N a (expt b 2) (expt e 2) (expt (sin theta) 2)) (*2 (expt p_theta 2)))