
16 Oct
2008
16 Oct
'08
4:46 a.m.
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.