Mathematical Expression Parser, Evaluator & SVG Plotter (Java)
FonctionsPlotterSVG is a Java-based project that parses, evaluates, converts, and visualizes complex mathematical expressions.
It supports Infix and Reverse Polish Notation (RPN), builds an Abstract Syntax Tree (AST), evaluates expressions with variables, and generates:
- 📊 SVG plots of mathematical functions
- 🌳 AST visualizations using Graphviz DOT
The project is designed with a compiler-like architecture, focusing on parsing, abstraction, and mathematical modeling.
- Arithmetic, logical, comparison, unary, binary, and ternary operators
- Trigonometric, logarithmic, exponential, and power functions
- Variable support via parameter mapping
- Infix ↔ RPN conversion
- AST generation and visualization
- SVG function plotting with:
- axes & grid
- legend
- multiple functions
- custom scaling
Languages & Tools
- Java 17+
- JavaScript (expression export)
- SVG
- Graphviz (DOT)
Computer Science Concepts
- Tokenization (Lexer)
- Parsing (Infix & RPN)
- Abstract Syntax Tree (AST)
- Sealed Interfaces & Enums
- Expression evaluation
- Tree traversal
- Compiler-style design
.
├── Bool.java
├── Vergleich.java
├── Op.java
├── Expr1.java
├── Token.java
├── ParserInfix.java
├── ParserRPN.java
├── Konvertisseur.java
├── ProductionDot.java
├── SVGPlotterStatic.java
├── FunktionSVG.java
└── meinedemo.java
- Java 17 or higher
- lvp-0.5.4.jar
- All Java source files listed above
Start the LVP server in the project directory:
java -jar lvp-0.5.4.jar --log --watch=meinedemo.javaOpen the generated link in your browser.
In the browser you can:
-
Configure plot scaling (default values provided)
-
Define free parameters and their values
Example:Parameter name: a Parameter value: 2 -
Enter up to 7 mathematical functions, e.g.:
f(x) = sin(x)
g(x) = x*x
p(x) = ln(x + a)
h(x) = ¡(x > ~3 && x < 4) ? log(√(x+2)) : exp(x^2)
Click Send after each modification.
- SVG plot with:
- colored function curves
- legend
- title
- axes & grid
- AST visualization generated as DOT files
!→ factorial¡→ logical NOT~→ numeric negation
2x or xln(x) are not supported.
Use explicit operators:
2*x
x*ln(x)
By default, the project uses Infix notation.
To switch to RPN parsing, modify meinedemo.java:
//ParserInfix p = new ParserInfix(token);
//expr = p.parse();
ParserRPN prpn = new ParserRPN(token);
expr = prpn.parse(token);String[] COLORS = { "cyan", "red", "orange", "green", "blue", "violet", "black" };
String[] NOMS = { "f", "g", "p", "h", "u", "v", "t" };
String fi = "~(exp(x))";
String gi = "sin(x)";
String pi = "cos(x)";
String hi = "(x>0 && x<5)? x*ln(x)-x : (x^2-1)/(x+3)";
String ui = "1/(log(x^b))";
String vi = "√(x^3)-3";
String ti = "¡(x < 0)? 2*x^2 - 4*x + 8 : ~x";
String[] expressions = { fi, gi, pi, hi, ui, vi, ti };- Strong mathematical and analytical skills
- Parsing & compiler fundamentals
- Clean software architecture
- Scientific visualization
- Ability to design complex systems from scratch
Bioinformatics student (3rd semester)
Interested in data analysis, scientific computing, and mathematical modeling

