Solving a problem with a diophantine equation without trial and error.

241 Views Asked by At

I have the following problem:

A teacher bought toys for the students of an academy, every toy for a boys costs $290$ and every toy for a girl costs $330$. If he spends $24300$, how many of each one he bought?.

Now it seems that the this exercise ask to solve the diophantine equation given by $$330x+290y=24300\;\text{ where }xy\geq0$$

How can I find the solutions for this equation?. I tried with Euclides algorithm to find the $\mathrm{gcd}$ and it appears to be $10$ because $$330=(1)(290)+40\\290=(7)(40)+10 \\ 40=(4)(10)$$.

Now follows $$290-(7)(40)=10 \\ 290-(7)[330-290(1)] =10\\ 330(-7)+290(8)=10$$.

And using $24300 = 10(2430)$ I have $$330(-17010)+290(19440)=24300$$

Which means that the general solution after adding and substracting $(339)(290)$ and dividing by $10$ (the gcd here) looks like $$330(-17010 +29n)+290(19440-33n)=24300$$.

I need $xy\geq 0$, how can I find such values?. I found out that $n=587$ gives $29n=17023$ and $33n=19371$, then a solution may be $x=13$ and $y=69$.

I found the positive setting different values for $n$ and checking if $x$ and $y$ were positive, my question here is, how can this be done without trial and error?

2

There are 2 best solutions below

0
On BEST ANSWER

$330x+290y=24300\to 33x+29y=2430$
Select and isolate the term whose coëfficient is the least in absolute value.  $29y=2430-33x\to y={{2430-33x}\over{29}}\to$ $\begin{cases} (a.)&y=83-x+{{23-4x}\over{29}}\\ &or\\ (b.)&y=84-x+{{-6-4x}\over{29}}\\ \end{cases}$
(All things considered, I prefer (b.) because of the difference in size between 23 and -6.)
New variable: $A={{-6-4x}\over{29}}\to -6-4x=29A \to 4x=-6-29A$  $x={{-6-29A}\over 4}=-1-7A+{{-2-A}\over 4}$
New variable: $B={{-2-A}\over 4}\to -2-A=4B\to A=-2-4B$  $x={{-6-29(-2-4B)}\over 4}={{-6+58+116B}\over 4}=13+29B$  $y={{2430-33(13+29B)}\over{29}}={{2430-429-957B}\over{29}}=69-33B$  $\begin{matrix} 13+29B\ge 0&\to&29B\ge -13&\to&B\ge -{{13}\over{29}}&\to&B\ge 0\\ 69-33B\ge 0&\to&33B\le 69&\to&B\le 2{1\over{11}}&\to&B\le 2\\ \end{matrix}$  $0\le B\le 2$

$\begin{array}{c|rr} B&\text{girls(x)}&\text{boys(y)}\\ \hline 0&13&69\\ 1&42&36\\ 2&71&3\\ \end{array}$

0
On

Set $-17010+29n>0$ and $19440-33n>0$, solve the two inequalities and get the range of values of $n$