
On Mon, Feb 27, 2006 at 03:11:35PM +0100, Henning Thielemann wrote:
To: Matthias Fischmann
cc: haskell-cafe@haskell.org From: Henning Thielemann Date: Mon, 27 Feb 2006 15:11:35 +0100 (MET) Subject: Re: [Haskell-cafe] rounding errors with real numbers. On Sun, 26 Feb 2006, Matthias Fischmann wrote:
I think this is the well-known issue of using real numbers in decimal representation on a machine that thinks binary, but I don't know what to do with it, and some of you maybe do.
I want to shift+stretch a list of doubles into a given interval. example:
| x1 = [2, 3, 4, 5, 10] | y1 = normInterval x1 0 1 | => y1 = [0.0,0.125,0.25,0.375,1.0]
The function that does this looks something like this:
| normInterval :: [Double] -> Double -> Double -> [Double] | normInterval ps lower upper = map (\ x -> (x - oldLower) * stretch + lower) ps
Is there --------------------------------------------------------------^ a cancellation problem?
what's a cancellation problem?
Maybe you should use a kind of convex combination, that is
(x-oldLower)*a + (oldUpper-x)*b
i don't quite understand this either. is 'x' an old element in my input list and your expression is the corresponding new element? then how does the resulting curve relate to the original one? does this keep the ratios between distances between elements in the list intact? (this is the property that i am interested in.) but it sounds intriguing. perhaps i should play with this a little and find out myself. thanks, matthias