Re: [math-fun] We can't have mental gymnastics without a floor exercise.
Gareth> Half-integers are rounded to the nearest even integer. Exercise: Write Round using only Floor, +, -, *, /, ... SPOILER SPACE ... [...] ... SPOILER SPACE ...[ 0. I assume we are allowed constants too. 1. So we can (very familiarly) almost do it with floor(x+1/2). This rounds up all half-integers, whereas we need to round half of them down instead. 2. So it's wrong by the sum of an infinite stream of delta functions. 3. We can get an infinite stream of deltas, but not quite the right ones, by considering floor(x)+floor(-x) which is -1 except at integers where it's 0. Call this G(x). 4. So -1-G(x) is 0 except at integers where it's -1. 5. We need something that's mostly 0 except at 1/2, 5/2, ... so the correction we need is -1-G(x/2-1/4). Putting it together, we get floor(x+1/2) - floor(x/2-1/4) - floor(1/4-x/2) - 1. Two minutes of Python confirms this (well, actually two minutes of Python originally showed that I'd made a sign error, but I fixed it up). -- g Not bad. But these four terms simplify to Julian's (very unhomely) two term solution privately reported at 23:24 PST. I'm a little surprised FullSimplify fails this. --rwg
On 14/01/2014 14:02, Bill Gosper wrote:
Not bad. But these four terms simplify to Julian's (very unhomely) two term solution privately reported at 23:24 PST.
I'm a little surprised FullSimplify fails this.
It's obvious how to lose one term (move the constant 1 inside one of the floors); how do you get it down to 2? -- g
Here's what I've got: (spoiler space) [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] (spoiler space) floor((2x+1)/4)-floor((1-2x)/4) On Tue, Jan 14, 2014 at 12:17 PM, Gareth McCaughan <gareth.mccaughan@pobox.com> wrote:
On 14/01/2014 14:02, Bill Gosper wrote:
Not bad. But these four terms simplify to Julian's (very unhomely) two term solution privately reported at 23:24 PST.
I'm a little surprised FullSimplify fails this.
It's obvious how to lose one term (move the constant 1 inside one of the floors); how do you get it down to 2?
-- g
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
-- -- http://cube20.org/ -- http://golly.sf.net/ --
participants (3)
-
Bill Gosper -
Gareth McCaughan -
Tom Rokicki