#!/usr/bin/perl -w use strict; print "\n"; my $a = 1; my $b = 2; print "Apples are worth a=$a and bananas b=$b\n"; print "\n"; my $x2 = 4; my $y2 = 5; my $k = 0.6; print "I end with x2=$x2 apples and y2=$y2 bananas\n"; print "\n"; my $p2 = $x2 + $y2; my $t2 = ($x2*$a) + ($y2*$b); print "Thus i have a total of p2=$p2\n"; print "Worth a total of t2=$t2\n"; print "\n"; my $t1 = $t2; print "p1 is the total number of fruits (x1 + y1)\n"; print "t1 is the total value of fruits (equal to t2=$t1)\n"; print "\n"; print "we know that initially:\n"; print "\t x1 = k(p1) (where k=$k)\n"; print "\t x1 = k(x1 + y1)\n"; print "\t (1/k)x1 = x1 + y1\n"; print "\t ((1/k)-1)x1 - y1 = 0\n"; print "\n"; print "some other things we know:\n"; print "\t x1(a) + y1(b) = t1\n"; print "\t x1($a) + y1($b) = $t1\n"; print "\n"; print "so now we just have some sim equations:\n"; print "\t x1((1/k)-1) - y1(1) = 0\n"; print "\t x1(a) + y1(b) = t1\n"; print "\n"; print "let's flip the bottom row:\n"; print "\t x1((1/k)-1) - y1(1) = 0\n"; print "\t -x1(a) - y1(b) = -t1\n"; print "\n"; print "and devide by b=$b\n"; print "\t x1((1/k)-1) - y1 = 0\n"; print "\t x1(-a/b) - y1 = -t1/b\n"; print "\n"; print "and join the two:\n"; print "\t -x1(a) - y1(b) + $t1 = 0\n"; print "\t ...\n"; print "\t x1((1/k)-1) - y1 = x1(-a/b) - y1 + (t1/b)\n"; print "\n"; print "then we can drop y1:\n"; print "\t x1((1/k)-1) = x1(-a/b) + (t1/b)\n"; print "\n"; print "and reduce:\n"; print "\t x1((1/k)-1+(a/b)) = (t1/b)\n"; print "\n"; print "and again:\n"; print "\t x1 = (t1/b) / ((1/k)-1+(a/b))\n"; print "\n"; print "so:\n"; my $x1 = ($t1/$b) / ((1/$k)-1+($a/$b)); print "\t x1 = ($t1/$b) / ((1/$k)-1+($a/$b))\n"; print "\t x1 = $x1\n"; print "\n"; print "and then we know that:\n"; print "\t x1(a) + y1(b) = t1\n"; print "\t $x1($a) + y1($b) = $t1\n"; print "\t y1($b) = $t1 - $x1($a)\n"; print "\t y1 = ($t1 - $x1($a)) / $b\n"; my $y1 = ($t1 - ($x1* $a)) / $b; print "\t y1 = $y1\n"; print "\n"; print "so now we know:\n"; print "\t x1 = $x1\n"; print "\t y1 = $y1\n"; __END__