The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP 50g - collect by powers of x
Message #1 Posted by Juraj O. on 17 Feb 2013, 4:40 a.m.

Is there an easy way to collect terms by powers of a variable in an expression? Ie. I have an expression on the stack that looks like this

A*x^2 + A*x + B*x + C

I want to group (something like GROUP(expression,'x') ) it by powers of x, so that it looks like this:

Ax^2 + (A+B)x + C

and not something like A(x^2 + x) + Bx + C which FACTOR/SIMPLIFY/COLLECT often give me.

It would also be handy if I could extract a vector of coefficients from that expression: [A A+B C].

If anyone knows how to do this please help me out :)

      
Re: HP 50g - collect by powers of x
Message #2 Posted by Juraj O. on 17 Feb 2013, 5:11 a.m.,
in response to message #1 by Juraj O.

I think I've found what I was looking for - the function A->P from the Polynomial library by Steen S. Schmidt.

      
Re: HP 50g - collect by powers of x
Message #3 Posted by Ronald Williams on 17 Feb 2013, 9:50 a.m.,
in response to message #1 by Juraj O.

For A*X^2 + A*X + B*x + C try using COLLECT alone and you should get A*X^2 + (B+C)*X + C as desired.

            
Re: HP 50g - collect by powers of x
Message #4 Posted by Mike Morrow on 17 Feb 2013, 10:38 a.m.,
in response to message #3 by Ronald Williams

Quote:
For A*X^2 + A*X + B*x + C try using COLLECT alone and you should get A*X^2 + (B+C)*X + C as desired.

That would be quite remarkable!

                  
Re: HP 50g - collect by powers of x
Message #5 Posted by Ronald Williams on 17 Feb 2013, 3:57 p.m.,
in response to message #4 by Mike Morrow

I'm using a real HP50g with rom 2.15 and flag settings as follows: { # 80800002452103F0h # 0h # 8018000002000010h # 0h } and COLLECT works for me!

                        
Re: HP 50g - collect by powers of x
Message #6 Posted by Mike Morrow on 17 Feb 2013, 4:25 p.m.,
in response to message #5 by Ronald Williams

I doubt that any HP 50G will indicate that

   A*X^2 + A*X + B*X + C   =    A*X^2 + (B+C)*X + C 

as your message number 3 in this thread proposes. :-) (unless A = C)

Edited: 17 Feb 2013, 4:38 p.m.

                        
Re: HP 50g - collect by powers of x
Message #7 Posted by Gerson W. Barbosa on 17 Feb 2013, 4:26 p.m.,
in response to message #5 by Ronald Williams

He was talking about the typo: A*X^2 + (B+C)*X + C instead of A*X^2 + (A+B)*X + C.

                        
Re: HP 50g - collect by powers of x
Message #8 Posted by Ronald Williams on 17 Feb 2013, 6:57 p.m.,
in response to message #5 by Ronald Williams

Good catch! Thank you Gerson I did miss type the expression. As you correctly pointed out it should have been A*X^2 + (A+B)*X + C and Mike I missed your subtle humor in post #4.

      
Re: HP 50g - collect by powers of x
Message #9 Posted by Juraj O. on 17 Feb 2013, 7:16 p.m.,
in response to message #1 by Juraj O.

I was wondering one more minor thing which doesn't really deserve its own thread. Is it possible in the equation editor, with an expression already entered, to add a factor or a summand on the beginning, from the left?

Ie. we have bc. Is it possible to multiply it by a from the left, so we have abc? Same question for b+c, so we get a+b+c?

      
Re: HP 50g - collect by powers of x
Message #10 Posted by C.Ret on 18 Feb 2013, 5:09 a.m.,
in response to message #1 by Juraj O.

Hi,

On my HP-28S,

'A*x^2 + A*x + B*x + C' x 2 TAYLR returns 'C + (A+B)*x + A*2/2*x^2'

then a simple COLCT leads to '(A+B)*x + A*x^2 + C'

Is that expression close enough to the expected format?

Edited: 18 Feb 2013, 5:11 a.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall