AdvancedMath

Context

As a math and a Java lover, I wanted to create something that groups the 2. The solution was simple, a library that combines both in an adventure of exploration and learning.

Description

AdvancedMath is a Java library that extends java.lang.Math API to deal with some more complex tasks, like:

Functionnalities

Numbers & Operations

AdvancedMath offers tools to represent, handle and operate on:

as well as many operations like finding the GCD and solving quadratics and cubics.

Equation parsing

AdvancedMath can parse string equations and turn them into operable objects, with support for variables and usual functions (exponentiation, logarithmics, trigonometrical functions, etc). This allows to represent functions and their derivatives with an aim towards integration in the future.

Graphs

Functions can be plotted in a new window (uses java.swing and java.awt).

Obstacles

The main obstacles were and still include the strategy used to simplify an equation or a part of one.

e.g. the following subtree represents -2x + x and should result in -x

      +
     / \
    *   x
   / \
  -2  x

Solutions

A naive solution inspired by alpha pruning is implemented where different orders of nodes are tested if certain conditions are met.

This method solves the equation above, but in other cases it does not succeed. Moreover, this method does not take in consideration deeper subtrees, only ones with 2 levels, i.e. 2 levels of operators, as shown above in the example.

Another implementation simplifies the tree as it is being built, and it delivers the expected results, however simplifying trees after differentiation (in the case of a function) does not work as expected yet.

Repo

Check out the source code on GitHub