I was thinking about an update to my Polynomials AOI program to bring substantial feature improvements.

The old one (v5) featured a 1- or 2- part input. For functions that require 2 inputs (like polynomial addition, subtraction, multiplication, and division), you have to enter in operand 1 and operand 2, as polynomials, and each entry is processed into lists and a result is computed. For things like zeroes of a function, it takes one input and does the same thing.

I got an email from someone who used my program, indicating that using it on something that has a fraction (like 5x/(3x+7)) causes an error. The problem with my program is that it only supports entries in the form of ax^n, where n must be a positive integer and a must be a real number.

This gives me an *excuse to overhaul the processing system. I was thinking about a single entry system, where you can enter:

((3x+7)/(3x^3+7x-1)) + (4x2/7x)

and the calculator performs order of operations, chaining the primary operations as necessary to simplify the equation.

The Question: Should I stick to TI-Basic for this? Or would it be easier to use Axe Parser?
cross posted to omnimaga, due to Axe Parser user-base.
Stick with TI-BASIC. What do you plan to do to handle polynomial quotients, other than trying to perform polynomial long division and working with the resulting equation? I'm not sure why you would consider using Axe for floating-point math when TI-BASIC makes it so much easier.
Kerm, here's the dilemma I'm having. I'm well aware that Basic is my friend with floating point math. However, when it comes to making an expression parser that can chain polynomial operations, I find that the scrap memory areas this will use will tax the heck out of what TI-Basic can facilitate. Not saying it isn't possible, its just difficult. Axe gives me access to all the memory areas that asm does and allows me to dynamically reference, something TI Basic cannot do.

Add to that the fact that Axe does provide routines that make floating-point math easier (not as easy as Basic, but not nearly as hard as assembly), it seems like I'm going to have to make a tradeoff. And to be honest, I'd rather have the memory to play around with. In addition, I want the speed improvement of Axe, since my string processing code in TI Basic takes well over 75% of the entire computation time of the program.

I'll start another topic on discussing how to handle order of operations.
Ok. Deep Thought and I were talking the other day, and he suggested a method to me, and out of that, came an algorithm for processing a string and doing order of operations:

Create a stack with 3-entries per push:
entry 1: a length-prepended value
entry 2: the operator
entry 3: total precedence

where total precedence = base precedence + 2(nesting level)
base precedence for - and + is 0, and for * and /, its 1.
every time I hit a (, nesting level goes up one.
every time I hit a ), nesting level goes down one

So for an example, the equation: 3x + (7x + (2x -1)) is pushed as:
3x
+
0 + 2(0) = 0
**paren here, so nesting level goes up
7x
+
0 + 2(1) = 2
** another paren here
2x
-
0 + 2(2) = 4
1
n/a
n/a

My question would be: is this an effective algorithm? Also, if so, using it, how would I deal with that last entry that has no operator?
You could just use the last entry as an "end of list" byte. Your idea sounds fine to me, as i said on Omnimaga, i'd suggest working on extracting everything to get rid of the parentheses so that all you have left is to simplify things: from "4(1+7)" to "4*1 + 4*7".
Cool. So I'll work on coding tomorrow.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement