Viplex

Screenshot 1 Screenshot 2 Screenshot 3

Viplex is a program to visiualize complex numbers or more precisely complex-valued functions.

Download executable jar

The program parses the mathematical expression defining a function f(z) in the input box below and creates a view of the complex plane. The standard math operators +, -, *, / and ^ (exponentiation) can be used and are parsed correctly regarding standard precedence rules. Important functions and mathematical constants are also recognized.

Each point z is colored based on the value of f(z). The absolute value of f(z) is encoded with color intensity. The argument of f(z) is encoded with hue. A particular slightly changed color wheel is employed to make the resulting images easier to read.

The user can move the view of the complex plane freely using the mouse or the keyboard. The view can also be zoomed to explore the finer details of the defined functions.

Parser

A complex part of the program is the parser. It is a hybrid between a standard recursive descent parser and a pratt parser.

The latter is rather unknown but really nice for implementing operator precedence. The grammar rule for expressions is parametrized by the minimum precedence / binding power of the operators that can appear in the expression. The operators define what should happen when appearing at the start of an expression (nullary usage: nud) and what should happen when they bind something on the left (led) using their left binding power (lbp). The actions nud and led can recursively call the expression rule with a custom precedence. This allows implicitly defining rules for expressions with precedence, associativity, complex operators like function-call-parenthesis (or a ternary operator) and "overloading" operators between prefix and postfix/infix usage (like the * in C: 3 * 5 and *ptr) in a decentralized manner.

Technology

This program is written in Java using the Swing GUI library. The Apache Foundation math library is used for the complex-valued math. Gradle is used as the build system.