Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Progam based on Vieta theorem. It find quadrial equation roots.
- ; equal operation for two real-is numbers
- ; is same as checking guess = x
- (define (real-is-equal? guess x)
- (< (abs (- (guess x)) 0.001))
- )
- ; check x1 and x2 for:
- ; 1) x1 + x2 = -p
- ; 2) x1 * x2 = q
- (define (is-equation-roots? x1 x2 p q)
- (and
- (real-is-equal? (+ x1 x2) (- p))
- (real-is-equal? (* x1 x2) q)
- )
- )
- (define (root-step x1 x2 dx1 dx2 p q)
- (+ x1 x2)
- )
- (define (roots p q x-begin x-end)
- (let ((x1 0.0) (x2 0.0))
- (set! (x1 x-begin)) ; Error here
- (set! (x2 x-begin)) ; and here
- ; TODO: find loop here
- )
- )
- ; TODO: reading b and c from stdin
- ; (let ((p 0.0) (q 0.0) (x-begin 0.0) (x-end 0.0)))
- (roots -2 2 0 0)
- Запуск:
- r2d2@r2d2:~/proj/scheme/2_local_var$ mit-scheme --load vieta.scm
- MIT/GNU Scheme running under GNU/Linux
- Type `^C' (control-C) followed by `H' to obtain information about interrupts.
- Copyright (C) 2011 Massachusetts Institute of Technology
- This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- Image saved on Saturday December 3, 2016 at 9:44:07 AM
- Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116
- ;Loading "vieta.scm"...
- ;Variable required in this context: (x1 x-b)
- ;To continue, call RESTART with an option number:
- ; (RESTART 1) => Return to read-eval-print level 1.
- 2 error>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement