Graphing Calculator: The expression language

Content

Introduction

The Graphing Calculator evaluates expressions based on a strict set of rules, which form a language. Since the mathematical language is way too complex, and is impossible to write in simple text, this application (and many others) uses a simplified language.

If you are familiar with programming in a C-like language (C, C++, C#, Java), the language used here is very similar to these programming languages.

Variables

A variable is a symbol which may assume any given value. In this application, this symbol is represented by a character string which follows the following rules:

The advantages of using variables are that you can skip having to type an ugly expression multiple times, and you can reevaluate the expression with a different input easily.

Variables are supported in the Graphing Calculator, with the limitation that they can only be used in the expression evaluator. Using variables in the plotting of graphs, and integrator is not possible. By default, the only used variable is x when plotting and integrating expressions.

Predefined variables

The evaluator has two predefined variables:

Accepted operators

The following operators are accepted:

The order of operations is also respected. A higher order means a higher priority. Operations with the same order are evaluated left to right, with the exception of the power operator.

Functions

The Graphing Calculator supports only predefined functions at the moment.

Predefined functions

The following functions can be used:

Roots

sqrt(x)Square root
cbrt(x)Cube root
root(n, x)Nth root

Logarithms

lg(x)Decimal logarithm
ln(x)Natural logarithm
log(b, x)Logarithm of x with base b

Trigonometric functions:

sin(x)Sine
sinh(x)Hyperbolic sine
cos(x)Cosine
cosh(x)Hyperbolic cosine
tan(x)Tangent
tanh(x)Hyperbolic tangent
ctan(x)Cotangent

Inverse trigonometric functions:

arcsin(x) or asin(x)Inverse sine
arccos(x) or acos(x)Inverse cosine
arctan(x) or atan(x)Inverse tangent

Other functions:

ceil(x) or ceiling(x)Ceiling, or the smallest integer number, greater than x.
floor(x)Floor, or the greatest integer number, smaller than x.
int(x)Integer part of the number.
truncate(x)Truncates (removes) the fractional part from the number.
round(x, n)Rounds the number to n decimals.
 
abs(x)Absolute
max(x, y)Maximum
min(x, y)Minimum

Syntax rules

The syntax of this application is more strict than the mathematic language. These are some of the rules:

Numbers:

Functions:

Operators:

Others: