Post Reply 
15C Nth Degree Polynomial Program
12-03-2019, 01:42 AM (This post was last modified: 12-05-2019 01:34 AM by 15-lennyphelan.)
Post: #1
15C Nth Degree Polynomial Program
Hello all, this program calculates a y value for any degree polynomial (between 1 and 56 theoretically, or more with a memory expansion) given an x value and matrix A containing the coefficients of the expression. This is useful for using the SOLVE and ∫yx functions, and for using Linear regression to plot secant lines. The program uses Horner's Method, which is outlined on pg. 79 of the latest 15c manual. Unfortunately, this program completely obliterates the stack so don't put anything important in there!

If you're keying this program in manually; be mindful of the USER mode instructions. A handy trick for keying the program in at some location other than 000 is to add however many R/S instructions is necessary to make the line number a multiple of 10, making it much easier to compare line numbers and ensure accurate entry. Once finished (leave them in until after a test run) you may optionally execute GTO A in run mode followed by a BST in program mode to easily position the cursor on the extraneous instructions for removal.

Usage
  • Dimension matrix A such that the area is equal to the degree of the desired polynomial. The shape of the matrix doesn't matter. For instance, a 1x6 matrix works just the same as a 2x3 matrix. The program uses the area to automatically calculate the degree of the expression.
  • As an aside, the area of the matrix is obtained with RCL DIM A and then just multiply
  • Fill the matrix with the polynomial cooeficients, with the most significant term at (1,1), in decending order
  • key an x value into the stack and run the program by calling label A. (remember you're probably already in user mode)

Code:

   001 {    42 21 11 } f LBL A
   002 {    42 16  1 } f MATRIX 1
   003 {    45 23 11 } RCL DIM A
   004 {          20 } ×
   005 {           2 } 2
   006 {    43 30  9 } g TEST x≥y
   007 {    22 48  8 } GTO .8
   008 {          30 } −
   009 {    44 48  9 } STO .9
   010 {    32 48  6 } GSB .6
   011 {    45 11  u } RCL A
   012 {          20 } ×
   013 { 42 21 48  9 } f LBL .9
   014 {    45 11  u } RCL A
   015 {          40 } +
   016 {          20 } ×
   017 { 42  5 48  9 } f DSE .9
   018 {    22 48  9 } GTO .9
   019 {          36 } ENTER
   020 {    45 11  u } RCL A
   021 {          40 } +
   022 {          40 } +
   023 {       43 32 } g RTN
   024 { 42 21 48  8 } f LBL .8
   025 {       43 35 } g CLx
   026 {           1 } 1
   027 {       43 10 } g x≤y
   028 {    22 48  7 } GTO .7
   029 {          33 } R⬇
   030 {    32 48  6 } GSB .6
   031 {    45 11  u } RCL A
   032 {          20 } ×
   033 {       45 11 } RCL A
   034 {          40 } +
   035 {       43 32 } g RTN
   036 { 42 21 48  7 } f LBL .7
   037 {          33 } R⬇
   038 {    32 48  6 } GSB .6
   039 {       45 11 } RCL A
   030 {       43 32 } g RTN
   031 { 42 21 48  6 } f LBL .6
   032 {          33 } R⬇
   033 {          36 } ENTER
   034 {          36 } ENTER
   035 {          36 } ENTER
   036 {       43 32 } g RTN

if you're using this 15c emulator and a DM15, you can simply copy this code as-is into a .15c file and upload it. Hope you enjoy!!
Find all posts by this user
Quote this message in a reply
12-03-2019, 06:08 AM
Post: #2
RE: 15C Nth Degree Polynomial Program
15-lennyphelan

Can you provide some example from this program?

Thank You

Gamo
Find all posts by this user
Quote this message in a reply
12-03-2019, 09:51 PM (This post was last modified: 12-04-2019 06:54 PM by 15-lennyphelan.)
Post: #3
RE: 15C Nth Degree Polynomial Program
(12-03-2019 06:08 AM)Gamo Wrote:  15-lennyphelan

Can you provide some example from this program?

Thank You

Gamo

No problem.

Suppose I have the function f(x)=16x^5-4x^4+8x^2-4x-9 and I want to find ∫f(x)dx from 1 to 7

The coefficients of this polynomial in order of descending significance are 16, -4, 0, 8, -4, and -9 (notice there are six of them)

I'm going to put the calc in user mode, execute f MATRIX 1, and dimension matrix A to 1x6 with 1, ENTER, 6, f DIM A, then load the coefficients into the matrix by typing 16 STO A, 4 CHS STO A, ... so on and so forth. As you're storing the constant term, the calc should display [A 1,6] as you're holding the button.

Then I simply type 1, ENTER, 7, f ∫yx A. Sit back and relax for a minute, the 15 is no supercomputer.

Mathematica tells me the answer is 301045.2, and with exact precision, so does my 15c!
Find all posts by this user
Quote this message in a reply
Post Reply 




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