# How to calculate this set of diophantine equations

I am not a math expert nor a native English speaker, so maybe I am using wrong terminology... In this case, help me to improve my question :)

Part 1:

This is my set of equations, I have to calculate values $x_n$, $y_n$ and $z_n$. I know the values of A, B, C, Total and sums of parameters ($S_1$ = $x_1$ + $x_2$ + $x_3$, $S_2$ = $y_1$ + $y_2$ + $y_3$, $S_3$ = $z_1$ + $z_2$ + $z_3$). It is not necessary, that each equation gives us exactly the same result, but each equation should have its solution it's close to others as possible - in perfect case this would be Total/3.

$x_1A + y_1B + z_1C = \text{Total}/3$

$x_2A + y_2B + z_2C = \text{Total}/3$

$x_3A + y_3B + z_3C = \text{Total}/3$

I figured it out, this is a set of diophantine equations. I could solve this with a genetic algorithm:

• First randomly assign values $x_n$, $y_n$ and $z_n$ (just watch for the sum of parameters)
• Then mutate this numbers so, that the solution of each equation is as close to others as possible. By mutating I mean to increase one parameter while decreasing another and calculate fitness function.

Part 2:

I think the first solution should work (have to try it out though). But it was a simplification of my original problem, which is like this:

$i(x_1A + y_1B + z_1C) = \text{Total}/3$

$j (x_2A + y_2B + z_2C) = \text{Total}/3$

$k (x_3A + y_3B + z_3C) = \text{Total}/3$

Now the problem is, that I cannot just randomly increase/decrease parameters, because $i$, $j$ and $k$ could be different and hence the set of these equations could yield different solution as previous mutation. Also - i, j and k are not given, I have to calculate them by my self.

What is the best way to solve my two problems?

-
I fixed the equations; don't use asterisks, because it is considered mark-up language – Arturo Magidin Oct 27 '10 at 19:47
Thanks......... – slobodan Oct 27 '10 at 19:48

It looks like you have six equations, the three you list in the post and $x_1+x_2+x_3=y_1+y_2+y_3=z_1+z_2+z_3=S$, where $S$ is given to you. If we add the three equations in your post together we find $S(A+B+C)=Total$. As all the terms in this equation are givens, it had better be true. This will not apply to Part 2. So you have five equations in nine unknowns and it should not be hard to satisfy. If you just do a solution of linear equations you should find that there is a four parameter solution set and all the terms are rational multiples of each other. The only thing that can go wrong is for things to go negative.

For Part 2, it looks like $i, j, k$ are givens as well. You still have more unknowns than equations.

-
1. x1+x2+3 != y1+y2+y3 != z1+z2+3. Well, it could be, but not necessary. – slobodan Oct 28 '10 at 7:49
2. i, j and k are not given, so I have to calculate them also – slobodan Oct 28 '10 at 7:49
If they are not given, then you have even more flexibility and there will be even more solutions. Responding to your first, you still have nine variables and six equations. If you use the usual methods to solve this you should find a three parameter family. You might try just guessing $(x_1,x_2,x_3)=(1,0,0), \text{then} (0,1,0) \text{then} (0,0,1)$. Then calculate the other six. Any linear combination of these solutions is also a solution, so clear the fractions. You then just need to find the constraints that keep them all positive. – Ross Millikan Oct 28 '10 at 12:58