Git Product home page Git Product logo

expressioninterpretertest's Introduction

Expression Interpreter Benchmarks

This was a small learning project on how to implement Math Expression Parsing and how to work with it. Additionally we had to analyze the runtime for different operations like calculating the result of a function of x and the comparism between different Expression Trees. (Note: The tests are distributed over the different branches)

Test 1 (Branches Master & Test 3)

The first test was just crudely implementing an Expression Tree and checking the equivalence between two trees by just calculating both functions for some random x values and checking if they yield the same result.
First Benchmark
As you can see we have a quite good time for a single calculation. But to ensure the equivalence we have to use more values. It seems to be running in O(logn) with n being the number of equality tests.

Test 2 (Branch Test 2)

In the second test we tried to implement some simplification Algorithm, to simplify a given Expression Tree in order to check the equality more easily. But we quickly abandoned this approach as we found a good library to do this for us (see test 3).

Test 3 (Branch Test 4)

In the third test we experimented with the library AngouriMath. It has methods to parse, evaluate and simplify Mathematical Expression in a wide range. It also can handle Differentiation, Integration, Limits, Complex Numbers and much more. Here are the Benchmarks we did:
Second Benchmark
The CheckEqualityHard Test checked the equality of two very hard (and long) polynomials - One in the factorized form and the other in the standard form.
The CheckEqualityEasy Test did the same thing, but with a much easier polynomial pair.
Lastly the Calculate Test just tested the runtime to evaluate the same polynomial like in Test 1 with one Value.

Results

The results were pretty clear to favour the Library implementation as it has a way better runtime in checking the equality. Nevertheless we learned a lot about implementing Expression Trees, how to Tokenize and Parse them and much more!

expressioninterpretertest's People

Contributors

alexmi-ha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.