WARNING: this is obsolete, unsupported software. I haven't touched this since 1997, when I was 12 years old... It is only here for historical purposes.
ComplexCalc
Contents
About ComplexCalc
ComplexCalc is a calculator written in 100% Java. Unlike most other Java calculators, it
supports complex numbers and an unlimited number of varibles. It uses an algebraic parser
which understands expressions such as 2 + 2i
and (37 / 6 ^ 5.4) - floor(3.9)
.
Expression Syntax
ComplexCalc expressions are made up of a number of symbols, separated by operators. For example,
2, "Hello world", and @x (which is a varible, I'll get to that in a moment) are all symbols.
Expressions can be as simple or as complex as reqired. The parser supports operator precedence.
Here is the list of operators, from highest precedence to lowest:
- - - Subtraction (this is so because if - was lower than /,
-1 / -1
would output
negative infinity.)
- ^ - Exponentation
- * - Multiplication
- / - Division
- % - Modulo
- + - Addition
- <,> - Less than and greater than
- = - Assignment operator
Expressions can be entered by typing the expression in the text field, using the
buttons, or both. After an expression has been entered, hit enter or return on
the keyboard or push the enter button to execute it. The result will appear in the area at
top of the applet.
Tip:instead of typing xxx * yyy, you can type xxx yyy. For example, 2 2 will output 4,
and 4i will output 4i.
Varibles
Most other calculators written in Java have a limited number of memories. ComplexCalc, on the
other hand, has an unlimited number. Each memory cell in ComplexCalc is called a varible. To
access the contents of a varible, enter an '@' symbol before the varible name, like this:
@myVarible
. varibles can be used in expressions, for example @x + 2 is valid as
long as the varible x has been defined.
To define a varible or assign it a new value use the = operator. Foe example, to define the
varible x with the initial value 6, you would type this: @x = 6.
To list the currently defined varibles, use the dump
command. To clear all defined
varibles, use the clear
command.
2 varibles are always defined: @e and @pi. They contain the values of the numerical constants
E and Pi.
Functions
ComplexCalc has a large array of functions. To invoke a function, enter its name, a left
parantheses, the parameters separated by commas, and a right parantheses. For example, to invoke
the sine function, giving it @pi/3 as a parameter, you would type this: sin(@pi/3)
.
Just like varibles, functionscan be used in expressions, like this: 2 sin(@theta).
Here's a list of functions included with ComplexCalc:
- All trigonometric functions: sin, cos, tan, arcsin, arccos, arctan
- All hyperbolic functions: sinh, cosh, tanh, arcsinh, arccosh, arctanh
- Logarithms: ln (natural logarithm), logn (any base logarithm - first
parameter is the base, second one is the number.)
- Various miscallaneous functions: floor, ceil, round, sqrt, square, exp (e^x), deg
(switches to degree mode, ie angles will be measured in degrees), rad (switches to
radian mode, ie angles will be measured in radians)
Tip: If the function accepts no parameters (this is the case for dump, clear, read, and deg)
you can simply enter it's name without the parantheses.
Plotting Functions
To plot a function or any other expression, enter plot(expression,xmin,xmax)
.
xmin and xmax are optional, if you don't specify them, xmin will be -1 and xmax will be 1. Also,
you an specify the y minumum and y maximum.
The expression must contain a reference to the varible x.
Try these expressions:
- plot(i^@x,-4,4)
- plot(sin(@x),-@pi,@pi)
- plot(exp(i @x),0,10)
- plot(@x,-10,10)
- plot(@x^2,-10,10)
Writing Your Own Functions
To write your own function, create a class in the slava.complexcalc.functions
package.
The class must be a subclass of slava.complexcalc.kernel.Function
and must implement
the method Object invoke(Expression[] params, ExpressionParser parser) defined in that class.
params
contains the parameters given to the function by the user. It is always 32
elements long, and parameters that haven't been specified are null
. The method
must return a string or a ComplexNumber
.
See the source code for slava.complexcalc.kernel.Function
and
slava.complexcalc.kernel.ExpressionParser
for more info.
Changes From The Previous Version
I have made a number of changes to ComplexCalc since version 1.0.
- The plot function now accepts ymin and ymax parameters
- The plots look better now
- Fixed a bug in the ComplexNumber class that would calculate 0^i as NAN
- Fixed a GUI bug that would append the text of a pushed button to the end of the text field,
even if the insertion point was somewhere else.