Skip to content

Latest commit

 

History

History
134 lines (110 loc) · 7.69 KB

README.md

File metadata and controls

134 lines (110 loc) · 7.69 KB

Computer-Algebra-System

This project is a Computer Algebra System coded in Java from scratch in Eclipse. It supports the majority of elementary functions.

Table of Contents

This Computer Algebra System contains:

  • A tree-like data structure to hold any mathematical expression in memory. This is the core of the project and consists of more than half of it.
  • Parsing any mathematical expression into this expression tree.
  • Display this mathematical expression beautifully using LaTeX.
  • Simplify this expression algebraically.
  • Find the symbolic partial derivatives of the mathematical expression with respect to any variable.
  • Graph the expression in both 2D and 3D.

Future improvement goals:

  • Complex numbers
  • Taylor expansions
  • Root finding via the Bisection method or Newton's method
  • Limits
  • Numerical integration using Riemann Sums or Monte Carlo methods
  • Symbolic single variable and multivariate integration
  • Numerical differentiation
  • Probabilistic and statistical distributions
  • Linear Algebra support
  • Differential Equations support

Presentation

Here is what it looks like when you launch the application. It defaults to the 3D plotter, you can switch between the 3D and 2D plotter with the button on the top left corner.

Here is an example with a single function of form . You can see the system automatically computes both partial derivatives of the function and gives the option to plot them too. Functions of form are possible too if you switch to the 2D plotter. You can plot as many functions as you want, the true limit is either memory or GPU power.


How to use it & What is Supported

To zoom in or out of a model, use the mouse wheel. To move the model, click and drag the model around. This applies for both the 2D and 3D contexts.

Here is a list of the supported functions, examples of syntax the parser can understand and how the parser will translate it. For most functions, brackets are necessary if the input is not a number or a variable. Unless stated otherwise. Also, the multiplication symbol is mandatory. An expression like "5x" will not work, it must be "5 * x".

  • Trigonometry: Write the name of the function and then the input.

    • sin, cos and tan. Examples:
      • "x * sinx" →
      • "a * x * cos(b * x)" →
    • arcsin, arccos, arctan. Examples:
      • "arcsin(a / x)" →
      • "arctanx" →
    • csc, sec, cot. Examples:
      • "csc(x + b)" →
      • "cotx + b" →
  • Floor function. Examples:

    • "floorx" →
    • "floor(x^2 + 15)" →
  • Ceiling function. Examples:

    • "ceilx" →
    • "ceil(5 * b * x + 0.1)" →
  • Absolute value function. Examples:

    • "absx" →
    • "abs5" →
    • "abs(x^3)" →
  • Logarithms. Examples:

    • "lnx" →
    • "ln(5 * x)" →
    • "logx" →
    • "log_5_x" →
    • "log_(x + 5)_(x^2)" →    This is a complex log, rarely ever used but supported.
  • Minimum and Maximum functions. These functions take an arbitrary amount of inputs (more than 1 of course). You must surround those inputs in brackets and separate them with commas. Examples:

    • "min(5, x)" →
    • "max(x, x^2, 15, 7 / x)" →
    • "min(17, x^3, 7 * x)" →
  • Modulus function. This function must take 2 inputs, separated by a comma and must be surrounded by brackets. Examples:

    • "mod(x, 5)" →   or   %   for computer scientists
    • "mod(x^2 + x + 15, x^3)" →
  • Sign function. Examples:

    • "signx" →
    • "sign(-x + 5)" →
    • "sign(x^2 + x - 15)" →

References & Dependencies

The following are all the libraries I used. They are all included inside the project as raw Jar files. Eclipse took care of adding them to the Build Path. I downloaded all the dependencies with a Windows 64-bit system in mind. You might need to download other jars if you run another type of system.

  • LWJGL3: I used LWJGL to render the 2D and 3D plots. The native files are included in the lib/natives folder.
  • ImGui: I used Dear ImGui for the GUI. This is a C++ library so I used the JNI based binding from here. The native jars ar in the lib/natives folder.
  • Commons Lang from Apache Commons: I used this library for String manipulation in the parser.
  • JLatexMath: I use this library to render the latex code generated by the mathematical expression or the expression tree.
  • Jafama: I used this library for faster math calculations than the built in Math class in java. You can see here the differences between Jafama's FastMath class and Java's Math class.