Try to solve this math problem.

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Jothaxe

Golden Member
Apr 5, 2001
1,274
0
0
Ooooooooooo, good problem! I think I can explain the formal way to solve it and other more general problems like this.

As has been noted by some above, there is no way to write down three equations and solve using algebra.

You can get 2 equations of three variables and reduce them to 1 equation of two variables however.

This one equation of two variable whose solutions are integers is known as the linear diophantine equation, and is a fun thing that you learn about in number theory. There are nifty algorithms for solving in terms of integers, but I wont explain these.

The way I solve is like this lettting #cows = a, #pigs = b, and #chickens = c:

a + b + c = 100 --> c = 100 - a - b
10a + 3b + c/2 = 100 --> 20a + 6b + c = 200

combine to get:

19a + 5b = 100 <-- this is the linear diophantine equation, because we want both a &amp; b to be integers.

A clever trick is to look for a more fundamental solution to

19c + 5d = 1 <-- note that we have reduced the 100 to just 1.

Clearly one solution to this is

c = -1
d = 4

Why does this help us?

because if

19c + 5d = 1 --> 100[19c + 5d] = 100[1]

simplifying tells us that:

19(100c) + 5(100b) = 100

.so a = 100c = -100
and b = 100d = 400

is a solution in the integers! Now we just need the solution to be nonzero which is easy

notice that 19(a+5x) + 5(b-19x) = 100 also, for all values of x, and if x is an integer then our solution is also still an integer.

Then we need:

5x - 100 >= 0 and...
400 - 19x >= 0

solving these inequalities gives:

x >= 20
x <= 400/19 (or 21.05...) and


this means x = 20 or 21 since it must be an integer.

So for x = 20 we get one solution:

a = 0
b = 20
c = 80

and for x = 21 we get the second solution

a = 5
b = 1
c = 94

That is all.


I look back and see that you want positive solutions as opposed to nonegative solutions so you can throw out the x = 20 answer and stick with the second one.

The nice thing about using this method is that it can generate the general form of all solutions a,b,c in the integers without the positive constraint and there is no guesswork needed. Also, it works for arbitrarily large and unwieldy initial parameters.
 

mundania

Senior member
Jun 17, 2000
921
0
0


<< notice that 19(a+5x) + 5(b-19x) = 100 also, for all values of x, and if x is an integer then our solution is also still an integer. >>



good stuff.. but i'm still a bit confused... where did the (a+5x) come from?
 

nd

Golden Member
Oct 9, 1999
1,690
0
0
Jothaxe,

I like that a lot. The basic idea seems to be substitution and manipulation in such a way where the solutions are only integers -- eliminating the need for the constraint.
 

Jothaxe

Golden Member
Apr 5, 2001
1,274
0
0


<<

<< notice that 19(a+5x) + 5(b-19x) = 100 also, for all values of x, and if x is an integer then our solution is also still an integer. >>



good stuff.. but i'm still a bit confused... where did the (a+5x) come from?
>>



This is a good question to ask because I got lazy and skipped a step or two. Let me fill in:

The thing to notice is that 19(5x) + 5(-19x) = 0 for all values of x, right?

This means we can take the original solution:

19(-100) + 5(400) = 100 and add this clever form of zero!

+ [19(5x) + 5(-19x) = 0] = 0 to get

19(5x-100) + 5(400-19x) = 100 <-- here our final a = 5x-100 and b = 400-19x

does this make sense now?


It was confusing for me to use a and b in the equation that mentioned, because they are not the final a,b we are looking for, so much as a valid a,b that give an integral solution that is not necessarily positive... I would have used a.sub.0 and b.sub0 if I was doing this on paper, but as you know, notation is severely limited on the forum. ;)
 

Jothaxe

Golden Member
Apr 5, 2001
1,274
0
0


<< cierto >>



acbimmer, I dont know much Spanish. Does this mean something like &quot;right on&quot; or &quot;true&quot; ?
 

Jothaxe

Golden Member
Apr 5, 2001
1,274
0
0


<< The basic idea seems to be substitution and manipulation in such a way where the solutions are only integers -- eliminating the need for the constraint. >>



Yes, that is generally the concept. If you like those tricks, then you would really like the general method you can use for solving the diophantine equation in more difficult cases. There are some really neat tricks for this!

For example say you have:

101x + 73y = 1


How the hell do you go about solving this for integers x &amp; y ?


If anybody wants to know how to solve this, maybe I will move it into a new thread, and teach you a trick or two that are really simple, but incredibly cool: one of them is even called &quot;the magic box!&quot;

-jothaxe

*spelling edit*
 

mundania

Senior member
Jun 17, 2000
921
0
0
ahhhh... i get it now.. this is pretty interesting stuff (to me at least). yeah.. start a new thread on these cool tricks. these equations were like the ones that you just gave up on back in high school.
 

Josh

Lifer
Mar 20, 2000
10,917
0
0
phew, I'm tired of simataneous (sp?) linear equations, they rack my brain :)
 

Jothaxe

Golden Member
Apr 5, 2001
1,274
0
0


<< ahhhh... i get it now.. this is pretty interesting stuff (to me at least). yeah.. start a new thread on these cool tricks. these equations were like the ones that you just gave up on back in high school. >>



Ok, I will pose the question in a new thread... ;)