To start using the Tusanga Calculator please enter an expression (like
2+3) in the big form in the middle of the screen - below the 'Enter your mathematical Expressions here' line. When you press the 'Calculate' button the system evaluates your expression. Please try it out now! Input:
2 + 3Output:
5The first line '
2+3' is your input to the calculator. The second line '5' is the resulting output from the calculator. The user can assign values to variables. Please notice the use of ':=' when assigning values. This is the equal sign the calcualtor uses for assignments. An ordinary '=' will not do.
Input:
a := 2Output:
a := 2Once again, the first line '
a := 2' is the user input and the second line is the output from the system. In this case the system reponds, that it has assigned the value 2 to the variable a. '
a := 2' is an example of a statement. An expression is evaluated to another expression (2+3 evaluates to 5) where as a statement is executed (assign the value 2 to the variable a). Let's try another calculation combining an expression and a statement.
Input:
b := 3 + 4Output:
b := 7The right hand side of a variable assignment statement can include known variables. In this example a semicolon separates the different statements and expressions.
Input:
a := 2 ; b := 7 ; c := a + bOutput:
a := 2Output:
b := 7Output:
c := 9The right hand side of a variable assignment statement can also include unknown variables.
Input:
d := 2 + q + 4Output:
d := 6 + qLet's list all the defined variables using the command
whoInput:
a := 2; b := 7 ; whoOutput:
a := 2Output:
b := 7Output:
Mate's environment:Output:
a := 2Output:
b := 7Besides the variable assignment statement there are other types of statements. An expression is special type of statement. It just consists of an expression to evaluate.
Input:
2 * 27Output:
54The system can also return integer results in the binary, octal or hexadecimal number system. Use
in bin for binary output. Replace with oct and hex for octal and hexadecimal output.Input:
2 * 27 in hexOutput:
0x36The result of an expression statement is always stored in the variables
ans. This way the result can be used in following statements.Input:
2 - 7 ; 2 * ansOutput:
-5Output:
-10To separate multiple statements one can use a colon or a semicolon. The colon suppresses output from the preceeding statement although the statement is executed normally. If the last or the only statement has neither a colon nor a semicolon, a semicolon is assumed and the result is printed.
Input:
2 ^ 4 ; 3 * 4: 5 - 6Output:
16Output:
-1Let's define a function on one variable and use it.
Input:
f(x) := 2 * x ^ 2 ; f(3)Output:
f (x) := (2*(x^2))Output:
18Functions on more than one variables can also be defined.
Input:
g(x,y,z) := x + y + 2 * z : g(1, 2, 3)Output:
9We can use floating point numbers, numbers in the binary or hexadecimal system or even roman numerals.
Input:
2.5-1.8 ; 0b1101 ; 0h2f ; MCMLXXIV|rOutput:
0.7Output:
13Output:
47Output:
1974In fact, we can use any number system from 2 to 36. Let's see what 27 is in a number system with base 9. We check the result by also calculating it directly. This time we use the comparison equal sign '==' and not the assignment equal sign ':='.
Input:
327|9; ans == (3*9^2+2*9+7)Output:
268Output:
trueVectors and matrices are also facilitated for. We'll define a matrix as well as a column vector and multiply them. The two elements of the resulting vector is then assigned to two different scalar variables. Here we chose to enter a row vector
{ 5,6 } which we then transpose using the transpose operator `. We could also have defined a column vector directly: { 5;6 }.Input:
M := { 1, 2 ; 3, 4 } : v := { 5,6 }` : w := M * v ; {k1,k2}:=w`Output:
w := {17 ; 39}Output:
k1 := 17Output:
k2 := 39If v is unknown and w known, we can solve the linear system of equations
M * v = w using the solvem function. We'll compare the result to the known value of v to make sure the result is correct.Input:
M := { 1, 2 ; 3, 4 } : w := {17 ; 39}: {v,H} := solvem(M,w); v == { 5,6 }` Output:
v := {5 ; 6}Output:
H := 0Output:
trueThat
H equals 0 indicate that we have found an exact solution.We extend the system to become over-determined. M has become a third row. We execute '
w := M*v'. Calling the function solvem(M,w) would give us the original v. Instead we change w a little to make it over-determined and then solve for v. Because the system is over-determined we get a least square solution. This is indicated by H being NaN. Notice how the original v and the solution v2 to the over-determined system differ. Mate tries to keep integers and fractions as far as possible. To convert the result to floating points we use the function float. Input:
M := { 1, 2 ; 3, 4 ; 2, 3 } : v := { 5,6 }`: w := M*v; w2:=w+{0,0,1}`; {v2,H} := solvem(M,w2); v2 <> v; v2-v; float(ans)Output:
w := {17 ; 39 ; 28}Output:
w := {17 ; 39 ; 29}Output:
v2 := {(14/3) ; (19/3)}Output:
H := NaNOutput:
trueOutput:
{(-1/3) ; (1/3)}Output:
{-0.333333333333 ; 0.333333333333}Hopefully, this 'Getting Started' page has helped you with your first calculations on the Tusanga Calculator. In the menu you will find more detailed information on the system. If you can't find the answers here, you can contact us and we will try to get back to you as quickly as possible.
Please consider a membership. As a member you'll enjoy a more advanced user interface supporting easy printing of calculations, file uploading, working on multiple workbooks for separate series of calculations and storing these for months. In addition more mathematical capabilities due to higher limits on size of matrices, number of variables and number of plots provide for larger and more complex mathematical projects. Sign-up now for a free trial membership.
Thank you for trying out the Tusanga Calculator.