-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocal.rkt
More file actions
43 lines (32 loc) · 825 Bytes
/
Copy pathLocal.rkt
File metadata and controls
43 lines (32 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#lang racket
(define a 3)
(define (roots-local2 a b c)
(define (roots-helper d)
(cons ( / (+ (- b) d) (* 2 a))
( / (- (- b) d) (* 2 a))))
(roots-helper (sqrt (- (square b) (* 4 a c))))
)
(define y (lambda (x) x))
(define (roots-local a b c)
;;local = b^2 - 4ac
(define (local)
(sqrt (- (square b) (* 4 a c))))
(cons ( / (+ (- b) (local)) (* 2 a) )
( / (- (- b) (local)) (* 2 a) ))
)
(define (roots a b c)
(cons (/ (+ (- b)
(sqrt (- (* b b) (* 4 a c))))
(* 2 a))
(/ (- (- b)
(sqrt (- (* b b) (* 4 a c))))
(* 2 a))
))
(define square
(lambda (x)(* x x)))
(define (root a b c)
(cons (quad + a b c) (quad - a b c))
)
(define (quad op a b c)
(/ (op (- b) (sqrt (- ((lambda (x)(* x x)) b) (* 4 a c)))) (* 2 a))
)