module Polynomial.Chebyshev (cheby) where
import Polynomial.Basic
{-# specialize cheby :: Int -> [Int] #-}
{-# specialize cheby :: Int -> [Double] #-}
cheby :: (Integral a, Num b) => a
-> [b]
cheby :: forall a b. (Integral a, Num b) => a -> [b]
cheby a
0 = [ b
1 ]
cheby a
1 = [ b
0, b
1 ]
cheby a
2 = [ -b
1, b
0, b
2 ]
cheby a
3 = [ b
0, -b
3, b
0, b
4 ]
cheby a
4 = [ b
1, b
0, -b
8, b
0, b
8 ]
cheby a
5 = [ b
0, b
5, b
0, -b
20, b
0, b
16]
cheby a
6 = [ -b
1, b
0, b
18, b
0, -b
48, b
0, b
32 ]
cheby a
n = forall a. Num a => [a] -> [a] -> [a]
polysub (forall a. Num a => [a] -> [a] -> [a]
polymult [ b
0, b
2 ] (forall a b. (Integral a, Num b) => a -> [b]
cheby (a
nforall a. Num a => a -> a -> a
-a
1))) (forall a b. (Integral a, Num b) => a -> [b]
cheby (a
nforall a. Num a => a -> a -> a
-a
2))