Post Reply 
newRPL - build 1255 released! [updated to 1299]
08-01-2018, 05:11 PM (This post was last modified: 08-01-2018 05:13 PM by Claudio L..)
Post: #245
RE: newRPL - build 1089 released! [update:build 1089]
Quote:The Shadow wrote:
Okay, so FACTORS now makes the first prime factor negative if the original number was negative. I assume this is just a marker, because otherwise it's flat-out wrong. (ie, it says that -180 factors as (-2)^2*3^2*5.)

Ouch, and I thought I had accomplished a lot in the 5 minutes I had available. Of course the negative sign doesn't work with even multiplicity. So I guess having -1 1 at the beginning is the only real solution.

Quote:The Shadow wrote:
Of course, this means that -1, 1, and 0 have the same factorization! Since they have no prime factors at all.

Two possible options:

1) Bite the bullet and give two outputs, one the list and the other of the unit. So -180 would give:

{ 2 2 3 2 5 1 }
-1,

and -1 would give:

{ }
-1

I'm liking this idea. While it will break compatibility, I think it goes a long way to make the result more usable.
Actually, once you break compatibility we can completely break it and output:
* A unity factor (or sign actually), which would allow the quantity being factored to even have a physical unit attached to it.
* A list of factors
* A list of multiplicity

Arguments returned in this order allow the original number to be reconstructed simply by:
Code:

^  ΠLIST *

For example factoring 180_m would output:
1_m
{2 3 5}
{2 2 1}

The "unity" contains the sign, and any other strange "features" in the original number.

Quote:The Shadow wrote:
2) Or, go all OldRPL and include the unit, but be consistent and do it every time, not just for negatives. So +180 would give:

{ 1 1 2 2 3 2 5 1 }

I dislike this option but if it's always there it's much easier to manage. Likewise, the factorization of 0 would be:

{ 0 1 }

(EDIT: There's also option 3: Once tagged objects are in, tag the list of factors with the unit.)

I think it would be cleaner to do the above.
Then 1 would be:
1
{ }
{ }
(the only catch is that ΠLIST errors on empty lists, so this case needs to be trapped separately)

or we could actually do:
1
{ 1 }
{ 1 }

to make it more manageable by programs

zero would factor as:
1
{ 0 }
{ 1 }



Quote:The Shadow wrote:
FACTORS also chokes on some non-integer inputs without throwing an error. For example, 1.5 gives:

{ 1.5 1 -1 0 }

which is more than a little odd. Other times it seems to round off first. OldRPL would actually factor rational numbers, so 1.5 (well, '3/2', but the difference isn't as important in NewRPL) would give:

{ 2 -1 3 1 }

which strikes me as much more desirable.

I thought there was a trap for integers only, but I like the factorization of the fraction!
For example 0.15 should be factored as 15 (*10^-2), then it's almost trivial to find all '2's and '5's in the list (or add them) then subtract 2 from their exponent.

Quote:The Shadow wrote:
The polynomial factorization is still a little odd. It throws an error when the polynomial has complex roots, but still manages to calculate them.
It's on purpose, (same as a square root) it throws an error if the result is complex and you are not in complex mode, other than that the results should be good, and if you set the complex mode flag the error will quietly vanish

Quote:The Shadow wrote:
I think it's more sensible to have a flag to just not break up factors irreducible in the reals. Of course, this gives headaches in the output syntax, as the vector notation breaks down. You'd need something like this for [1 0 0 1]:

{ [ 1 1 ] 1 [1 -1 1] 1 }

EDIT: I think this is desirable anyway, since currently the input and output are both vectors, but vectors interpreted in entirely different ways.
I think the output should be the same as I proposed above for reals. Forget the vectors and use lists, after all the result is a list of factors, not another polynomial.
So, we would leave the leading factor, then a list of factors (or perhaps we should change the signs and output the roots?) and then a list of multiplicities.
For example for 4*x^2-8*x+4 the output would be:
4
{ -1}
{2}

(we could also use +1 in the middle list and define the factors as (x-an) rather than (x+an) )

Then the factored polynomial equation can be easily obtained by:
Code:
 'X' ROT + SWAP ^ ΠLIST *
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
RE: newRPL - build 1089 released! [update:build 1089] - Claudio L. - 08-01-2018 05:11 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
How to participate? - erazor - 12-13-2019, 07:12 AM



User(s) browsing this thread: 26 Guest(s)