|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
maths formula
how could i store a mathematical expression? in a logical way...maybe using some graphs? any suggestions or links?
|
|
#2
|
|||
|
|||
|
What's the expression?
__________________
~mgb |
|
#3
|
||||
|
||||
|
not a particular expression! how does an equation editor store the data, for example?
|
|
#4
|
|||
|
|||
|
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+ 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? |
|
#9
|
||||
|
||||
|
no ... i'm looking for a method to store a mathematical expression in memory...i was thinking graphs.
|
|
#10
|
|||
|
|||
|
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 is that any help? |
|
#11
|
||||
|
||||
|
that's what i was thinking also....but could u help me with som URLs?
![]() |
|
#12
|
|||
|
|||
|
MathML is potentially a very good way of storing the forumlae for long term. That's what it was designed for.
URL 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
|
|||
|
|||
|
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 |
|
#14
|
|||
|
|||
|
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > maths formula |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|