Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^3: Obtaining terms in an expansion

by Scott7477 (Chaplain)
on Jan 06, 2006 at 06:46 UTC ( #521419=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://521419]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2021-05-08 14:30 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (96 votes). Check out past polls.