支点(重装上阵)

来源:互联网 发布:sql语句优化面试题 编辑:程序博客网 时间:2024/05/01 23:39

支点(重装上阵)

//复杂的解待定系数的参数的过程

X=1+1/X

设a(n)=1+1/a(n-1)

另外设

A(n)=a(n)*A(n-1)

Go

A(n)={ 1+1/a(n-1) }*A(n-1)

Go

A(n)=A(n-1)+A(n-1)/a(n-1)

Go

A(n)=A(n-1)+A(n-2)

为fibs数列。

Go

a(n)=A(n)/A(n-1)

 

FIBS数列

 

 

 

(defun pow (num count)

(if (> count 0)

      (* num (pow num (- count 1) ) )

    1

)

)

 

(defun  expr (n)

(if (eq  n 1)

       1

   (+  1  (/  1.0   (expr  (- n  1) ) ))))

 

 

 

(setq  A    (/ (sqrt  5)  5.0))

(setq  B    (- 0  A) )

 

 

(defun  formula (n)

(+  (* A  (pow (/  (+  1  (sqrt 5) ) 2.0 ) n))

    (* B  (pow (/  (-  1  (sqrt 5) ) 2.0 ) n))))

 

(defun  test (n)

(if (> n 0)

  (progn 

       (print (/ (formula (1+ n) ) (formula n) ))

       (print  'compare)

       (print (expr  n ))

       (test  (- n 1) ))

  (print 'over)))

 

(test  10)

原创粉丝点击