# Finding specific solution for a Diophantine equation

The equation given $$18 = 3x + 2y + 1/2z$$ where $$x, y, z$$ are positive integers and $$20 = x+y+z$$.

Now, not really knowing what to do, I multiplied through by $$2$$ to make it a linear Diophantine equation with three unknowns, this gives $$36 = 6x + 4y + z$$. Solving this using a technique I found on this site I was able to obtain a solution to the original equation: $$18 = 3(36) + 2(-36) + (-36)1/2$$.

As I said, that is a solution, but not within the constraints I want. $$x, y, z$$ are not all positive integers and they also don't sum up to $$20$$. (The correct solution is $$x = 2$$ and $$y = 2$$ and $$z = 16$$, found with Wolfram Alpha.)

Now, assuming I know how to solve linear Diophantine equations with three unknowns, how would I take the constraint into account that $$x,y,z$$ need to sum up to a certain positive integer? What would be the approach here to find the correct solution?

• Solving both, you get $5x + 3y = 16$ which may make it easier to see only one possible values for $x, y$ and then plug in $x + y + z = 20$ to find $z$. Dec 12, 2020 at 16:12

$$\begin{cases} 6 x+4 y+z=36\\ x+y+z=20\\ \end{cases}$$ Subtract the two equations $$5x+3y=16\tag{1}$$ which is satified for positive integers only by $$x=2,y=2$$.
substitute in the second equation $$z=20-x-y$$ and get $$z=16$$, so the unique solution is $$x=2,y=2,z=16$$.