Author Topic: PROGRAM: Polynomial Math Utility  (Read 10000 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
PROGRAM: Polynomial Math Utility
« on: December 02, 2012, 12:15:09 pm »
Works on :  TI-83+, TI-83+ SE, TI-84+, TI-84+ SE, TI-84+ emulator on the TI-Nspire.

At the bequest of an old friend of mine, I fished out my really old Synthetic Division program. I was intending to fix it up and ship it off, but when I saw the code, I realized how much of a mess it was. So I started over. This program started off as a Polynomial Division Utility, but it evolved into a suite for doing all four standard operations with polynomials. The algorithms are brand new, and optimized with help from an old high school friend.

This program can theoretically handle polynomials of infinite size, but, of course, bounded by your memory. See the speed test information at the bottom. It can also handle fractional coefficients. The input occurs in descending exponent order, where the calculator will first prompt you for the number of terms in the polynomial, so for x^3+x-1, you say '4' (without the single quotes  ;) ). You will then be prompted for the coefficients. You would input 1 for exponent 3, 0 for exponent 2, 1 for exponent 1, and -1 for exponent 0. Repeat this procedure for the second operand. Alternatively, for either operand, you may enter a value of '-1', '-2', or '-3' (without the single quotes  ;) ). '-1' loads the last Operand 1 you used, '-2' loads the last Operand 2, and '-3' loads the last result. You may supply either of these three arguments at either operand prompt without issue.

Speed Test

DISCLAIMER: This speed test was conducted on my own hardware, a TI-84+ SE, running OS 2.43. While you may experience results close to this, no two pieces of hardware are exactly alike.

for Multiplication
a 19-term times a 19-term: done in 3.35 seconds.
a 37-term times a 37-term: done in 7.52 seconds.
a 73-term times a 73-term: done in 16.94 seconds.

for Division:
a 73-term divided by a 37-term: done in 7.39 seconds.
a 37-term divided by a 19 term: done in 3.21 seconds.
a 19-term divided by a 9-term: done in 1.88 seconds.
« Last Edit: December 03, 2012, 08:42:41 pm by ACagliano »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: PROGRAM: Polynomial Math Utility
« Reply #1 on: December 03, 2012, 06:25:24 pm »
I don't have much actual need for this (for a little while, anyways), but this should prove useful to many others :D

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: PROGRAM: Polynomial Math Utility
« Reply #2 on: December 03, 2012, 06:27:56 pm »
ha, sounds nice! is it for the 84+?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: PROGRAM: Polynomial Math Utility
« Reply #3 on: December 03, 2012, 08:41:12 pm »
Yes. Let me actually add a compatability list.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: PROGRAM: Polynomial Math Utility
« Reply #4 on: December 05, 2012, 10:14:09 am »
Update: I just finished an update to this program that adds an input parser to the polynomial inputs. Gone is the system where you input the number of terms, then input the coefficients one-by-one. In its place, you simply input the polynomial...as a string. The program parses it and builds the lists.

Also, instead of rendering as a list, I created a list parser that converts the result back into a string, containing the polynomial. Currently testing the heck out of it. Will upload when I get my computer back from the apple store.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: PROGRAM: Polynomial Math Utility
« Reply #5 on: December 05, 2012, 04:53:41 pm »
Wooh, that will be great for regular users who may or may not understand how to input a list!

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: PROGRAM: Polynomial Math Utility
« Reply #6 on: December 07, 2012, 03:40:03 pm »
UPDATED PROGRAM

As of this version, you may input polynomials directly as you see them, not by lists or by inputting coefficients one-by-one. For instance, you may type in x^2+2x+1 as operand 1 and x+1 as operand 2 and the program will function as it did in the prior version. The output has been similarly changed. Please note, however, that negative exponents and fractional exponents are not supported.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: PROGRAM: Polynomial Math Utility
« Reply #7 on: December 07, 2012, 03:53:23 pm »
Hmm, division at least appears to be broken. For example, try X^4-1 divided by x-1. It should be x3+x2+x+1, but it outputs x3+x3+x+1.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: PROGRAM: Polynomial Math Utility
« Reply #8 on: December 07, 2012, 04:04:18 pm »
I successfully reproduced it. Currently fixing.


Edit: Fixed.
« Last Edit: December 07, 2012, 04:13:03 pm by ACagliano »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: PROGRAM: Polynomial Math Utility
« Reply #9 on: December 07, 2012, 04:13:15 pm »
The input is nice, though, and I am glad that you support the use of 2 and 3 :) I remember I wrote a synthetic division program a few years ago, but it only took list inputs.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: PROGRAM: Polynomial Math Utility
« Reply #10 on: December 07, 2012, 04:26:15 pm »
Thanks. Better yet, I'm trying to design an asm version. Can someone help me out with routines for all 4 operations... multiplying, adding, dividing, and subtracting 16.8 fixed point numbers...?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: PROGRAM: Polynomial Math Utility
« Reply #11 on: December 07, 2012, 04:28:14 pm »
Hmm, so it is going to support non-integers?

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: PROGRAM: Polynomial Math Utility
« Reply #12 on: December 07, 2012, 04:49:42 pm »
Yes, that's why im looking for 16.8 numbers (where 16-bits are the integer part and 8-bits are the decimal part).

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: PROGRAM: Polynomial Math Utility
« Reply #13 on: December 07, 2012, 04:57:07 pm »
Basically, for division, it would be the same as 24-bit division by a 24-bit number (think about it, 11.8/22.3 = 118/223). You would need to adjust the algorithm a little to bring in the extra 8 bits of precision, though. For multiplication, you would do the same thing as 24-bit multiplication , but remember that the bottom 16 bits will be the decimal part and the upper 32 bits will be the integer part. If the upper 16 bits are not 0 or -1 (-1 is in case you have signed numbers), then there was an overflow, and if the lower 8 bits have bit 7 set, then you will need to round up the number (if you want rounding done). Addition and subtraction are also straightforward and is just like adding or subtracting 24-bit numbers.

Keep in mind that for division and multiplication, you will want to keep track of sign. I also think that there is a problem with how I described multiplication, but hopefully calc84maniac or Runer112 will be able to tell you how to do that properly.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: PROGRAM: Polynomial Math Utility
« Reply #14 on: December 08, 2012, 02:20:40 am »
Would you make the program have some hook then and call at some function on the homescreen (like symbolic)? That would be epic! :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!