Visualisation of complex functions of a complex variable.
The other day in my Complex Analysis class someone asked: “what is the
graphical meaning of a residue?” Then the lecturer went on about how complex
functions of a complex variable are hard to interpret graphically, since they
are mappings from a 2-dimensional space to another. That is how this repo was
born.
I immediately started thinking about how to build an interactive graphing tool
that would help give an intuitive meaning to functions from one complex
variable to another. Then one could differentiate them, and then integrate
them, and then… who knows, maybe even visualise the residue of a function at
a singularity.
The code in this repo is under development. There is a high
chance that it will substantially change in the near future!
The code in this repo basically consists of two types of JavaScript objects:
variables and graphics. Variables have values that can be read by
other variables and graphics. These values are usually a function of other
variables’, but they can also be derived from the mouse position or be set
manually. Variables also have names, which allow you to use them in equations.
Classes that fall under the variable category are:
Variable
- No surprises here. These are thePlot
objects as position vectors.Interval
- This is a rather special type of variable. It represents anVariable
, which can be veryDeltaVar
- This is used to represent the difference between consecutiveCumVar
- This variable is used to represent the sum of the different valuesContour
- This one is very similar to Variable
in functionality. TheInterval
. It is also plotted differently: instead of a position vector itEnough about variables. Let’s talk about graphics! They are used to
interact with the DOM in order to show the user the state of its dear
variables. Currently, there are two types of graphics:
Plot
- Give it a <canvas>
element and it will do wonders with it! ItVariable
,DeltaVar
, CumVar
and Contour
mentioned above. Plot
objects areSHIFT
for panning) or using two fingers on your touchscreen (!). Each Plot
Variable
for it to pass it the position of the mouse when theDisplay
- This simple class can be given a DOM element (such as a <span>
)Apart from this, the framework also provides the class FreehandContour
which
could be regarded as a radioactive hybrid between Interval
and Contour
(and
most probably a poor design choice). You can pass it a Variable
which is
linked to the mouse position of some Plot
and it will draw (and store) the
contour described by the mouse as it moves. This class doesn’t have a value per
se; instead, it manages a Variable
and a DeltaVar
(suspiciously named z
and dz
) which can be accessed for further mischief.
Each of these objects updates and is updated by others using the observer
pattern. Every object has a
list of listeners, to which it notifies when its own value is updated.
Essentially, the variables and graphics used will form a dependency graph,
which should be a directed acyclic
graph (or else you will
have variables updating each other in a cycle ad stack-overflow-um). This
creates some synchronisation challenges, since there might be more than one
path to a descendant variable, causing it to update twice for each signal of
the original variable (and this could cause or integral estimation to
manifold). This is handled in two ways:
Variable
objects (which, conveniently, are the only ones that can depend onwait
. If it is set toI hope that someday Soon I will write a not-so-short
article about complex functions and how to visualise them which demonstrates
the potential and usage of this framework. Until that day comes, you can get a
sneak peak of what it can do by visiting this
page.
Currently, the only dependency of this project is the
Math.js library.