Hi, 2007/3/5, Yannick Grams <yannick_grams / hotmail.com>: > 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) You can use "algebra" (http://raa.ruby-lang.org/project/algebra/) require "algebra" R = MPolynomial(Rational) x, y, z = R.vars("xyz") f0 = x + y + z - 5 f1 = x + y - z - 7 f2 = (x - y)*(x - y)*(x - y) + (y - z)*(y - z)*(y - z) - (x - z)*(x - z)*(x - z) gs = Groebner.basis([f0, f1, f2]) gs.each do |f| p f.factorize end This shows: x + y - 6 (y - 3)(y - 7)(y + 1) z + 1 These mean "z = -1, y = 3, 7, -1, x = -y + 6", And p f2.factorize #=> (-3)(x - z)(x - y)(y - z) This means you can solve this by hand. :-) Regards, Shin-ichiro HARA