Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
#lang racket
|
||||
(define a 0) (define b 7)
|
||||
(define (ε? x) (<= (abs x) 1e-14))
|
||||
(define (== p q) (for/and ([pi p] [qi q]) (ε? (- pi qi))))
|
||||
(define zero #(0 0))
|
||||
(define (zero? p) (== p zero))
|
||||
(define (neg p) (match-define (vector x y) p) (vector x (- y)))
|
||||
(define (⊕ p q)
|
||||
(cond [(== q (neg p)) zero]
|
||||
[else
|
||||
(match-define (vector px py) p)
|
||||
(match-define (vector qx qy) q)
|
||||
(define (done λ px py qx)
|
||||
(define x (- (* λ λ) px qx))
|
||||
(vector x (- (+ (* λ (- x px)) py))))
|
||||
(cond [(and (== p q) (ε? py)) zero]
|
||||
[(or (== p q) (ε? (- px qx)))
|
||||
(done (/ (+ (* 3 px px) a) (* 2 py)) px py qx)]
|
||||
[(done (/ (- py qy) (- px qx)) px py qx)])]))
|
||||
(define (⊗ p n)
|
||||
(cond [(= n 0) zero]
|
||||
[(= n 1) p]
|
||||
[(= n 2) (⊕ p p)]
|
||||
[(negative? n) (neg (⊗ p (- n)))]
|
||||
[(even? n) (⊗ (⊗ p (/ n 2)) 2)]
|
||||
[(odd? n) (⊕ p (⊗ p (- n 1)))]))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
(define (root3 x) (* (sgn x) (expt (abs x) 1/3)))
|
||||
(define (y->point y) (vector (root3 (- (* y y) b)) y))
|
||||
(define p (y->point 1))
|
||||
(define q (y->point 2))
|
||||
(displayln (~a "p = " p))
|
||||
(displayln (~a "q = " q))
|
||||
(displayln (~a "p+q = " (⊕ p q)))
|
||||
(displayln (~a "-(p+q) = " (neg (⊕ p q))))
|
||||
(displayln (~a "(p+q)+(-(p+q)) = " (⊕ (⊕ p q) (neg (⊕ p q)))))
|
||||
(displayln (~a "p+(q+(-(p+q))) = 0 " (zero? (⊕ p (⊕ q (neg (⊕ p q)))))))
|
||||
(displayln (~a "p*12345 " (⊗ p 12345)))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
p = #(-1.8171205928321397 1)
|
||||
q = #(-1.4422495703074083 2)
|
||||
p+q = #(10.375375389201409 -33.524509096269696)
|
||||
-(p+q) = #(10.375375389201409 33.524509096269696)
|
||||
(p+q)+(-(p+q)) = #(0 0)
|
||||
p+(q+(-(p+q))) = 0 #t
|
||||
p*12345 #(10.758570529320806 35.387434774282106)
|
||||
Loading…
Add table
Add a link
Reference in a new issue