[Haskell-beginners] Mathematical Blundering
Jeffrey Drake
jeffd at techsociety.ca
Thu Oct 16 04:46:47 EDT 2008
I have defined myself a set of functions to test:
fact 1 = 1
fact n = n * (fact $ n - 1)
sine x = x - (x^3/(fact 3)) + (x^5/(fact 5)) - (x^7/(fact 7))
Where my code is 'sine' and the prelude's is sin:
*Main> sine 1
0.841468253968254
*Main> sin 1
0.8414709848078965
*Main> sine 2
0.9079365079365079
*Main> sin 2
0.9092974268256817
*Main> sine 3
9.107142857142847e-2
*Main> sin 3
0.1411200080598672
*Main> sine 4
-1.3841269841269837
*Main> sin 4
-0.7568024953079282
After 2 they seem to diverge rather rapidly, and I am not sure why. Any
ideas?
I would have thought that 4 terms would have been enough.
- Jeff.
More information about the Beginners
mailing list