(define complexp
  (lambda (a)
    (and (consp a)
	 (numberp (car a))
	 (numberp (cdr a)))))

(define c+
  (lambda (a b)
    (cons (+ (car a) (car b))
	  (+ (cdr a) (cdr b)))))

(define c-
  (lambda (a b)
    (cons (- (car a) (car b))
	  (- (cdr a) (cdr b)))))

(define c*
  (lambda (a b)
    (cons (- (* (car a) (car b))
	     (* (cdr a) (cdr b)))
	  (+ (* (car a) (cdr b))
	     (* (cdr a) (car b))))))

(define conj
  (lambda (a)
    (cons (car a) (- 0 (cdr a)))))

(define norm2
  (lambda (a)
    (car (c* a (conj a)))))

(define norm
  (lambda (a)
    (sqrt (norm2 a))))

(define c/
  (lambda (a b)
    (let ((x (c* a (conj b)))
	  (n (norm2 b)))
      (cons (/ (car x) n)
	    (/ (cdr x) n)))))

(define euler
  (lambda (r th)
    (let ((c (cos th)) (s (sin th)))
      (cons (* r c) (* r s)))))
