X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FPolynomials%2FOrthogonal.hs;h=13ffa995b379600336a68780d44c49532300dd55;hb=f7991d57e5eeae31a869dbef40bc1bc46b31552f;hp=4ea0b68191d1b4bc8b717e2aa156c10e2d77cb5e;hpb=ae914d13235a4582077a5cb2b1edd630d9c6ad62;p=numerical-analysis.git diff --git a/src/Polynomials/Orthogonal.hs b/src/Polynomials/Orthogonal.hs index 4ea0b68..13ffa99 100644 --- a/src/Polynomials/Orthogonal.hs +++ b/src/Polynomials/Orthogonal.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE ScopedTypeVariables #-} + -- | The polynomials over [a,b] form a basis for L_2[a,b]. But often -- the \"obvious\" choice of a basis {1, x, x^2,...} is not -- convenient, because its elements are not orthogonal. @@ -27,7 +29,7 @@ where import NumericPrelude import qualified Algebra.RealField as RealField ( C ) -import qualified Prelude as P +import Prelude () -- | The @n@th Legendre polynomial in @x@ over [-1,1]. These are @@ -63,7 +65,7 @@ import qualified Prelude as P -- >>> actual == expected -- True -- -legendre :: (RealField.C a) +legendre :: forall a. (RealField.C a) => Integer -- ^ The degree (i.e. the number of) the polynomial you want. -> a -- ^ The dependent variable @x@. -> a @@ -72,5 +74,5 @@ legendre 1 x = x legendre n x = (c1*x * (legendre (n-1) x) - c2*(legendre (n-2) x)) / (fromInteger n) where - c1 = fromInteger $ 2*n - 1 - c2 = fromInteger $ n - 1 + c1 = fromInteger $ 2*n - 1 :: a + c2 = fromInteger $ n - 1 :: a