August 9th, 2003, 03:44 PM

maths formula
how could i store a mathematical expression? in a logical way...maybe using some graphs? any suggestions or links?
August 11th, 2003, 10:39 AM

August 11th, 2003, 10:51 AM

not a particular expression! how does an equation editor store the data, for example?
August 11th, 2003, 11:01 AM

You could try unicode. That has code for mathematical symbols I believe.
August 11th, 2003, 12:13 PM

If you've got the space and resources, a simple way would be to get some mathematical software, like Mathematica, Maple or MATLAB. They're expensive, but well worth it.
August 11th, 2003, 01:04 PM

i'm interested in the way they store mathematical data, like equations in their programs.
August 11th, 2003, 01:17 PM

The programs all store equations by writing to the hard drive...
I think you might want to try to be a bit more informative in your question, I'm not sure what you're getting at.
August 11th, 2003, 02:17 PM

It's often stored in reverse polish notation as well as plain text.
ie:
5(xy)+3
5xy3+
read as:
push 5
push x
push y
subtract
subtract
push 3
add
pushes are done onto a stack, operators pop the last two values, do their operation, then push the answer back on.
Is this what you're looking for?
August 11th, 2003, 04:22 PM

no ... i'm looking for a method to store a mathematical expression in memory...i was thinking graphs.
August 11th, 2003, 05:59 PM

i'm not sure what the terminology is  but you use a binary tree with a main node for the final operator to be processed and the left and right nodes representing the operands / sub equations similarly / recursively ... i don't really know how to explain it.
a simple example: 3+7*4 would look like thisand you can use this structure to parse, store and evaluate expressions in unary and binary operators
is that any help?
August 12th, 2003, 04:06 AM

that's what i was thinking also....but could u help me with som URLs?
August 12th, 2003, 11:57 AM

MathML is potentially a very good way of storing the forumlae for long term. That's what it was designed for.
http://www.w3.org/Math/
In memory you could use an binary tree as mentioned earlier (though for certain math expressions you might need an Mway tree). To compute the result you do a traversal.
An alternative to an Mway tree is to specify that a complex expression has to have a leaf node <twoargs> which contains 2 arguments. This is a cludge.
Look up mway trees, Binary trees and Abstract Syntax Trees (ASTs) in google. They are very common data structures documented everywhere.
You could also manipulate the MathML document tree with dom or sax.
HTH,
Aragon
August 12th, 2003, 12:00 PM

This looks good like a good place to start looking for MathML links (the standards are good for reference but not for learning), in particular the second and sixth entries...
MathML at Google
August 12th, 2003, 07:42 PM
