In designing a chess heuristic, I find myself with three coefficients to balance to define the AI behavior. The heuristic is like below:
$$h = c_1v + c_2m + c_3p$$
Where $v$ is material value, $m$ is board control, and $p$ is pawn values. Each $c$ are some coefficients to manipulate each of the three values, $c_1, c_2, c_3 \in \mathbb{Z}$. This balancing act works as a ratio:
$c_1 = 1, c_2 = 2, c_3 = 1$ means the AI will favor board control over the other two, $c_1 = 3, c_2 = 1, c_3 = 1$ means the AI will hugely favor material over the other two, a negative $c_1$ will actively try to lose pieces, et cetera.
I run into issues when you choose incredibly high coefficients such that the heuristic can exceed the highest possible integer allowable by the system. But I have a solution: reducing the coefficients so the ratio remains the same, but the coefficients become small.
Consider $c_1 = 2, c_2 = 4, c_3 = 6$ will have the same behavior as a $c_1 = 1, c_2 = 2, c_3 = 3$. The ratio $2:4:6$ is equivalent to the ratio $1:2:3$.
What arithmetic or algebra can I employ to reduce these numbers algorithmically?
There are several approaches.
You can just use floating point numbers and divide by the smallest to make it $1$.
You can use Euclid's algorithm on one pair, then with that result and the third to find the greatest common divisor, which you can divide out.
The problem with finding the greatest common divisor is that it might not be very large. How accurately are the coefficients determined? If the ratio is changed by a part in $1000,$ do you care? Pretending that they are big numbers, if your coefficients were $123$ and $277$, the greatest common divisor is $1$ so you can't divide anything out. But $\frac 94\cdot 123=276.75$, so the error of using $4$ and $9$ is only a part in $1000.$ If this is acceptable, you could just divide by the smallest, then look at the decimals to see if they look close to any fraction you recognize, then multiply by that and round.