Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Another proposal for a "split" function to complement "mid"



Michel

On 18 Mar 2012, at 23:01, Michel Hack wrote:

> John Pryce wrote, replying to Vladik's efficiency concerns:
>> Earlier discussion suggested a good method to find a split point in [a,b]
>> would behave like the arithmetic mean for smallish numbers, and like
>> geometric mean for larger numbers of the same sign.  asinh is the only
>> elementary function that gives a mapping which implements that, being like
>> log(x) for x >> 1, like x for |x| small, like -log(-x) for x << -1.  That's
>> why I chose it.  But a function with similar behaviour would do, if it and
>> its inverse are cheap to evaluate and guaranteed monotone.
> 
> If you want a Level 1 definition, this seems best indeed.  But if we loosen
> the Level 2 requirement to provide a function with the same overall behaviour,
> but otherwise unspecified, the most efficient one at Level 2 works directly
> on the binary representation, by flipping some bits and taking the integer
> arithmetic mean.  Formally it means converting to sortable, averaging, then
> converting back to FP.  This would work for DFP as well as for BFP (the DFP
> sortable format is a bit more complicated, but still implementable with good
> performance -- certainly better than a hyperbolic function).
> 
> (You still need the cutoff -- probably L=1 is just fine -- near zero.)

I like this idea. I've previously written some code using convert-to-sortable, but wonder how the cutoff is to be done. Is the idea that you scale down so that L becomes the subnormal threshold? I.e. multiply [xlo,xhi] by C = REALMIN/L, do the convert and average, then divide by C?

Look at my sample output. I think they show having a variable length-scale L can be quite useful.

John