http://www.perlmonks.org?node_id=521419


in reply to Re^2: Obtaining terms in an expansion
in thread Obtaining terms in an expansion

I believe that to solve this you would need to create two separate arrays; one to contain the variables on the left side of the equation and another to contain each of the terms on the right side of the equation.

Since you know that you will have 2**N variables on the left side, you would want to create an array named, say, Variable{2**N-1) to contain the variables. Then you would create an array Terms[2**N-1] to contain the terms generated by multiplying the polynomials.

I don't think one would need a two dimensional array. The first part of the program code could pop up a message box asking what N is, and then it would create the arrays as I described above. Then the code would step through array Variable[] multiplying the variables as appropriate and placing the resulting terms into array Terms[]. So the expansion is simply the sum of the elements of array Terms[2**N-1].

I am new to Perl so I am still working on actual code to do what I've described. I think that this is an interesting problem.

jdporter added code and p tags