Results 1 to 5 of 5

Thread: Algorithm that simplifies a notation

  1. #1
    Join Date
    Apr 2012
    Beans
    211
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Smile Algorithm that simplifies a notation

    About a year ago, I asked this question
    http://ubuntuforums.org/showthread.php?t=1996202

    And the problem was resolved thanks to 11jmb's suggestion of using shunt yard algorithm

    But if I can do a constant folding after generating the RPN ?
    for example,
    1 + 2*x + 3*x + 3
    1 2 x * + 3 x * + 3 +
    _00 = 2*3
    _01 = 1 + _00
    _02 = 3*x
    _03 = _01 + _02
    _04 = _03 + 3

    can it be simplified into
    5*x + 4 ?

    Thanks

  2. #2
    Join Date
    Jul 2010
    Beans
    92
    Distro
    Lubuntu

    Re: Algorithm that simplifies a notation

    What's the scope of your project?

    While it can be simple (though still not trivial) if you stick with only sums and products of polynomials in only one variable, the difficulty can easily escalate if you plan to consider more complex functions and different variables.
    - What do you get if you multiply six by nine?
    - 42!

  3. #3
    Join Date
    Apr 2012
    Beans
    211
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: Algorithm that simplifies a notation

    I am just curious about how to do that, not a project
    Then how is your solution ?

  4. #4
    Join Date
    Nov 2011
    Beans
    56

    Re: Algorithm that simplifies a notation

    Quote Originally Posted by DaviesX View Post
    I am just curious about how to do that, not a project
    Then how is your solution ?
    This is not going to be so trivial. This is an example of computer algebra and many of the CAS systems implement a "simplify" command.
    Why don't you just study how they did it. There are several CAS program that are open source (Axiom, Sage and others).

    I'd recommend looking at the source code of Mathomatic it's written in C and it's a command line program so things will be a bit simpler.

    Example run;

    Code:
    Secure Mathomatic version 16.0.4
    Copyright © 1987-2012 George Gesslein II.
    200 equation spaces available in RAM; 2 megabytes per equation space.
    HTML color mode enabled; manage by typing "help color".
    Reading in file specified on the command line...
    1−>  1 + 2*x + 3*x + 3
    
    #1: 4 + (2·x) + (3·x)
    
    1−> simplify;
    
    #1: 4 + (5·x)
    
    Successfully finished reading script file "/tmp/mserve.LtN25b".
    1−> 
    End of input.
    So download the source and study how he implemented the "simplify" command.

  5. #5
    Join Date
    Apr 2012
    Beans
    211
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: Algorithm that simplifies a notation

    Thanks. I'll try that

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •