solvequad



Write a function that will generate a list of two elements, each element is a root of the quadratic equation given by:

 ax**2 + bx + c

a,b and c are the arguments to the function


Solution

(define solvequad
  (lambda (a b c)
    (let ((bsq (* b b))
          (fac ( * 4 a c)))
      (list
       (/ (+ (- 0 b) (sqrt (- bsq fac))) 2)
       (/ (- (- 0 b) (sqrt (- bsq fac))) 2)))))