Example on pge 20 fails to evaluate. Any ideas why?

111 views
Skip to first unread message

rmz

unread,
Dec 2, 2010, 7:21:40 PM12/2/10
to Structure and Interpretation of Classical Mechanics
Hi guys

I'm looking at this excellent book and considering if I should spend
som serious time with it. However, of I am going to that I should have
some confidence that the scheme code is reasonably stable. I want to
learn mechanics, not debug scmutils exiting as that may be. So to
check things out I try to work through the examples in the book to see
if they work as advertised, but unfortunately I'm finding that they
are not. Below are my notes. I've tried to be very accurate when
copying from the book, but of course mistakes can have been made. I
haven't spotted any though. Anyone haveany ideas?

(Rmz)



;;;
;;; This file is a file that I use for scheme notes when
;;; reading "The Structure and Interpretation of
;; Classical Mechanics" (sicm). (Rmz)
;;;


(define ((L-free-particle mass) local)
(let ((v (velocity local)))
(* 1/2 mass (dot-product v v))))


(define q
(up (literal-function 'x)
(literal-function 'y)
(literal-function 'z)))

;; use (component i) to get components out
;; time = (coordinate 0)
;; coordinate = (component 1)
;; velocity = (component 2)

;; Some examples from p. 18o

(print-expression ((D q) 't))

(print-expression ((Gamma q) 't))

(print-expression
((compose (L-free-particle 'm) (Gamma q)) 't))

(show-expression
((compose (L-free-particle 'm) (Gamma q)) 't))

(show-expression
((compose (L-free-particle 3) (Gamma q)) 't))


;; This defines action based on the Lagrangeian:
;; The integral along from t1 to t2 of the Lagrangeian,
;; the action principle is that the real action will be along the
;; minimum action path.

(define (test-path t)
(up (+ (* 4 t) 7)
(+ (* 3 t) 5)
(+ (* 2 t) 1)))

(define (Lagrangian-action L q t1 t2)
(definite-integral (compose L (Gamma q)) t1 t2))

;; Now page 20 in SICM states that evaluating:
;; (Lagrangian-action (L-free-particle 3.0) test-path 0.0 10.0)
;; should yield ther result 435, but that isn't what i'm getting.
;; I'm getting
;The object (*number* (expression (* 1.5 (+ (* ((derivative z) 2.5)
((derivative z) 2.5)) (* ((derivative y) 2.5) ((derivative y) 2.5)) (*
((derivative x) 2.5) ((derivative x) 2.5)))))), passed as the first
argument to integer->flonum, is not the correct type.
;; and this callstack(from the debugger):
; S0 (integer->flonum (quote (*number* (expression (* 1.5 (+ (*
((derivativ ...
; S1 (f i)
; S2 (sigma-flo fx 0 (minus-fixnum n 1))
; S3 (f (head s))
; S4 (map-stream (second-euler-maclaurin f a b) *new-bs-steps*)
; >S5 (integrate-open-finite f a b *integrate-n* eps)

;; At this point I'm wondering if the definite-integral method is
broken
;; so I run a simple test, but that seems to be working fine.
(define (identity x) x)
(definite-integral identity 1 19) ; works fine


;; In all that wasn't so encuraging. Any ideas about what might be
wrong?

;; I'm running on OSX with mit-scheme from macport
; Image saved on Thursday November 25, 2010 at 10:37:15 AM
; Release 9.0.1 || Microcode 15.1 || Runtime 15.7 || SF 4.41 || LIAR/
C 4.118 || Edwin 3.116
; Scmutils compled locally and dumped to a band.

Christoffer Karlsson

unread,
Dec 7, 2010, 6:25:04 AM12/7/10
to Structure and Interpretation of Classical Mechanics
Hi!

The example works for me on Mac OS X (10.5) with scmutils (prepackaged
with MIT Scheme) installed from http://groups.csail.mit.edu/mac/users/gjs/6946/scmutils-tarballs/
. (Release 7.7.90.+)

Christoffer Karlsson

unread,
Dec 7, 2010, 6:37:10 AM12/7/10
to Structure and Interpretation of Classical Mechanics
Oops. It seems as if the version I have installed is an older one (I
have a 32 bit version) that isn't available at that adress anymore.
Sorry.

On 7 Dec, 12:25, Christoffer Karlsson <christoffer.karls...@gmail.com>
wrote:
> Hi!
>
> The example works for me on Mac OS X (10.5) with scmutils (prepackaged
> with MIT Scheme) installed fromhttp://groups.csail.mit.edu/mac/users/gjs/6946/scmutils-tarballs/

Bjørn Remseth

unread,
Dec 7, 2010, 10:33:20 AM12/7/10
to si...@googlegroups.com
Ok, thanks. This is useful info. I'll use it the next time I have time
to sit down with this problem :-) I'll report back when I figure out
how to get this working.

> --
> You received this message because you are subscribed to the Google Groups "Structure and Interpretation of Classical Mechanics" group.
> To post to this group, send email to si...@googlegroups.com.
> To unsubscribe from this group, send email to sicm+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sicm?hl=en.
>
>

--

                                                 (Rmz)

Reply all
Reply to author
Forward
0 new messages