This project is made by a novice, and is a work in progress. This program is by no means perfect or in a final state.
EulerForm is a Python program that performs complex-number operations. Run the program on the TI-Nspire CX II CAS calculator (OS 6.x) or on a PC.
The program uses Euler's formula to convert a complex number between three equal forms:
- Rectangular form:
a + b*i. - Trigonometric form:
r*(cos θ + i*sin θ). - Exponential form:
r*e^(iθ).
EulerForm's primary function is to perform complex algebra, but can also add, subtract, multiply, and divide complex numbers. EulerForm is also able to compute powers/n-th roots and return the modulus, argument, and conjugate of a complex number.
The program shows exact values when it can, and gives an exact result when the input parts are integers.
Modulus examples:
|1+i|shows√2.|2+3i|shows√13.|3+4i|shows5.
Arguments are shown in one of three forms:
- A fraction of π. The argument of
1+ishows asπ/4. - A symbolic inverse tangent. The argument of
3+4ishows asatan(4/3). - A decimal value. This form occurs when the real part and the imaginary part are not integers.
Example. Convert 3+4i to exponential form. The program shows:
5 * e^(i * atan(4/3))
It does not show a rounded decimal angle for integer input.
EulerForm has an exact mode. In this mode, the program calls the CAS engine
of the calculator. The CAS engine returns exact symbolic values. The menu
item 7 toggles the exact mode.
The exact mode is OFF on PC. The exact mode is ON on the calculator by default. The exact mode won't do anything on a PC due to the lack of a CAS engine. Symbolic angles ARE still shown on PC. This is possible because EulerForm computes the symbolic angle in Python code.
This table lists the files of the project.
| File | Purpose |
|---|---|
eulerform.py |
The main program. |
test_eulerform.py |
The self-test which runs on PC. |
README.md |
This file. |
EulerForm shows these characters: π, √, ·.
If your device can not show these characters, change the constants at the
top of eulerform.py, using ASCII text instead.
Change the constants to these values:
SYMPI = "pi"SQRT = "sqrt"DOT = "*"
Create a virtual environment in the project folder. Use this command:
python -m venv .venv
Run the self-test. Use this command:
python test_eulerform.py
The self-test passes when it shows ALL TESTS PASSED.
Run the program. Use this command:
python eulerform.py
Note: The PC version has no CAS engine so exact mode stays OFF, meaning the program will work in numeric mode.
- Connect the calculator to the computer with a USB cable.
- Open the TI-Nspire CX software on the computer.
- Under "Documents," select New > Add Python > New.
- Name your program and select "Blank Program" as the type.
- Paste the contents of
eulerform.py. - Save the document.
- Transfer the document to the calculator.
Start EulerForm. The program will shows the main menu with six items and a quit command.
| Item | Function |
|---|---|
1 |
Convert the forms of a number. |
2 |
Add, subtract, multiply, or divide two numbers. |
3 |
Compute a power or the n-th roots. |
4 |
Show the modulus, the argument, and the conjugate. |
5 |
Toggle the angle mode. |
6 |
Toggle the exact mode. |
q |
Quit the program. |
EulerForm will ask for the form of the number. Select one of these items:
- Rectangular. Type the real part
a. Type the imaginary partb. - Polar. Type the modulus
r. Type the argumentθ. - Exponential. The program uses the same prompts as polar.
Type q to quit a prompt.
The angle mode is RAD or DEG. The mode determines how you type the angle.
In RAD mode:
- Type a fraction of π. For example, type
1/4. The program reads this asπ/4. - Type a decimal value. The program reads this value as radians.
In DEG mode:
- Type the angle in degrees. For example, type
45.
- The exact display is a "snap". EulerForm compares a computed value with a
set of simple values. If the difference is below a limit (
1e-5), the simple value is shown. The program shows a clean decimal value when no simple value matches. - Angles are shown as a fraction of π when the angle is a multiple
of π. EulerForm will show the angle as
atan(b/a)when the parts are integers, and shows a decimal value in other cases.