From: Rick DeNatale Date: 2007-03-06T02:00:23+09:00 Subject: Re: Maths in Ruby On 3/5/07, M. Edward (Ed) Borasky wrote: > Yannick Grams wrote: > > Hello to everyone! > > > > I have a mathematic problem I need to solve, and it involves finding > > the values of three consecutive numbers, x, y and z. I need to be able > > to find every instance of these from negative one million (-1,000,000) > > up to one million (1,000,000). They must follow the following equations: > > > > x + y + z = 5 > > x + y - z = 7 > > (x - y)(x - y)(x - y) + (y - z)(y - z)(y - z) = (x - z)(x - z)(x - z) > > > > I'm completely and utterly stumped. > Well, one of the reasons you might be stumped is that the problem as > posed does not appear to have a solution. I punched it in to Maxima: > > (%o1) z+y+x=5 > (%o2) -z+y+x=7 > (%o4) (y-z)^3+(x-y)^3=(x-z)^3 > (%i5) solve([%o1,%o2,%o4], [x,y,z]); > (%o5) [[x=-1,y=7,z=-1],[x=3,y=3,z=-1],[x=7,y=-1,z=-1]] > > Since one of the equations is a cubic, there are three solutions, and > they are all smallish integers. But they are *not* consecutive! > > Are you sure about the problem statement? You can tell there's no solution for consecutive X, Y, Z just from looking at that last equation, each side boils down to a different constant: Since the numbers are consecutive y = x + 1 z = y + 1 Then: x - y = x - (x+1) = -1 y - z = y - (y+1) = -1 x - z = x - (y+1) = x - (x+1+2) = -2 so: (x-y)(x-y)(x-y) + (y-z)(y-z)(y-z) = (-1)(-1)(-1) + (-1)(-1)(-1) = -2 but: (x - z)(x - z)(x - z) = (-2)(-2)(-2) = -8 -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/