Thread: maths formula

    #1
  1. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12

    maths formula


    how could i store a mathematical expression? in a logical way...maybe using some graphs? any suggestions or links?
  2. #2
  3. 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?
    ~mgb
  4. #3
  5. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12
    not a particular expression! how does an equation editor store the data, for example?
  6. #4
  7. 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.
  8. #5
  9. onCsdfeu
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Canada
    Posts
    100
    Rep Power
    12
    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.
  10. #6
  11. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12
    i'm interested in the way they store mathematical data, like equations in their programs.
  12. #7
  13. Just another guy
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jun 2003
    Location
    Wisconsin
    Posts
    2,953
    Rep Power
    262
    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.
  14. #8
  15. Doggie
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    Seattle, WA
    Posts
    751
    Rep Power
    13
    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?
  16. #9
  17. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12
    no ... i'm looking for a method to store a mathematical expression in memory...i was thinking graphs.
  18. #10
  19. No Profile Picture
    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?
  20. #11
  21. digital sinner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    sinner's land
    Posts
    68
    Rep Power
    12
    that's what i was thinking also....but could u help me with som URLs?
  22. #12
  23. 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
  24. #13
  25. 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...

    MathML at Google
  26. #14
  27. No Profile Picture
    i'm nothing
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    70
    Rep Power
    12

IMN logo majestic logo threadwatch logo seochat tools logo