1. #### maths formula

how could i store a mathematical expression? in a logical way...maybe using some graphs? any suggestions or links?
2. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2003
Location
The Netherlands
Posts
122
Rep Power
12
What's the expression?
3. not a particular expression! how does an equation editor store the data, for example?
4. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2003
Location
The Netherlands
Posts
122
Rep Power
12
You could try unicode. That has code for mathematical symbols I believe.
5. 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.
6. i'm interested in the way they store mathematical data, like equations in their programs.
7. 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.
8. It's often stored in reverse polish notation as well as plain text.

ie:
5-(x-y)+3
5xy--3+
push 5
push x
push y
subtract
subtract
push 3

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?
9. no ... i'm looking for a method to store a mathematical expression in memory...i was thinking graphs.
10. No Profile Picture
epl
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2001
Location
Dublin
Posts
413
Rep Power
14
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 this
Code:
``` +
/ \
3 *
/ \
7 4```
and you can use this structure to parse, store and evaluate expressions in unary and binary operators

is that any help?
11. that's what i was thinking also....but could u help me with som URLs?
12. No Profile Picture
aragon
Guest
Devshed Newbie (0 - 499 posts)
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 M-way tree). To compute the result you do a traversal.

An alternative to an M-way tree is to specify that a complex expression has to have a leaf node <two-args> which contains 2 arguments. This is a cludge.

Look up m-way 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
13. No Profile Picture
aragon
Guest
Devshed Newbie (0 - 499 posts)
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...