From: Rimantas Liubertas Date: 2008-02-28T12:25:26+09:00 Subject: Re: Math problem <...> > And then I much prefer the algebraic solution I worked out in a few > seconds on paper when the question was first posed. <...> Father: x Daugher: y 4y - x = 0 (x + 6) / (y+6) = 3 -> 3y + 18 = x + 6 -> 3y - x = -12 Coefficients: 4, -1 3, -1 Constants 0 -12 >> require 'matrix' => true >> require 'rational' => true >> k = Matrix[*[[4, -1], [-3, 1]].map{|r| r.map{|x| Rational(x)}}].inverse => Matrix[[Rational(1, 1), Rational(1, 1)], [Rational(3, 1), Rational(4, 1)]] >> c = Matrix[[Rational(0)],[Rational(12)]] => Matrix[[Rational(0, 1)], [Rational(12, 1)]] >> (k * c).to_a.flatten.map{|e| e.to_i} => [12, 48] Regards, Rimantas -- http://rimantas.com/