

> {-# LANGUAGE TypeSynonymInstances #-}







f(0)=1

f(1)=1

f(n)=f(n-1)+f(n-2) for n>=2





> f 0 = 1

> f 1 = 1

> f i = f (i-1)+f (i-2)







s(n)=s(n-1)+s(n-2) for n>=2





> class VectorSpace v where

> zero :: v

> (.*) :: Float -> v -> v

> (.+) :: v -> v -> v

> (.-) :: v -> v -> v

> v .- w = v .+ ((-1) .* w)



> type Sequence = Int -> Float



> instance VectorSpace Sequence where

> zero _ = 0

> a .* v = \i -> a*v i

> v .+ w = \i -> v i+w i



> epsilon f = f 0







> type Sequence2 = Int -> Int -> Float



> instance VectorSpace Sequence2 where

> zero _ _ = 0

> a .* v = \i j -> a*v i j

> v .+ w = \i j -> v i j+w i j







> (<*>) :: Sequence -> Sequence -> Sequence2

> v <*> w = \i j -> v i*w j







> d :: Sequence -> Sequence

> d v i = v (i+1)







<f(D)g(D),s>=<f(D)⊗g(D),Δ(s)>





> delta :: Sequence -> Sequence2

> delta v = \i j -> v (i+j)







> extract :: Sequence2 -> Sequence

> extract f i = let k = i `div` 2 in f k (i-k)





ij



Σ j f(i+j)t jk =δ ik for i,j,k=0,1.





Σ j,k f(i+j)t jk f(k+l)=f(i+l) for j,k=0,1;i,l≥0





Σ j,k <Di⊗Dl,t jk Djf⊗Dkf=e<Di+l,f>



jk



Δ(f)=2s⊗f-f⊗Df-Df⊗f+Df⊗Df





> bootstrap :: [Float] -> Sequence -> Sequence

> bootstrap xs v i = if i<length xs then xs!!i else v i



> f' :: Sequence

> f' = bootstrap [1,1,2,3] $ extract $ 2 .* (f' <*> f') .- (f' <*> (d f')) .- ((d f') <*> f') .+ ((d f') <*> (d f'))







> let's_go_slow = map f [0..]

> let's_go_faster = map f' [0..]



