HP Forums
HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () (/thread-17759.html)



HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Gil - 11-27-2021 04:42 PM

How to simplify in a program such an algebraic expression '-(2.2*X^2-3.3*X-4.4+5*X^2)'
with real coefficients, suppressing the parentheses when they occurr, but with no string manipulation ?

I tried expand, collect, simplify, distrib, all with no success.

Thanks for your help.

Gil Campart


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - John Keith - 11-27-2021 07:00 PM

Since the entire expression is inside the parentheses with a negative sign, I don't know of any command that will do the algebraic manipulation required. EVAL will simplify it somewhat:

-(7.2*X^2+-3.3*X-4.4)


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Gil - 11-27-2021 07:13 PM

A pity in a way as it does not look very satisfactory for the mind or the eyes.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - C.Ret - 11-28-2021 08:10 AM

Hello,

Doesn't the COLCT command satisfy your need ?

I got no HP-50g, but on my HP-28S the '-(2.2*X^2-3.3*X-4.4+5*X^2)' expression is transformed into '4.4-7.2*X^2+3.3*X' by pressing the COLCT soft-key from the ALGBRA menu.

Why isn't '4.4-7.2*X^2+3.3*X' not OK ?


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Albert Chan - 11-28-2021 09:30 PM

You may build the polynomial from scratch, with its coefs, [-7.2, 3.3, 4.4]

0
-7.2 'X' 2 [Y^X] * +
3.3  'X' 1 [Y^X] * +
4.4  'X' 0 [Y^X] * +

We get '-7.2*X^2 + 3.3*X + 4.4'
But, it may not worth the time to program it ...


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Carsen - 11-30-2021 07:23 AM

First, I would use the command ->Q to set the calculator to exact mode and turn the expression's real numbers into integers. Then I would execute the command PARTFRAC. This seems to simplify the expression the way you want it. Except that the numbers are integers and not real numbers.

And if you use EVAL while in approx. mode to convert the fractions back to real numbers, the parentheses you want gone will reappear. I don't know how to manipulate this.

Lastly, I do not know if PARTFRAC will accomplish what you want every time. This is because I am not that knowledgeable about the 50g's CAS and I do not know exactly what it is you are accomplishing with your program.

Hope it helps figure out your problem.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Gil - 12-01-2021 03:10 PM

Thanks for the answers, all interesting.

First, we have to suppose that we are inside a program, not knowing what kind of expression we will get, if there is or not somethings of the kind '-(...)'.

It might occurr a minus sign before (), or not.

Unfortunately, the COLCT command does not work on my HP50G EMU48 application.

Great idea with PARTFRAC, but the setting back to real, a disappointments result.

Regards,
Gil


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - ObiWanKenobi - 12-02-2021 12:03 AM

Set the Flag -114 - for example with: -114 SF

Type the formula: '-(2.2*X^2-3.3*X-4.4+5*X^2)'
Press: EVAL

Result is: 4.4+3.3*X+-7.2X^2

Edit: removed the stuff with Incr Pow. Its the same flag and -114 should be enough.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Gil - 12-02-2021 11:52 AM

I would never have thought of that!

Thanks and congratulations!

By the way, after your 2 instructions, EXPAND works now also instead of EVAL]


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - ObiWanKenobi - 12-02-2021 03:58 PM

just found, that both are the same flag.
-114 SF
is enough.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Gil - 12-07-2021 11:57 PM

Sorry to turn back to what seemed a solved question.

As I mentioned, the expression of the type
'-(...)' is unknown, it might appear in a program with -() or already been simplified.

With real coefficients for X,
we saw that -114 SF EVAL could remove the -().

How to remove on the HP49-HP50 the parentheses in
'-(100-1*X+7*X^2)'
or in '-(100.2-X+7*X^2)'
... without string manipulation?

It seems that all the suggested ideas have no effect.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - DavidM - 12-08-2021 01:05 PM

(12-07-2021 11:57 PM)Gil Wrote:  How to remove on the HP49-HP50 the parentheses in
'-(100-1*X+7*X^2)'
or in '-(100.2-X+7*X^2)'
... without string manipulation?

It seems that all the suggested ideas have no effect.

Seems like FDISTRIB should be helpful here in some way. Perhaps in combination with flag settings and/or other steps? I've also noticed that in certain situations EXPAN seems to give more intuitive results than EXPAND, though I don't know the details of its process. It may be worth some experimentation as well.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - ObiWanKenobi - 12-08-2021 11:33 PM

interesting challenge :-P

FDISTRIB helps only in some situations.

ok, i see no simple solution. If you have only polynomials of the form
a0 + a1*x^1 + a2*x^3 ... an*x^n
you can extract the parameters a0 to an and then build the formula in the right way. I have three really old UserRPL programs which can do this task (never used for something like this). Let me know, if you are interested.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - John Keith - 12-09-2021 01:09 AM

(12-08-2021 11:33 PM)ObiWanKenobi Wrote:  you can extract the parameters a0 to an and then build the formula in the right way. I have three really old UserRPL programs which can do this task (never used for something like this). Let me know, if you are interested.

Not sure if it is relevant to your question, but Albert Chan's program in this post seems to be an efficient way to extract the coefficients of a polynomial.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Gil - 12-09-2021 09:59 AM

As already published in this forum, one possible "solution" that works well with string manipulation is my program
P.ARR.VER2(long version).

Or P.ARR.VER3 (short/compact version).


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - ObiWanKenobi - 12-09-2021 11:34 AM

(12-09-2021 01:09 AM)John Keith Wrote:  Not sure if it is relevant to your question, but Albert Chan's program in this post seems to be an efficient way to extract the coefficients of a polynomial.
Nice solution, but does not work in all situations because HORNER has an ugly issue.
Example:
1. 0. HORNER is not ok (wrong type)
1 0 HORNER is ok

note, that in the second case the number 1 is a "real integer" (type 28) and in the first case it is a "real number" (type 0).
Implementing a trap for this issue is needed and then it looses some performance.


RE: HP50: how to transform '-(2.2*X^2-3.3*X-4.4+5*X^2)' w/ no () - Claudio L. - 12-09-2021 02:00 PM

(12-08-2021 11:33 PM)ObiWanKenobi Wrote:  ok, i see no simple solution...

One simple solution: install newRPL on your 50g. Type the equation and use AUTOSIMPLIFY. Works every time.