I'm in the process of writing an equation simplification program. In this program, they want to use binomial and trinomial theorems.
With binomial extension:
(x + y) ^ r
Sum (k → r) x ^ [rk] y ^ [k],
where k is 0 and r is the degree of the binomial.
I can do it like this:
for (k=0; k<=r; k++) {
x_degree=r-k;
y_degree=k;
}
Otherwise, if I want to implement trinomial theorems, I must satisfy the constraints of the form:
(a + b + c) ^ n
Sum (n selects i, j, k) a ^ i b ^ jc ^ k,
where n is the degree of trinomial and i + j + k = n.
I have been thinking about this for a while, but I cannot understand something better than looping through all the possible combinations, as shown below:
for (int i=0; i<=n; i++)
for (int j=0; j<=n; j++)
for (int k=0; k<=n; k++) {
if((i+j+k)==n) {
find_coefficient(i,j,k);
set_degree_values(i,j,k);
proceed();
}
}
So, my questions are: how to implement three-dimensional extension without going through all possible combinations of degrees?
Thank.