特殊形式的差分方程(改变)
改变前面的计算方式,假设0<a(1)<1,
形式为a(n)=2*a(n-1)^2-1的差分方程,根据以前的经验:
可以转化为a(n-1)=(sqrt (/ {1+a(n)} 2 ) )
如果当a(1)=0.99 (即小于1的时候,可以用三角函数确定值,这样也就能确定每一个a(n)的值了。
下面是程序验证:
这里只有一个限制条件了0<a(1)<1,
下面写程序来证明:
(defun pow (num count)
(if (or (> count 1) (eq count 1) )
(* num
(pow num
(- count 1) ) )
1))
(defun slayer ( count)
(if (or (> count 1) (eq count 1) )
(* count
(slayer
(- count 1) ) )
1))
(defun look ( init left right value )
(if (< (abs (- (cos init ) value )) (/ 1.0 10000000))
init
(if (< (cos init ) value )
(look (/ (+ init left ) 2.0) left init value)
(look (/ (+ init right ) 2.0) init right value))))
(setq a1 (look 0.1 0 (/ pi 2 ) 0.99))
(defun expr (n x)
(if (eq n 1)
(cos x)
(- (* 2
(pow (expr (1- n)
x)
2))
1)))
(defun test (n)
(if (> n 0)
(progn
(print (expr n a1))
(print 'compare)
(print (cos (* (pow 2
(1- n))
a1)))
(test (- n 1)))
(print 'over)))
(test 10)
注意这里如果a1为0.5时候,将很快就出现都为负数的情况。
同样我们也能注意到如果a1>1将基本不会出现任何负数,那怎样求它的公式???