Table of Contents
Definition and notation of functions
CGRAPH is a tool for creating graphical representations. In CGRAPH, functions can therefore be defined simply by typing them in on the keyboard – without the considerable effort that learning a programming language, for example, would entail. In order for CGRAPH to recognise the functions entered as such, certain conditions must be met.
The following section uses a number of terms that are first explained in the table below.
| Term | Explanation |
|---|---|
| Function identifier | A word that identifies a function; for example, sin for the sine function. |
| Reserved character | A character that has a specific meaning in CGRAPH and therefore cannot be used in variable names. One such character is the slash, which is used as a division symbol. |
| Function definition | A mathematical term consisting of functions, arithmetic operators, variables and constants that are predefined as keywords and reserved characters, as well as complex or real numbers |
| Keyword | A word that has a specific meaning in CGRAPH |
In order for CGRAPH to process the entered functions, they are translated into an internal format after entry. In this format, which divides the calculation into many small steps, results can be determined very quickly. If an error occurs during translation, CGRAPH displays this error in red below the input fields.
Available functions
CGRAPH offers the most important basic mathematical functions as function identifiers. All functions work with complex numbers and return complex values, even if the graphic function only uses the real part. The argument of the function is enclosed in two brackets, which indicate to CGRAPH that a function is about to begin.
| Function identifier | Meaning |
|---|---|
| exp | Exponential function ex |
| log | Logarithm to the base e |
| sinh | Sine hyperbolic |
| cosh | Cosine hyperbolic |
| tanh | Tangent hyperbolic |
| sin | Sine |
| cos | Cosine |
| tan | Tangent |
| sqr | Square |
| sqrt | Square root |
| abs | Absolute value (returns a complex number whose imaginary part is always zero) |
| re | Real part (returns a complex number whose imaginary part is always zero) |
| im | Imaginary part (returns a complex number whose imaginary part is always zero) |
| pol | Conversion of a complex number from Cartesian to polar coordinates. The return value is a complex number whose real part is interpreted as the magnitude and whose imaginary part is interpreted as the angle in radians. |
| kart | Conversion of a complex number from polar to Cartesian coordinates. The input value is a complex number whose real part is interpreted as the absolute value and whose imaginary part is interpreted as the angle in radians. |
| arcsin | Arc sine |
| arccos | Arc cosine |
| arctan | Arc tangent |
| arsinh | Arcus sine hyperbolic |
| arcosh | Arcus cosine hyperbolic |
| artanh | Arcus tangent hyperbolic |
| sigma | Sigma function. Only the real part of the input value is evaluated; a complex number is returned whose imaginary part is always zero. |
| delta |
Only the real part of the input value is evaluated; a complex number is returned whose imaginary part is always zero. For the input value 0, the delta function returns the result 1|
| int | Calculation of the integer value of the real part. A complex number is returned whose imaginary part is always zero. |
| frac | Calculation of the non-integer value of the real part. A complex number is returned whose imaginary part is always zero. |
| inv | Inverse function |
| konj | Conjugate complex argument |
In addition, CGRAPH has functions for calculating sums and products.
| Function identifier | Meaning |
|---|---|
| sum | Sum function |
| prod | Product function |
Both functions have in common that they must always be at the beginning of a function definition and enclose the entire remaining function term in brackets. The variable n then serves as the counting variable. Outside of sum() and prod(), n always has the value 1. Further information on usage can be found here.
Available variables
CGRAPH allows only a limited number of variables when entering functions in order to make input as simple as possible. The table shows all possible values. Wherever functions can be entered, floating windows indicate which variables are permitted.
| Variable | Meaning |
|---|---|
| z | complex number |
| z\ | conjugate complex number |
| x | denotes the Cartesian x-coordinate or the real part of the variable z |
| y | denotes the Cartesian y-coordinate or the imaginary part of the variable z |
| r | variable for radii |
| phi | variable for angles |
| t | to be used analogously to x |
| s | to be used analogously to x |
| u,v,w | denote the Cartesian x, y and z coordinates and are used where three different variables are actually required for the coordinates. In some graphics, u, v and w can also be complex numbers. |
The joint use of x, t and s is possible in some places, but should be avoided for reasons of clarity.
Parameters
CGRPAH recognises the keyword param, which can be used like a variable. If CGRAPH recognises this keyword in a function, it displays an input option for it, which can be used to specify an initial value for the parameter. The parameter can then usually be changed later within the display of the graph.
In some graph functions, a parameter is mandatory. A floating window indicates this.
Arithmetic symbols
The following arithmetic symbols can be used in CGRAPH:
| Arithmetic symbol | Meaning | |
|---|---|---|
| + | Addition | |
| - | Subtraction | |
| * | Multiplication | |
| / | Division | |
| General power function |
The colon : is not an arithmetic operator. It is used to represent coordinate pairs and triples and to separate their individual coordinates from each other. See Number formats for more information.
Keywords
Several keywords are defined to control processes in CGRAPH. These are not currently used:.
| Keyword |
|---|
| function |
| programme |
| import |
| export |
| external |
| := |
| # |
Notes
CGRAPH allows the use of real numbers or the complex number format within functions. The internal compiler first checks the number of brackets set. If not all of them are closed, the missing brackets are automatically inserted at the end. If more brackets are closed than were previously opened, you will receive an error message.
The functions entered may contain spaces. The compiler first checks the number of brackets used. If not all brackets are closed, the missing brackets are automatically inserted at the end. If more brackets are closed than were previously opened, you will receive an error message.
Since complex numbers are fully recognised, brackets are not necessary here. An input such as z-3-3j is equivalent to z-(3+3j). The same applies to priority considerations. An input such as z*-3-3j is recognised as correct and calculated as z*(-3-3j) The imaginary part is therefore interpreted as still belonging to the number. The equally conceivable translation to z*(-3)-3j, where the multiplication is performed first, followed by the subtraction of the imaginary number, requires additional brackets, as indicated here. It is irrelevant whether only the number -3 or the entire multiplicative term is bracketed.
CGRAPH can provide a maximum of ten memory locations within a bracket level. This is sufficient for most inputs. However, an input such as z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z overwhelms the compiler – eleven memory locations are required here due to the priority of the multiplications. Inserting an additional bracket level solves the problem. z*z+(z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z+z*z) Incidentally, entering 11*sqr(z) or 11*z^2 It is advisable to use the general power function instead of multiple multiplication, as powers are not split internally into multiplications, but are calculated directly using the exponential function.
Automatic saving and loading
Functions entered are saved as soon as they have been correctly translated. They can then be reloaded using the arrow button on the right-hand side of the input field for the function. The functions are assigned to the respective graphics – functions from the real function area are therefore not found in the complex plane graphics functions, etc.
Changes to a function result in both the old and new variants being saved. Functions can be removed from the memory list in the settings.
Further notes
Internally, CGRAPH does not distinguish between real and complex numbers. This has the advantage that when creating real graphs, you do not have to pay attention to their domain in the real numbers. Since, for example, the square root of negative numbers results in a purely imaginary number, CGRAPH simply returns zero as the result when displaying the (real) square root; this is also mathematically correct within the complex numbers.
Nevertheless, care should be taken to adhere to the respective domain so that undesirable results are not produced. For example, if the function
sqrt(x)*sqrt(2*x)
is to be plotted, CGRAPH calculates purely imaginary numbers for negative values of x in both parts of the term, the multiplication of which again results in a real number, which is mathematically correct. However, the result is not desirable when displaying real graphics. CGRAPH cannot detect such systematic errors; you must exclude such possibilities yourself by selecting a suitable drawing range.
