/ Lisp / /
 
> 1 <

Svetozar

Members



7

: Russia
:
:

#4413   2011-06-01 17:58 GMT+3 ()      
: (-).
, DECLARE, SPECIAL, FUNCALL . !


; , ,
;
(LOAD "E:\\FUNCTION.TXT")

; PARABL_METHOD
;X0 -
;H -
;EPS -
;FN -
(DEFUN PARABL_METHOD (X0 H EPS FN)
;
;---------------------
;
(DECLARE (SPECIAL X1))
(DECLARE (SPECIAL X2))
(DECLARE (SPECIAL XN))
;
(DECLARE (SPECIAL F_X0))
(DECLARE (SPECIAL F_X1))
(DECLARE (SPECIAL F_X2))
(DECLARE (SPECIAL F_XN))
;
(DECLARE (SPECIAL Q))
(DECLARE (SPECIAL A))
(DECLARE (SPECIAL B))
(DECLARE (SPECIAL C))
(DECLARE (SPECIAL D))
(DECLARE (SPECIAL Z))
;---------------------

;
(SETQ X1 (+ X0 H))
;
(SETQ X2 (+ X0 (* 2 H)))

; FN
;
(SETQ F_X0 (FUNCALL FN X0))
(SETQ F_X1 (FUNCALL FN X1))
(SETQ F_X2 (FUNCALL FN X2))

(DO
((K 0))
; 10000 (>= K 10000)
((>= K 10000))

;
(SETQ Q (/ (- X0 X1) (- X1 X2)))
(SETQ A (+ (- (* Q F_X0) (* (* Q (+ 1 Q)) F_X1)) (* Q Q F_X2)))
(SETQ B (+ (- (* (+ (* 2 Q) 1) F_X0) (* (+ 1 Q) (+ 1 Q) F_X1)) (* Q Q F_X2)))
(SETQ C (* (+ 1 Q) F_X0))
(SETQ D (SQRT (- (* B B)(* 4 A C))))
(IF (> (ABS (+ B D)) (ABS (- B D)))
(SETQ Z (+ B D))
(SETQ Z (- B D))
)

(SETQ XN (- X0 (/ (* (- X0 X1) 2 C) Z)))
(SETQ F_XN (FUNCALL FN XN))

;
(IF (< (ABS F_XN) EPS) (SETQ K 10000))

;
(SETQ X2 X1)
(SETQ X1 X0)
(SETQ X0 XN)

;
(SETQ F_X2 F_X1)
(SETQ F_X1 F_X0)
(SETQ F_X0 F_XN)

;
(SETQ K (+ K 1))
)
;
XN
)

; PARABL_METHOD
(SETQ MINIMUM (PARABL_METHOD MIN_VAL MAX_VAL EPS (FUNCTION FUNC)))

;
(SETQ OUTPUT_STREAM (OPEN " E:\MINIMUM.TXT" : DIRECTION :OUTPUT))
;
(PRINT 'MINIMUM OUTPUT_STREAM)
(PRINT MINIMUM OUTPUT_STREAM)
;
(TERPRI OUTPUT_STREAM)
(CLOSE OUTPUT_STREAM)
> 1 <


:

0 (), 37 () :