
Thank you all for the friendly and helpful explanations - and for your patience. The solution to my problem is finally f :: Double -> Double f i = (-1)**i/(2**(10*i)) * (-2^5/(4*i+1)-1/(4*i+3)+2^8/(10*i+1) -2^6/(10*i+3)-2^2/(10*i+5)-2^2/(10*i+7)+1/(10*i+9)) I had confused (^) and (**) due the fact that 1.0/2^16 or (-1.0)^2/2^16 are accepted. The important sentence in the Gentle Tutorial is " It is easy to forget at times that numerals are overloaded, and not implicitly coerced to the various numeric types," (Finding my errors was made somewhat difficult due to the following messages I got while testing my conjectures: *Main> let i=1 in 1/2^i 0.5 *Main> let i=1 in i/2^i Ambiguous type variable `a' in these top-level constraints: `Fractional a' arising from use of `/' at <interactive>:1 `Integral a' arising from use of `^' at <interactive>:1 :-) ) Thanks to all. Marc Charpentier

On Wed, 3 Nov 2004, Marc Charpentier wrote:
Thank you all for the friendly and helpful explanations - and for your patience.
The solution to my problem is finally
f :: Double -> Double f i = (-1)**i/(2**(10*i)) * (-2^5/(4*i+1)-1/(4*i+3)+2^8/(10*i+1) -2^6/(10*i+3)-2^2/(10*i+5)-2^2/(10*i+7)+1/(10*i+9))
I'm afraid that you will get problems with negative bases if you use (**) which allows fractional exponents. If your function is inherently based on positive integer i's you should stick to (^). Further on you should use one of the signatures f :: Integral a => a -> Double f :: Int -> Double f :: Integer -> Double to assert statically that f will always receive integer values and nothing else.
participants (2)
-
Henning Thielemann
-
Marc Charpentier