Wednesday, 30 December 2015

TLCalc Hamburger Menu

The main calculator menu was getting rather crowded so the navigation options have now been moved to the hamburger menu.

    

The 3 dashes icon on the top left is used to open the hamburger menu (alternatively, you can swipe from the left).

You can now adjust the angle mode anywhere using the angle mode toggle. The angle mode is RAD when on and DEG when off (the labels don't fit in the Android Lollipop themed switches so unfortunately you'll have to remember this).

The different modes of TLCalc can be switched between easily by tapping on the mode you would like to use. You can also add a short-cut to your home screen to directly access that mode by tapping on the bookmark icon.

Note: TLScript is still in development and is not intended for use although you can play around with it if you wish.

Wednesday, 14 October 2015

Order of Operations

Brackets ( and ) are used for grouping expressions and changing the order of operation. This calculator evaluates the expression following the rules of BODMAS (Wikipedia link).

The specific order of operation for TLCalc is defined as below:
  1. Brackets: (, [ 
  2. Negate (-) 
  3. Angle (@), factorial (!) and Exponential (E)
  4. Power (^)
  5. Permutation (nPr) and combination (nCr)
  6. Multiplication (*), division (/) and modulus (%)
  7. Addition (+) and subtraction (-) (or negate if first term)
  8. Comparators (>, >=, <, <=)
  9. Equality (==, !=)
  10. AND (&&)
  11. OR (||), XOR (|^) and IMPLIES (=>)
Items with higher priority are evaluated first with items on the same level being evaluated from left to right. E.g. 2^3nPr2%3 = ((2^3)nPr2)%3 .

Tip: Always use brackets if in doubt.

WARNING: The order of operation was drastically changed in V1.18.0. The changes were made to make TLCalc more closely reflect the order of operations used in other calculators and programming languages such as C and Java. Note that in all versions, BODMAS is always adhered to.

Technical extra for those that are curious:
You may notice that the minus sign (-) is located in 2 places in the order of operations list. The parse will parse the '-' sign with lowest priority first. For example:
  -2^2 is interpreted as -(2^2) because negate has a lower priority (of 7) than power (4) while
  --2^2 is interpreted as -((-2)^2) since the first minus is parsed under priority 7 (like before) and the second is parsed under priority 2. The second minus is applied only to the 2 because the second minus has higher priority than power so the second minus is applied before the power and the power is applied before the first minus.   Confusing? Use brackets and you won't be.

Monday, 7 September 2015

Custom Functions

In the Insert dialog (press [fx...] when in main calculator mode), tap on [Add FX...].



Fill in the details. Tap on [?] to obtain more information about each field.

[Add FX] will create the function.

Custom functions are used just like any other functions.

Tap on [x] in the Insert dialog to remove unwanted custom functions.

Custom functions can also be created using the fxdef command.

Calculator Precision

A tolerance of ± 0.005 is used when determining how close a value is to an integer. I.e. 3.001! = 6 but 3.008! = NaN. The same tolerance is also used for comparisons. I.e. 3.034>=3.037 = 1  and 3.034==3.037 = 1 since they are within 0.005 of each other thus they are considered equal to each other.

You can bypass this behaviour for comparisons by multiplying the input by a large value such as 1E9 to ensure deviations are pushed outside tolerances. Make sure the result is within the range of a double which is (2 - 2-52) * 21023.

The tolerance is currently set at compile time and cannot be adjusted.

Main Calculator Mode

When TLCalc is opened, the main screen is shown for evaluating expressions as well as accessing the other features of TLCalc. The calculator is split into 3 main areas, the input row at the top, the history pane in the middle and the button pad at the bottom. The button pad is moved to the right in landscape mode.

TLCalc Portrait Mode
TLCalc Landscape Mode

To enter expressions, simply type the expression into the input field. E.g. 25+sin(2i


Input can be provided using the button pad or a keyboard. The on-screen keyboard is shown by pressing the keyboard icon. The button pad has [abc] and [2nd] modifiers which activate the similarly coloured text when these modifiers are turned on. You can also tap and hold a button to insert the [2nd] text for that button. This short-cut also works when the button pad is in alpha mode.

Calculator Results and History

A preview of the calculation is displayed below the field. Pressing [Eval] appends the calculation to history. Click [X] to remove that item from history.

If the expression is invalid. In which case “Error in expression” is displayed. Press [Eval] to get a description of the error. 

Press and hold an item from history to open a context menu to copy and paste either that command or its answer to the input. Some commands have no answers that can be copied to the input in which case the copy answer option is disabled.

Tapping on the history item that contains a result will toggle between rectangular, degree polar and radian polar format (see Imaginary Numbers section below).

Constants (e, pi)

There are 3 built-in constants: i, e and pi. To use these, just type them in. E.g. sqrt(-2*pi)-5i.

e must be lower case but the other constants can be in any case. The words e, nCr and nPr is the only time the calculator is case sensitive.

For numeric constants, you can use E meaning multiply by 10 raised to the power of (10^). E.g. 2E3 = 2*10^3 = 2000. The E must be capital otherwise the calculator will assume the constant e is being used.

Imaginary Number (i, @)

i is the imaginary constant and can be used in many functions such as sqrt, sin, cos, etc.

You can type imaginary numbers in using a+bi, a+ib, re^(ti) or r@t where a is the real component, b is the imaginary component, r is the magnitude and t is the angle. The angle must be in radians when using the exponential form but uses the chosen angle mode when using the @ notation. You can also toggle the output type by tapping on the results in history. The letter next to >> indicates the output type where:
  • i = rectangular 
  • p = radians polar
  • d = degrees polar
ReminderTLCalc uses @ to input complex angle (i.e. ∠). This is so you can use a keyboard to type in polar numbers easily.

Variables

See Using Variables.

Operands

This calculator accepts operands: add (+), subtract (-), multiplication (*), division (/), to the power of (^) and modulus (%). The subtract symbol (-) is also used for multiplying the result by -1 like -sqrt(4) = -2.

% is not used as percentage in TLCalc. It is used as modulus which returns the remainder of a division operation. Percentage is not supported outside of Unit Converter mode. (where it can be entered as a unit type)

This calculator supports implicit multiplication. This means that you are allowed to drop the multiplication character when it it is allowed in algebra. E.g. (5)(2(sin(2)+3) .

The * sign is required when omitting * causes the sequence of letters to look like a function (regardless of spaces and capitalization of letters). E.g. a*sin is not the same as asin which is a function.

See also: Order of Operations.

Functions

Many functions are available for you to use and custom functions can even be added to TLCalc (see Custom Functions for more information).  To use a function, type the function name followed by the open bracket and the argument(s) to the function. Most functions only accept one parameter but some accept more in which case the comma is used to separate the parameters. E.g. rect(2,2*pi).

To view a list of functions you can use, tap on [fx…] to show the Insert dialog. From the dialog, tap on a function name to insert it into the input, [?] to view more information about the function or [x] to remove the function (remove applies to custom functions only). You can also insert commands and variables using the Insert dialog.


Some functions have restrictions on their inputs such as factorial which only accepts a positive integer. Specifying an input that is incompatible with the function results in NaN (not a number). Any operations involving a NaN degrade to NaN, e.g. 0*NaN = NaN.

Matrix

From V1.10 and onwards, you can use matrices by typing them in using square brackets [ and ]. Commas are used to separate columns and semicolons to separate rows. E.g. the 2x2 matrix is entered as [a,b;c,d]. Normal matrix operation are considered for addition, subtraction, matrix multiplication, scalar multiplication and integer powers (-1 is the only negative power allowed which calculates the inverse matrix).

Note: Indexing of matrix elements start with 1.

Use of algebraic operations with matrices, especially with operations such as det and matrix inverse is currently experimental. There are some known bugs so use with caution.

Permutation (nPr), combinations (nCr) and factorial (!)

Permutation and combination is input as a nPr b and a nCr b where a and b are non-negative real integers and b<a. Factorial is input as a! where a is a non-negative integer. You can use variables as well but the non-negative integer requirement still holds. Similar to functions, these operations return NaN if you provide invalid parameters.

See also: Calculator Precision and Order of Operations.

Comparisons

Symbol
Meaning
< 
Less than
> 
Greater than
<=
Less than or equal to
>=
Greater than or equal to
==
Equal to
!=
Not equal to









You can use the symbols shown in the table to compare quantities. These operators return 0 for false and 1 for true. These relational operators only work if both numbers being compared are both real or both purely imaginary. Equals checks that both real and imaginary components are equal before returning 1. The not-equals operator checks for difference in either real or imaginary components before returning 1.

See also: Calculator Precision and Order of Operations.

Function Helper

Added in V1.11 is a utility to help you input functions. The function helper displays the function argument’s name and a description on the function. It also allows you to evaluate the function before inserting it into your main expression. To access the function helper, first place the cursor after the opening bracket (but before closing bracket if any) of the function then tap on the [Fx?] button.

Remember to place the cursor somewhere after the opening bracket of the function, not inside the function name. You don’t have to place it directly after the opening bracket but if placed inside nested functions, function helper will display the help for the nested function (since TLCalc can't tell whether you would like to edit the inner or outer function, it will default to the inner function).

Commands

Commands are like sub-programs built into the calculator. They are called by their name followed by a colon (:). All arguments are separated using colons (this is to prevent confusion when the argument contains a comma). The FX Picker lists all available commands in the CMD tab as well as how to use them.

Number Bases


Saturday, 29 August 2015

Graphing

TLCalc has a powerful graphing system offering you 7 different plot types and up to 20 simultaneous plots of any combination.

The plotting interface was revised in V1.17. This documentation is for V1.17 and above only. 


Plotting mode is accessed in the menu >> Graphing mode. This brings up the screen for inputting plots. To add a plot, click on the [+] icon at the top. You will be asked to pick a plot type. The plots available are:
  • Function: single variable expressions f(x) or f(y) on the x/y axis.
  • Polar: plots r(t) where t is the angle and r(t) is the distance from the origin.
  • Parametric: plots x(t) and y(t) on the x/y axis where t is the changing variable.
  • Implicit: plots f(x,y) = 0. This mode is extremely slow compared to other modes. Avoid adding more than one implicit plot, especially on large screen devices. 
  • Stat-Plot: plot matrix data (see notes) as scatter, line, column or stem plot.
  • Stat-Histogram: plots a histogram for matrix data (see notes).
  • Stat-Box&Whisker: plots the box and whisker plot for matrix data (see notes). 
Some notes:
  • Tap on the card header closes and opens the card for editting
  • Plots with invalid information will be ignored from plotting
  • Tapping on the function information when the card is collapsed will hide the function (red X means the plot is hidden)
  • Plots are removed using the [x] button. The [↑] button is used to reorganise plots by moving plots up one spot.
  • Variables x, y and t can only be used if the function accepts them. E.g. using t in the implicit plot will cause the plot to be marked as invalid. 
  • You can use variables other than x, y or t in the plot expression to experiment with constants. When plotting, a slider will appear allowing you to adjust the constant's value. Except from stat plots, '#' variables such as #a are not supported at all in graphing mode because of performance reasons.
  • Stat plot requires a general variable (such as #a) that is currently storing a matrix. The matrix within the variable must contain only real finite values (NaN or complex values will cause the matrix to be rejected). Use the drop down to specify the variable containing the dataset you want to use. Matrices which are not linear (one column or one row) are treated as linear by reading of one row at a time. If the variable you want to use is not in the list, make sure the variable contains a matrix and that it contain no complex or non-finite values. 

An example of a function and polar plot added:



Once you are done editing the plots, tap on [Plot] to view the graphs.


To navigate the graph:
  • Drag to move the view around
  • Pinch diagonally to zoom in and out (maintains current aspect ratio)
  • Pinch horizontally or vertically to zoom in x or y axis only (does not maintain current aspect ratio)

You can also add markers to identify features in the graphs. Tap on [...] and pick a feature type to find. This will run a search on all the plots (you cannot exclude particular plots from this search). Tap on a marker to get more precise reading of its position. You can also add a trace marker which you drag around to observe the x and y value at that point. [CLR] is used to remove all added markers.
Note that feature finding or tracing is not supported for implicit plots. The intersection finder also has some limitations associated with it. 



[FX] returns you to the plot editor. You can also navigate to table mode which shows you each plot evaluated at regular intervals apart by tapping on [Table]. Note that the first column is for t which is the placeholder for the changing variable and is internally converted to x or y for functions and indices for stat plots. Following columns are the x and y values evaluated at the corresponding t value for each plot. Implicit plots are not compatible with table mode and are not shown.



Number Bases

Since V1.14, TLCalc allows you to change number bases. TLCalc goes one further and allows you to use any number base from 2 to 36. Other calculators normally limit you to 2 (binary), 8 (octal), 10 (decimal) and 16 (hexadecimal). The other bases are rarely used however so most of you won't have any use for other bases.

To change the base, in the main calculator mode, go to the menu >> settings. The number base setting is near the bottom:


Some caveats to using number bases other than 10:
  • This is a relatively new feature and may have bugs
  • This setting only applies to the calculator mode. Base-10 is used in all other modes irrespective of this setting
  • When using bases higher than 10, numeric values starting with a letter must have 0 prefixed. This is to let TLCalc know you want the number value instead of the variable. Also be careful when using letter variables which can be mistaken for the numeric values. Use * to break up letters. E.g. 2*a ≠ 2a in bases higher than 10.
    Warning: TLCalc does not format algebraic expressions correctly all the time when the base is higher than 10. E.g. typing 2*a returns 2a which is interpreted as a number.
    In general, mixing of algebraic variables with bases other than 10 is discouraged.
  • Exponential multiplier E is unusable (i.e. the E in 5E2 = 5x102 = 500). As such, the range of calculation results available in modes other than base-10 is severely reduced. When the value is too large to be shown, OVERFLOW is returned.

Using Variables

TLCalc allows you to store 24 complex values and 26 general values for a total of 50 variables. The 24 complex variables are letters a-z excluding e and i which have special meaning inside TLCalc as the exponential constant and imaginary constant respectively. To store a complex value, specify the variable name followed by an equals symbol:

    a = 2+3i

To use the variable, just type in the letter:

    a = 2+3i

The general variables are simply variables proceeded by the hash symbol:

    #a = 2+3i

The general variables are special as they can be used to store results that aren't just complex values. They can also be used to store expressions and matrices.

    #b = [2,4;2,3+4i]
    #c = x+2x^2

Note that unlike complex variables, general variables #e and #i are allowed.

When you use variables that have not been defined, TLCalc will simplify the expression for you. Note that TLCalc's algebra system is very basic and will not always produce the best results. TLCalc is best suited to numerical calculations.

Warning: when the number base is higher than 10, letters used by the number system may be confused for numeric values. Use a multiplication (*) symbol to separate the variable if it follows a number. E.g. if a is a variable, then 2a should be entered in as 2*a in bases higher than 10.