Subversion Repositories programming

Rev

Rev 100 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
63 irasnyd 1
;Written by: Ira Snyder
2
;Date:       01-13-2005
3
;Project #:  Hw 02
108 ira 4
;License: Public Domain
63 irasnyd 5
 
6
;define a function to calculate the result of the infix expression
7
; -b + sqrt( -b^2 - 4*a*c )
8
 
9
(defun QUAD-MINUS (A B C)
10
  (/ 
11
    (+ (- B) (sqrt (- (* B B) (* 4 A C))))
12
    (* 2 A)
13
  )
14
)
15
 
16
;define a function to calculate the result if the infix expression
17
; -b - sqrt( -b^2 - 4*a*c )
18
 
19
(defun QUAD-PLUS (A B C)
20
  (/ 
21
    (- (- B) (sqrt (- (* B B) (* 4 A C))))
22
    (* 2 A)
23
  )
24
)
25
 
26
;define a function that evaluates to a list containing both
27
;roots provided by the quadratic function
28
 
29
(defun QUAD2 (A B C)
30
  (list (QUAD-MINUS A B C) (QUAD-PLUS A B C))
31
)
32