(define os ((fileVal "ranoth") "Schlep" 3)) (define tr (fileVal "transpose")) (define mattool ((fileVal "Matrix") '() 0 zero? 1 + - * /)) (define mxm (cadr mattool)) (define ip (cadddr mattool)) (define (mxv m v) (map car (mxm m (map list v)))) (define (sq x) (* x x)) (define (cp a B) (apply (lambda (a b c) (apply (lambda (d e f) (list (- (* b f) (* c e)) (- (* c d) (* a f)) (- (* a e) (* b d)))) B)) a)) (define (sm s v) (if (null? v) '() (cons (* s (car v)) (sm s (cdr v))))) ; cp is Gibbs cross product, ip is dot product, ; x = (A∙B)/(A∙A), y2 = ((A×B)/(A∙A))∙((A×B)/(A∙A)) (define (P A B) (let* ((a2 (ip A A))(ai (/ a2))(x (* ai (ip A B)))(x2 (sq x))(CP (cp A B)) (y2 (* ai ai (ip CP CP))) (f (sqrt (+ (sq (- x 1)) y2))) (g (sqrt (+ x2 y2)))) (* 1/2 a2 (+ (* 3 x (- f g)) f (* (- (* 2 x2) y2) (log (/ (+ (- x) 1 f)(- g x)))))))) (define (p x y2) (let* ((x2 (* x x))(f (sqrt (+ (sq (- x 1)) y2))) (g (sqrt (+ x2 y2)))) (/ (+ (* 3 x (- f g)) f (* (- (* 2 x2) y2) (log (/ (- (- x 1) f) (- x g))))) 2))) (let ((A '(2 -3.4 3)) (B '(1.3 2.3 4.1)) (m 1.6) (x 1.7) (y 0.89) (uv '(1 0 0)) (U (os)) (a (* 3 (sin 1)))(b (* 3 (cos 1)))(c (* 3 (sin 1.3)))(d (* 3 (cos 1.3)))(s 2.3)) (list (cons (P uv (list x y 0)) (p x (sq y))) (cons (P uv (list x a b)) (P uv (list x c d))) (cons (P (mxv U A) (mxv U B)) (P A B)) (cons (P (sm s A) (sm s B)) (* (sq s) (P A B))))) ; => ((0.2577326251065175 . 0.2577326251065175) ; => (0.10578948845762332 . 0.10578948845762332) ; => (7.733939380334978 . 7.733939380334975) ; => (40.91253932197204 . 40.91253932197201))