Post Reply 
(Free42, DM42, HP42S): Polynomial Solver
03-14-2022, 01:16 PM
Post: #1
(Free42, DM42, HP42S): Polynomial Solver
The solver PSOL (pmatsolver.raw) uses a two column matrix PMAT to evaluate and solve for polynomials in the form:

p(x) = a1 * x^b1 + a2 * x^b2 + a3 * x^b3 + ...

And PMAT has the matrix in the form of:

[ [ a1, b1 ],
[ a2, b2 ],
[ a3, b3 ] ... ]

The PMAT Matrix

The solver uses the matrix PMAT. It must first be created in order for the solver to work.

Creating PMAT:
1. Enter the number of terms, press [ENTER], type 2, press [(shift)] [ 9 ] (MATRIX), select (NEW).
2. Select (EDIT) from the MATRIX menu.
3. Enter the coefficients and powers. For terms in form of a1, the power is 0. For terms in form of x^b1, the coefficient is 1.
4. Press [EXIT], then [STO], [(shift)] [ENTER] (ALPHA), type PMAT.

Editing PMAT:
1. Enter the number of terms, press [ENTER], type 2, press [(shift)] [ 9 ] (MATRIX), select (DIM), select PMAT.
2. From the MATRIX menu, select (EDITN), select PMAT. Be sure to select EDITN (edit named matrix).

Running the Solver

To run the polynomial solver:
1. Press [(shift)] [ 7 ] (SOLVER), select PSOL.
2. To evaluate p(x), enter a value for X and solve for P.
3. To solve for x, enter a value for P, enter a guess for X, and then press X again to solve.

Note: The solver cannot evaluate 0^0. Hopefully you can see why in the program listing.

The best part of PSOL is that you don't have to use just integer powers, put powers in order, or fill in zero terms (0 * x^n).

Examples

Example 1: p(x) = 2 + 3x^1.5 - x^3

Set PMAT to be this:
[ [ 2, 0 ],
[ 3, 1.5 ]
[ -1, 3 ] ]

If X = 2.2, solving for P yields 1.141382003
If P = -1, solving for X with guess 0 yields 2.431407988

Example 2: p(x) = -5 + 3*x + 4*x^2

Set PMAT to be this:
[ [ -5, 0 ],
[ 3, 1 ],
[ 4, 2 ]]

If X =1.8, solving for P yields 13.36
If P = 10, solving for X with guess 0 yields 1.59746673


DM42/HP42S (Free42) Solver Program PSOL

Code:
00 { 65-Byte Prgm }
01 LBL "PSOL"
02 MVAR "P"
03 MVAR "X"
04 0
05 STO 01
06 INDEX "PMAT"
07 RCL "PMAT"
08 DIM?
09 R↓
10 STO 02
11 LBL 00
12 RCLEL
13 RCL "X"
14 J+
15 RCLEL
16 Y↑X
17 ×
18 STO+ 01
19 RCLIJ
20 R↓
21 RCL 02
22 X=Y?
23 GTO 01
24 J-
25 I+
26 GTO 00
27 LBL 01
28 RCL 01
29 RCL- "P"
30 .END.
Visit this user's website Find all posts by this user
Quote this message in a reply
03-14-2022, 03:06 PM
Post: #2
RE: (Free42, DM42, HP42S): Polynomial Solver
(03-14-2022 01:16 PM)Eddie W. Shore Wrote:  Example 1: p(x) = 2 + 3x^1.5 - x^3

Strictly speaking, this is not a polynomial.
The exponent \(1.5\) is not an integer.
Find all posts by this user
Quote this message in a reply
03-21-2022, 11:37 AM (This post was last modified: 03-21-2022 11:37 AM by Namir.)
Post: #3
RE: (Free42, DM42, HP42S): Polynomial Solver
(03-14-2022 03:06 PM)Thomas Klemm Wrote:  
(03-14-2022 01:16 PM)Eddie W. Shore Wrote:  Example 1: p(x) = 2 + 3x^1.5 - x^3

Strictly speaking, this is not a polynomial.
The exponent \(1.5\) is not an integer.

Thomas,

This is a Shammas Polynomial (which I precented in HHC2008) and can be found on my website (see the Shammas Polynomials hyperlink at this web page.
Find all posts by this user
Quote this message in a reply
03-21-2022, 02:29 PM
Post: #4
RE: (Free42, DM42, HP42S): Polynomial Solver
(03-21-2022 11:37 AM)Namir Wrote:  This is a Shammas Polynomial
Of course, you are free to name a class of functions whatever you want.
But if a common mathematical term like polynomial is used, people will likely assume that Shammas Polynomials are a special kind of polynomial.

And with that, they will assume that these functions have the same properties.

For example that \(f: \mathbb{R} \to \mathbb{R}\)
However, for \(f(x) = x^\tfrac{1}{2}\) this is not the case since the square root for negative numbers is undefined.

Or then that \(f\) is differentiable on \(\mathbb{R}\) which is also not the case for \(f(x) = x^\tfrac{1}{2}\) at \(x = 0\).

Also that polynomials compose, which means that the composition of a polynomial with another polynomial is again a polynomial.
But this is not the case either, e.g. for:
\(
f(x) = (1 + x)^\frac{1}{2}
\)

However, if you call \(x^\tfrac{1}{2}\) a polynomial, it's just plain wrong.
Find all posts by this user
Quote this message in a reply
03-21-2022, 08:28 PM (This post was last modified: 03-21-2022 09:18 PM by Namir.)
Post: #5
RE: (Free42, DM42, HP42S): Polynomial Solver
The classical Polynomials have the powers of the terms change by integer values, usually 1, and sometimes 2. Think of this change in power as a tempo. The Shammas Polynomials alter this tempo. If you read my notes on my web sites you will see that I use Shamrmas Polynomials to have a slower tempo—that is increase the powers by non-integer values that are usually less than 1. I use this scheme to perform curve fitting that has the values of the highest terms rise to powers that are less than in classical polynomials with the same number of terms. The advantage here is that rounding errors are reduced.

I used my last name in naming the Shammas Polynomial to avoid using more general names that may, sooner or later, conflict with similar polynomial names proposed by others.

I am a person who thinks outside the box, sometimes as a math heretic. To me that is far more satisfactory that focusing endlessly on topics like calculating pi, logarithm of 2, or calculating trig functions. If mathematicians like Gauss had our powerful computers and software, he would have come up with non-integer polynomials and called them Gauss Polynomials—and the topic would be a classic by now. In fact I have noticed advances on topics like non-integer derivatives and integrals. I am sure these new advances leave some of us scratching their heads!
Find all posts by this user
Quote this message in a reply
Post Reply 




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