mathtool manual - en -...

25
Contents 1. What is MathTool? ............. 1.1 Arithmetic ................... 1.2 Analysis ....................... 1.3 Algebra ....................... 1.4 Numerics..................... 1.5 Statistics...................... 1.6 Mathematical logic ..... 2. How MathTool works – a sh 2.1 Arithmetical expression 2.2 Logical expressions ..... 2.3 Matrix expressions ..... 2.4 Operators for arithmet 2.5 Examples ..................... 2.6 Commands .................. 2.6.1 Example 1: Approxim 2.6.2 Example 2: Definitio 2.6.3 Example 3: Solving e 2.6.4 Example 4: Solving s 2.6.5 Example 5: Solving o 3. Graphical representations .. 4. Complex problems and algo 4.1 The Risch algorithm .... 4.2 Groebner bases and th 4.3 Implicit functions and t 5. Algorithms in MathTool ...... 5.1 The language MAL and ............................................................................... ............................................................................... ............................................................................... ............................................................................... ............................................................................... ............................................................................... ............................................................................... hort introduction ................................................... ns .......................................................................... ............................................................................... ............................................................................... tic expression and matrix expressions .................. ............................................................................... ............................................................................... mation of expressions ........................................... on of new functions and variables ......................... equations ............................................................... systems of equations............................................. ordinary differential equations ............................. ............................................................................... orithms .................................................................. ............................................................................... he Buchberger algorithm....................................... the Marching Cubes Algorithm............................. ............................................................................... d its syntax ............................................................. ................................ 2 ................................ 2 ................................ 3 ................................ 3 ................................ 3 ................................ 3 ................................ 3 ................................ 3 ................................ 3 ................................ 4 ................................ 5 ................................ 5 ................................ 7 ................................ 8 .............................. 10 .............................. 11 .............................. 12 .............................. 13 .............................. 13 .............................. 13 .............................. 16 .............................. 16 .............................. 17 .............................. 17 .............................. 18 .............................. 18

Upload: others

Post on 15-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

Contents 1. What is MathTool? ................................

1.1 Arithmetic ................................

1.2 Analysis ................................

1.3 Algebra ................................

1.4 Numerics................................

1.5 Statistics................................

1.6 Mathematical logic ................................

2. How MathTool works – a short introduction

2.1 Arithmetical expressions

2.2 Logical expressions ................................

2.3 Matrix expressions ................................

2.4 Operators for arithmetic expression and matrix expressions

2.5 Examples ................................

2.6 Commands ................................

2.6.1 Example 1: Approximation of expressions

2.6.2 Example 2: Definition of new functions and variables

2.6.3 Example 3: Solving equations

2.6.4 Example 4: Solving systems of equations

2.6.5 Example 5: Solving ordinary differential equations

3. Graphical representations ................................

4. Complex problems and algorithms

4.1 The Risch algorithm ................................

4.2 Groebner bases and the Buchberger algorithm

4.3 Implicit functions and the Marching Cubes Algorithm

5. Algorithms in MathTool ................................

5.1 The language MAL and its syntax

................................................................................................

................................................................................................................................

................................................................................................................................

................................................................................................................................

................................................................................................................................

................................................................................................................................

................................................................................................

a short introduction ................................................................

Arithmetical expressions ................................................................................................

................................................................................................

................................................................................................

Operators for arithmetic expression and matrix expressions ................................

................................................................................................................................

................................................................................................

Example 1: Approximation of expressions ................................................................

Example 2: Definition of new functions and variables ................................

Example 3: Solving equations ................................................................

Example 4: Solving systems of equations ................................................................

Example 5: Solving ordinary differential equations ................................

................................................................................................

Complex problems and algorithms ...............................................................................................

................................................................................................

Groebner bases and the Buchberger algorithm ................................................................

Implicit functions and the Marching Cubes Algorithm................................

................................................................................................

he language MAL and its syntax ................................................................

.......................................................... 2

................................ 2

.................................... 3

.................................... 3

.................................. 3

................................... 3

.................................................. 3

.................................................. 3

......................................... 3

.................................................. 4

.................................................. 5

................................................. 5

.................................. 7

............................................................... 8

........................................ 10

...................................................... 11

............................................................ 12

.......................................... 13

.......................................................... 13

............................................. 13

............................... 16

............................................... 16

.................................... 17

.......................................................... 17

................................................. 18

.......................................................... 18

Page 2: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

MathTool offers the possibility to write and to execute own algorithms. The syntax of this algorithm language called MAL (MathTool Algorithm Language) leans on the syntax of the object oriented language Java, but is quite more simple, because it is designed for solving mathematical problems. ........................................................................................................................................................... 18

5.2 Reserved characters and keywords ....................................................................................... 18

5.3 Structure and priciples of MAL .............................................................................................. 19

5.4 Data types .............................................................................................................................. 20

5.5 Standard commands and standard algorithms ..................................................................... 20

5.6 Examples ................................................................................................................................ 21

5.6.1 Example 1: The first algorithm .......................................................................................... 21

5.6.2 Example 2: Call of further algorithms ................................................................................ 21

5.6.3 Example 3: Algorithm with matrices ................................................................................. 22

5.6.4 Example 4: Error due to missing return value ................................................................... 23

5.7 Code generation .................................................................................................................... 23

5.7.1 Generate the main algorithms and subroutines ............................................................... 23

5.7.2 Generate Identifier definition ........................................................................................... 24

5.7.3 Generate control structures .............................................................................................. 24

5.7.4 Generate return command ............................................................................................... 25

5.8 In the next versions ............................................................................................................... 25

1. WhatisMathTool?

MathTool is a light weight computer algebra system, which mainly focuses on analysis. It deals with many mathematical issues and questions a mathematician meets daily, such as simplification of mathematical expressions, solving equations, differentiation, integration, solving differential equations and much more. MathTool also covers a series of numerical methods which approximate solutions in complex cases. Moreover, MathTool can plot plane and three dimensional graphs.

In the following, we describe precisely all kinds of operations and commands MathTool is able to perform.

1.1 Arithmetic All kinds of computation with (nearly) arbitrarynumbers, computation of greatest common divisors, least common multiples, …

Page 3: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

1.2 Analysis Computation of zeros and extrema of functions, (partial) derivatives, integration (symbolic and numeric), solving ordinary differential equations (symbolic and numeric), Taylor and Fourier polynomials.

1.3 Algebra Computation of matrix and vector operations, in particular computation of eigenvalues and eigenvectors and solving systems of linear equations. Themodulecommutative algebra is in development, but computing Gröbner bases already works.

1.4 Numerics Numericalapproximationsof expressions and matrix expressions, numericalintegration, solving equations and ordinary differential equations numerically.

1.5 Statistics Computation of arithmetic means, variance and standard deviation as well as linear regressions of given distributions.

1.6 Mathematicallogic Simplification of logicalexpressions, computation of conjunctiveand disjunctive normal form of logical expressions, evaluations of logical expressions in tables.

2. HowMathToolworks – a short introduction

User interacts with MathTool only by typing commands or expressions into the command line. Depending on the input MathTool tries to understand it and to perform all necessary operations and computations which are needed to obtain the result.If this was not successful, MathTool throws an exception containing a detailed message about what went wrong. The syntax of the commands is described in the following.

2.1 Arithmetical expressions MathTool understands mathematical expressions. The basic arithmetic operations are denoted by +, -, * and /, and ^ denotes the power. Mathematical functions are denoted by their typical names, for example by sin(...), exp(...), ln(...), arctan(...) etc. A list with all functions can be found below. Important: Multiplications must be explicitly denoted by *. MathTool understands the expression 2*x, whereas it does not understand the expression 2x and hence returns an error. Valid expressions look like:

3*x + y^5, -a + 6*exp(2 + cos(z^4)), …

MathTool returns a mathematical expression immediately in a simplified form, if possible. However, this may lead to increased waiting times, if the expression is too complicated and the simplification takes far too long. Variables can be denoted by a small letter or by a small letter with an index. Furthermore, arbitrary many ' can be appended. Hence, valid variables are, for example, given by

Page 4: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

a, b, c, …, x, y, …, a_1, x_18, …, y′, a_2′, …

but not by xy, abc or a'_1'. The apostrophe suggests a derivative, which only comes to fruition when dealing with differential equations. Otherwise it serves simply for distinguishing variables. The constant pi denotes the well-known constant π and, of course, cannot be overwritten with the command def() (see subsection Commands). Note, that MathTool removes empty space as well as makes capital letters to small letters while compiling an expression. Hence, the variable A_3 will be the same variable as a_3. List of functions: abs(x): Computes the absolute value of x. arccos(x): Computes the inverse of the cosine of x. arccosec(x): Computes the inverse of the cosecans of x. arccot(x): Computes the inverse of the cotangent of x. arcsec(x): Computes the inverse of the secans of x. arcsin(x): Computes the inverse of the sine of x. arctan(x): Computes the inverse of the tangent of x. arcosh(x): Computes the inverse of the hyperbolic cosine of x. arcosech(x): Computes the inverse of the hyperbolic cosecans of x. arcoth(x): Computes the inverse of the hyperbolic cotangent of x. arsech(x): Computes the inverse of the hyperbolic secans of x. arsinh(x): Computes the inverse of the hyperbolic sine of x. artanh(x): Computes the inverse of the hyperbolic tangent of x. cos(x): Computes the cosine of x. cosh(x): Computes the hyperbolic cosine of x. cosec(x): Computes the cosecans of x. cosech(x): Computes the hyperbolic secans of x. cot(x): Computes the cotangent of x. coth(x): Computes the hyperbolic cotangent of x. exp(x): Computes the exponential function value of x. lg(x):Computes the decadal logarithm of x. ln(x): Computes the natural of x. sin(x): Computes the sine of x. sgn(x): Computes the signum function value of x. sinh(x): Computes the hyperbolic sine of x. sec(x): Computes the secans of x. sech(x): Computes the hyperbolic secans of x. sqrt(x): Computes the square root of x. tan(x): Computes the tangent of x. tanh(x): Computes the hyperbolic tangent of x.

2.2 Logical expressions MathTool can also understand and compute logical expressions. The operators !, &, |, > and = correspond to the logical operators negation, conjunction, disjunction, implication and equivalence. Important: Although the AND and OR operators, respectively, are often denoted by * and +, respectively, MathTool does not accept this notation when it deals with logical expressions. This serves to prevent misunderstandings when compiling. Otherwise, MathTool would not know,if

Page 5: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

a + 1 is an arithmetic or a logical expression. Valid logical expressions look like a&!b, !(a&b|c)>1|d, ... MathTool returns a logical expression immediately in a simplified form, if possible. However, this may lead to increased waiting times, if the expression is too complicated and the simplification takes far too long.

2.3 Matrix expressions MathTool is also able to understand matrices and vectors. In principle, they can be expressed by the same language and indeed, MathTool makes no difference between matrices and vectors. Vectors are always interpreted as matrices with only one column. To define a matrix one uses the brackets '[' and ']', where entries in the same line are separated by a comma and rows are separated by a semicolon. For example, the expression

[1,2,5+x;0,-2/5,3]

defines a matrix with two rows and three columns. Analogously, the input

[5;-2;0;1]

defines a vector with four entries. To express sums, differences, products and powers of matrices one uses the same operators as for common expressions.

ListeallerMatrizenfunktionen:

abs(a):Computes the length ofthe vector a. cos(a):Computes the cosine ofthe matrix a. cosh(a):Computes the hyperbolic cosine ofthe matrix a. det(a):Computes the determinantofthe(quadratic) matrix a. exp(a):Computes the exponential function value ofthe matrix a. ln(a):Computes the natural logarithmofthe matrix a. tr(a):Computes the traceofthe(quadratic) matrix a. sin(a):Computes the sine ofthe matrix a. sinh(a):Computes the hyperbolic sine ofthe matrix a. trans(a):Computes the transpose ofthe matrix a.

2.4 Operators for arithmetic expression andmatrix expressions MathTool parses a collection of operators and it can simplify and evaluate them,depending on the arguments, for ordinary expressions as well as for matrix expressions. List of all available operators inMathTool: cov([x1,y1] …, [xn,yn]): Computes the covariance for the values [x1,y1] …, [xn,yn]. cross(F1, …, Fn-1):Computes the vector product F1 × … × Fn-1 of the n-dimensional vectorsF1, …, Fn-1.

Page 6: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

diff(F(x1, …, xn), xi):Computes the partial derivative ∂F/∂xiof the function (or matrix function) F with respect to the variable xi. diff(F(x1, …, xn), xi, k):Computes the k-th partial derivative ∂kF/∂xi

kof the function (or matrix function) F with respect to the variable xi. diff(F(x1, …, xn), xi, …, xj):Computes the partial derivative ∂(… ∂F/∂xi …)/∂xjof the function (or matrix function) F with respect to the variables xi, …, xj. The variables xi, …,xjdo not have to be pairwise different. div(F(x1, …, xn)):Computes the divergence div(F) = ∂F/∂x1 + ··· + ∂F/∂xnof the function (or matrix function) F. fac(n) oder n!:Computes the factorial of n. For nonnegative integers n it returns the well-known factorial n! = 1·2· ··· ·n. Factorials of negative integers return errors and for factorials of non-integers it returns (or is approximated by) the value of the gammafunctionΓ(n + 1). A factorial of an integer n will be computed explicitly only for n <= 10000. grad(F(x1, …, xn), x1, …, xn):Computes the gradient grad(F(x1, …, xn))of the function F. gcd(n1, …, nk):Computes the greatest common divisor of the integers n1, …, nk. int(F(x, a1, …, an), x):Computes the indefinite integral ∫ F(x, a1, …, an) dx ofthe function (or matrix function)F(x, a1, …, an) with respect to the variable x. int(F(x, a1, …, an), x, a, b):Computes the indefinite integral ∫a

bF(x, a1, …, an) dx ofthe function (or matrix function)F(x, a1, …, an) with respect to the variable x. The function F as well as the integration limits aand b may contain further parameters. laplace(F(x1, …, xn)):Computes the Laplace operatorΔF = ∂2F/∂x1

2 + ··· + ∂2F/∂xn2of the

function (or matrix function) F. lcm(n1, …, nk):Computes the least common multiple of the integers n1, …, nk. max(x1, …, xn):Computes the maximum of the values x1, …, xn. min(x1, …, xn):Computes the minimum of the values x1, …, xn. mod(a, b): If a and b are integers, it returns the (non-negative) remainder r of the division of a by b. modpow(a, b, c): If a, b and c are integers and b ≥ 0, it returns abmodc. mu(x1, …, xn):Computes the arithmetic mean of the values x1, …, xn. prod(F(k, x1, …, xn), k, k1, k2):Computes the product F(k1, x1, …, xn)·F(k1 + 1, x1, …, xn)· ··· ·F(k2, x1, …, xn), where F is an expression of a matrix expression, representing a square matrix. If k1>k2, the result will be 1 (or the identity matrix respectively). If k1 ork2are not integers or if their difference is too large, the product won’t be computed explicitly.

Page 7: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

rot(F(x, y, z), x, y, z):Computes the curl ofthe threedimensional vector fieldF(x, y, z) with respect to the variables x, y and z. sigma(x1, …, xn):Computes the standard deviation of the values x1, …, xn. sum(F(k, x1, …, xn), k, k1, k2):Computes the sum F(k1, x1, …, xn) + F(k1 + 1, x1, …, xn) + ··· + F(k2, x1, …, xn), where F is an expression of a matrix expression. If k1>k2, the result will be 0 (or the zero matrix respectively). If k1 or k2 are not integers or if their difference is too large, the sum won’t be computed explicitly. taylor(F(x, y1, …, yn), x, x0, k):Computes the Taylor polynomial of degree k of the function F(x, y1, …, yn) with respect to the variable x at the pointx = x0. var(x1, …, xn):Computes the variance of the values x1, …, xn.

2.5 Examples We want to see, how MathTool performs certain computations. As examples, we want to compute the resultsof the following three operations:

1. The matrixproduct−2 13 0

𝑎 4

4 −21 7

.

2. The expression − + .

3. The sum of the derivatives ln(𝑥 + 𝑦 ) + ln(𝑥 + 𝑦 ).

The inputs

[-2,1;3,0;a,4]*[4,-2;1,7]^3, (-1/2)*x+(x^4-5*x^2+x+2)/(2*x^3-x-14) and

diff(ln(x^2+y^2),x,2)+diff(ln(x^2+y^2),y,2) yieldthedesiredresults:

Page 8: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

2.6 Commands

MathTool is able to parse commands.The commands often use easy understandable names, which clearly state their purpose.Here is a list of commands, together with their syntax, which are accepted by MathTool: approx(F(x1, …, xn)):Approximates the expression F(x1, …, xn). ccnf(F(x1, …, xn)): Returns the canonical conjunctive normal form of the logical expressionF(x1, …, xn). cdnf(F(x1, …, xn)): Returns the canonical disjunctive normal form of the logical expression F(x1, …, xn). clear():Clears the entire console. However, variables and functions defined by user stay in memory. def(x = x0):Assigns to variable x the constant value x0. def(F(x1, …, xn) = G(x1, …, xn)):Defines a function F with variables x1, …, xnby the expression G(x1, …, xn). Of course, predefined functions likesin(), tan(), exp(), etc. cannot be overridden. defvars():Returns the list of all variables with predefined values. deffuncs():Returns the list of all functions defined by the user. euler(n):Returns the first n digits of Eulers constant e. The result is not rounded. For performance reasons, the integer n must not exceed 100000. eigenvalues(A):Returns the eigenvalues of the quadratic matrix A, if they are computable. eigenvectors(A):Returns the eigenvectors of the quadratic matrix A, grouped by the corresponding eigenvalues of A, if they are computable. expand(F(x1, …, xn)):Expands the expression F. latex(F(x1, …, xn) = … = G(x1, …, xn)):Generates the Latex code for the mathematical expression F(x1, …, xn) = … = G(x1, …, xn). normal(F(x1, …, xn), x1 = a1, …, xn = an):Returns the parametrization of the normal line to the graph of F at the point (x1, …, xn) = (a1, …, an). pi(n):Returns the first n digits of the constant pi. The result is notrounded. For performance reasons, the integer n must not exceed 100000. plot2d(F1(x), …, Fn(x), x, x1, x2):Plots the graphs of the functions F1, …, Fnfor x1<= x <= x2.

Page 9: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

plotimplicit2d(F1(x, y) = F2(x, y), x, y, x1, x2, y1, y2): Plots the solution of the equation F1(x, y) = F2(x, y) in two variables for x1<= x <= x2, y1<= y <= y2. plot3d(F1(x, y), …, Fn(x, y), x, y, x1, x2, y1, y2): Plots the graphs of the functionsF1, …, Fnfor x1<= x <= x2, y1<= y <= y2. plotimplicit3d(F1(x, y, z) = F2(x, y, z), x, y, z, x1, x2, y1, y2, z1, z2): Plots the solution of the equation F1(x, y, z) = F2(x, y, z) in three variables x1<= x <= x2, y1<= y <= y2, z1<= z<= z2. plotcurve2d([F1(t); F2(t)], t, t1, t2): Plots the plane curve which is given by the component functionsx = F1 and y = F2 for t1<= t <= t2. Sometimes it may happen (if choosing "bad" curves) that only a part of the is drawn (that is, for t1<= t <= t3 forsome t3<= t2). plotcurve3d([F1(t); F2(t); F3(t)], t, t1, t2): Plots the curve which is given by the component functionsx = F1, y = F2 and y = F3 for t1<= t <= t2. Sometimes it may happen (if choosing "bad" curves) that only a part of the is drawn (that is, for t1<= t <= t3 for some t3<= t2). plotpolar(F1(t), …, Fn(t), t, t1, t2): Plots the graphs of the functions F1, …, Fn for t1<= t <= t2, where t is the angle and Fi(t) is the radius in polar coordinates. plotcylindrical(F1(r, t), …, Fn(r, t), r, t, r1, r2, t1, t2): Plots the graphs of the functions F1(r, t), …, Fn(r, t) for r1<= r <= r2 and t1<= t <= t2in cylindrical coordinates, where r is the radius und t is the anglein cylindrical coordinates, where r is the radius und t is the angle. The radius must be non-negative the difference t2 – t1of the angles must be at most 20πbecause of technical reasons. plotspherical(F1(u, v), …, Fn(u, v), u, v, u1, u2, v1, v2): Plots the graphs of the functions F1(u, v), …, Fn(u, v) for u1<= u <= u2 and v1<= v <= v2in spherical coordinates, where u is the angle in the x, y-plane and v is the angle to the z-axis.The differences u2 – u1and v2 – v1of the angles must be at most20πbecause of technical reasons. plotsurface([F1(s, t); F2(s, t); F3(s, t)], s, t, s1, s2, t1, t2): Plots the surface which is given by the component functions x = F1(s, t), y = F2(s, t) and z = F3(s, t) for s1<= s <= s2and t1<= t <= t2. plotvectorfield2d([F1(x, y); F2(x, y)], x, y, x1, x2, y1, y2): Plots the vector field [F1(x, y); F2(x, y)] for x1<= x <= x2and y1<= y <= y2. plotvectorfieldpolar([F1(r, t); F2(r, t)], r, t, r1, r2, t1, t2): Plots the vector field [F1(r, t); F2(r, t)] for r1 <= r <= r2 and t1 <= t <= t2. Here, (r, t) is the polar representation of the current point and F1(r, t) is the radius and F2(r, t) the angle of the polar representation of the vector field. The zoom factor can be (almost) arbitrary. regressionline(P1, …, Pn):Computes the equation of the regression line for the points P1, …, Pn, 2 <= n, and also plots it, if possible. The points Pi must be (after simplifying) of the form [a;b], i.e. they must be (2x1)-matrices. solve(F1(x) = F2(x)):Returns the algebraic (exact) solutions of the equation F1(x) = F2(x) in x, if possible. Note, that not every equation can be solved exactly. For example, equations of the form exp(x) - x = 3 do not admit solutions which can be expressed in algebraic terms or elementary functions. In these cases, MathTool will not return any (exact) solution.

Page 10: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

solve(F1(x, a1, …, an) = F2(x, a1, …, an), x):Returns the (exact) solutions of the equation F1(x, a1, …, an) = F2(x, a1, …, an) in x (depending on the parameters a1, …, an), if possible. solve(F1(x) = F2(x), x1, x2):Returns the numerical solutions of the equation F1(x) = F2(x) in the interval x1<= x <= x2. solve(F1(x) = F2(x), x1, x2, n):Returns the numerical solutions of the equation F1(x) = F2(x) in the interval x1<= x <= x2. Here, the interval [x1, x2] is subdivided in n equal subintervals and in every subinterval at most one solution can be found. Higher n may potentially yield more solutions, but it increases the computation time. This function can be useful if the user has specific knowledge of the solutions of the equation F1(x) = F2(x). solvediffeq(F1(x, y, y‘, y“, …, y(n)) = F2(x, y, y‘, y“, …, y(n)), x, y):Returns the solution of the differential equation F1(x, y, y‘, y“, …, y(n)) = F2(x, y, y‘, y“, …, y(n)). solvediffeq(F(x, y, y‘, y“, …, y(k)), x, y, n, x0, x1, y0, y1, …, yn-1):Returns the numerical solution of the differential equation y(n) = F(x, y, y‘, y“, …, y(k)), y(x0) = y0, …, y(n-1)(x0) = yn-

1with k <= n in the interval x0<= x <= x1. For the numerical computation, the interval [x0, x1] is subdivided in 1000 subintervals and MathTool returns all 1001 function values in the corresponding points. table(F(x1, …, xn)):Returns a table with all possible values of the logical expression F(x1, …, xn), depending on the values of the variablesx1, …, xn. If n is greater than 20, no computation will be performed. tangent(F(x1, …, xn), x1 = a1, …, xn = an):Returns the equation of the tangent space to the graph of F at the point (x1, …, xn) = (a1, …, an). taylordiffeq(F(x, y, y‘, y“, …, y(k)), x, y, n, x0, y0, y1, …, yn-1, m):Returns the Taylor polynomial of degree m of the solution of the differential equation y(n) = F(x, y, y‘, y“, …, y(k)), y(x0) = y0, …, y(n-1)(x0) = yn-1with k <= n. undeffuncs(f1, …, fn):Removes the functions f1, …, fn. undefvars(x1, …, xn):The variables x1, …, xn are again indeterminate, that is, without value assigned. undefallfuncs():Removes all functions, which were defined during this session. undefallvars():All variables, which are assigned a value during this session, are again indeterminates. undefall():Removes all functions and all variables, which were defined during this session. For a better illustration we consider some examples. The commands for graphical presentation of function graphs we treat in a separate chapter.

2.6.1 Example 1: Approximation ofexpressions

Page 11: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

Wo want to approximate the expression √4327 + sin . The input

approx(4327^(1/7)+sin(pi/9))

yields the following output by MathTool:

2.6.2 Example 2: Definition of new functions and variables The variable a is to set to the fixed value 5/7 (at least temporary). The input

def(a=5/7) yields an output, that the variable a attains the value 5/7:

Pay attention, that as long as the variable a has a fixed value, it cannot be used for computations, which require indeterminate. For example, the command solve(a^2=7,a) (i.e.

solving the equation𝑎 = 7by the variable a) throws an error. The command

undefvars(a) removes the fixed value from the variable a.

Now, we want to define the function 𝑓(𝑥, 𝑦) = 𝑥 + 𝑦. The corresponding command

def(f(x,y)=x^2+sqrt(y))

yieldstheoutput:

Page 12: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

Here, MathTool provides technical names for the parameter variables (𝑈 , 𝑈 , 𝑈 , …), instead of x, y, since in this way we avoid name clashes (remember that variables, which can be used by a user, do not contain capital letters).Similarly, the command

undeffuncs(f) removes the function f from the memory.

2.6.3 Example3: Solvingequations We want to solve the equation 𝑥 − 2𝑥 − 3𝑥 + 11𝑥 − 10 = 0. Here, we simply use the command

solve(x^4-2*x^3-3*x^2+11*x-10 = 0) and we obtain immediately the desired solutions:

Similarly, the command

solve(5^x+25^x=a,x) yields solutions of the equation 5 + 25 = 𝑎 by the variable x, which depend on our parameter a:

Page 13: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

2.6.4 Example 4: Solving systems of equations We want to solve the system of equations 𝑥 𝑦 + 𝑥𝑦 = 42, −𝑥𝑦 + 𝑥 𝑦 = 102 with respect to the variables x and y. The command

solvesystem(x^3*y+x*y^2=42,-x*y+x^2*y^3=50,x,y) then yields the following output:

2.6.5 Example 5: Solving ordinary differential equations To obtain the general solution of the ordinary differential equation (𝑦 − 2𝑦)(𝑦 − 𝑦 ) =

0(where 𝑦 = 𝑦(𝑥)is a function in x), we enter the following command:

solvediffeq((y''-2*y)*(y''-y^2)=0,x,y) MathTool return implicit as well as explicit solutions of the differential equation:

3. Graphicalrepresentations

Page 14: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

Another feature of MathTool is its quite big library of techniques for graphical representation of mathematical objects.These graphics can also be exported, which can be useful for various presentations. Mathematics knows many different methods to present mathematical objects in form of graphics. Besides the “common” graphical representation of two and three dimensional graphs one also prefers to represent such graphs in polar coordinates, cylindrical coordinates and spherical coordinates. Also, there are situations where one needs to represent graphically a graph of a function which is defined implicitly (i.e. by an equation of the form 𝐹(𝑥, 𝑦) = 0) instead of the common presentation 𝑦 = 𝑓(𝑥)). Similarly, one can define implicit function in three dimensions in the same way. MathTool implements corresponding algorithms for such graphical representations of functions. Here is a list of all commands, which dealwith graphical representation of a function: plot2d(F1(x), …, Fn(x), x, x1, x2):Plots the graphs of the functions F1, …, Fnfor x1<= x <= x2. plotimplicit2d(F1(x, y) = F2(x, y), x, y, x1, x2, y1, y2):Plots the solution of the equation F1(x, y) = F2(x, y) in two variables for x1<= x <= x2, y1<= y <= y2. plot3d(F1(x, y), …, Fn(x, y), x, y, x1, x2, y1, y2):Plots the graphs of the functionsF1, …, Fnfor x1<= x <= x2, y1<= y <= y2. plotimplicit3d(F1(x, y, z) = F2(x, y, z), x, y, z, x1, x2, y1, y2, z1, z2): Plots the solution of the equation F1(x, y, z) = F2(x, y, z) in three variables x1<= x <= x2, y1<= y <= y2, z1<= z<= z2. plotcurve2d([F1(t); F2(t)], t, t1, t2):Plots the plane curve which is given by the component functionsx = F1 and y = F2 for t1<= t <= t2. Sometimes it may happen (if choosing "bad" curves) that only a part of the is drawn (that is, for t1<= t <= t3 for some t3<= t2). plotcurve3d([F1(t); F2(t); F3(t)], t, t1, t2):Plots the curve which is given by the component functions x = F1, y = F2 and y = F3 for t1<= t <= t2. Sometimes it may happen (if choosing "bad" curves) that only a part of the is drawn (that is, for t1<= t <= t3 for some t3<= t2). plotpolar(F1(t), …, Fn(t), t, t1, t2):Plots the graphs of the functions F1, …, Fn for t1<= t <= t2, where t is the angle and Fi(t) is the radius in polar coordinates. plotcylindrical(F1(r, t), …, Fn(r, t), r, t, r1, r2, t1, t2):Plots the graphs of the functions F1(r, t), …, Fn(r, t) for r1<= r <= r2 and t1<= t <= t2in cylindrical coordinates, where r is the radius und t is the anglein cylindrical coordinates, where r is the radius und t is the angle. The radius must be non-negative the difference t2 – t1of the angles must be at most 20πbecause of technical reasons. plotspherical(F1(u, v), …, Fn(u, v), u, v, u1, u2, v1, v2):Plots the graphs of the functions F1(u, v), …, Fn(u, v) for u1<= u <= u2 and v1<= v <= v2in spherical coordinates, where u is the angle in the x, y-plane and v is the angle to the z-axis.The differences u2 – u1and v2 – v1of the angles must be at most20πbecause of technical reasons.

Page 15: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

plotsurface([F1(s, t); F2(s, t); Fthe component functions x = Ft2. plotvectorfield2d([F1(x, y); Fy)] for x1<= x <= x2and y1<= y <= y For example, the commands

plot3d(exp(-(x^2+y^2)/4)*sin(3*(x^2+y^2)^(1/2)),x,y, and

plot3d(x^3+sin(5*x*y) respectively yields the following three dimensional graphics

The graphical representation of implicit function in the three dimensional space (which is obtained by the command plotimplicit3dthe so calledMarchingCubesAlgorithmalgorithm subdivides the ambient space in very small cuboids andof every cuboid, whether it is contained in the interior of the graph or not.Depending on these vertex constellations, the Marching Cubes Algorithm elementary polygons (see 4.3)implicit equation𝑥 + 𝑦 + 𝑧

plotimplicit3d(x^2+y^2+z^2=1,x,y,z,

yieldsthefollowinggraphic:

(s, t); F3(s, t)], s, t, s1, s2, t1, t2):Plots the surface which is given by the component functions x = F1(s, t), y = F2(s, t) and z = F3(s, t) for s1<= s <= s

(x, y); F2(x, y)], x, y, x1, x2, y1, y2):Plots the vector field [F<= y <= y2.

(x^2+y^2)/4)*sin(3*(x^2+y^2)^(1/2)),x,y,-3,3,-

lot3d(x^3+sin(5*x*y)-y^3,x,y,-1,1,-1,1)

respectively yields the following three dimensional graphics:

The graphical representation of implicit function in the three dimensional space (which is plotimplicit3d) is a very non-trivial problem. MathTool implements

MarchingCubesAlgorithm, which is designed for solving this pralgorithm subdivides the ambient space in very small cuboids and determines for every vertex of every cuboid, whether it is contained in the interior of the graph or not.Depending on these vertex constellations, the Marching Cubes Algorithm approximates the graph by certain

(see 4.3).For example, a sphere with radius 𝑅 =

𝑧 = 1, and the corresponding command

plotimplicit3d(x^2+y^2+z^2=1,x,y,z,-2,2,-2,2,-2,2)

Plots the surface which is given by <= s <= s2and t1<= t <=

Plots the vector field [F1(x, y); F2(x,

-3,3)

The graphical representation of implicit function in the three dimensional space (which is trivial problem. MathTool implements

, which is designed for solving this problem.This determines for every vertex

of every cuboid, whether it is contained in the interior of the graph or not.Depending on these oximates the graph by certain

= 1 is given by the

Page 16: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

4. Complexproblemsandalgorithms

4.1 The Rischalgorithm

One of the main features of MathToolis theimplementationof the Risch algorithmfor transcendentalfunctions (note, that no computer algebra system implements the Risch algorithm for arbitrary functions, since the general Risch algorithm contains a step with an unsolvable problem and hence, it is not a proper algorithm). TheRisch algorithm is a (semi-) algorithm, which decides, whether a function 𝑓(𝑥)admits an elementary integral function F(x) = ∫ 𝑓(𝑥) 𝑑𝑥, and allows moreover to compute it in the affirmative case.For example, the Risch algorithm yields that the integral

𝑒

𝑥𝑑𝑥

is not elementary.But, on the other hand,it yields that the integral of the function𝑓(𝑥) =

( ) –

( ) ( ) is elementary, and gives furthermore a precise instruction how to obtain the

desired integral F(x). Following the Risch algorithm, we obtain:

𝐹(𝑥) = 𝑥

𝑥 + 𝑙𝑛(𝑥)

Modern computer algebra systems implement the Risch algorithm, at least for the transcendental case. The algebraic case is quite more sophisticated and belongs in general to unsolvable problems.

Page 17: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

4.2 Groebnerbasesand the

Another complicated problem, which can be solved by modern computer algebra systems, is solving of arbitrary systems of equationsequations requires the implementation of the algorithm computes for a given family of polynomials

anotherfamily of polynomials „better properties“. Unfortunately, the case complexity (with respect to MathTool also implements the Buchberpolynomial equations. For example, we want to solve the system of equations 12 .The theoryof Gröbnerbasepolynomial system into another, equations (and in particular, the nonsolution 𝑥 = 2, 𝑦 = 3 another, more complicated,

4.3 Implicitfunctionsandthe

Plotting of implicitly given functions case there may occur self-intersections, in contrast to the case of explicit functionsThis problem can be solved by the so calledroughly speaking, of the following steps

1. The ambient space (a cuboid) is subdivided into finer cuboids aone decides, whether this vertex belongs to the “interior” of the grap

2. Depending on the configuration of the inner vertices from step 1, one polygons, which are best approximations for the given piece of the graph

3. Draw polygons from step 2 for every cuboid ambient space.

For example, the command

plotimplicit3d(x^3*y

theBuchberger algorithm

Another complicated problem, which can be solved by modern computer algebra systems, is solving of arbitrary systems of equations. In particular, solving systems of polynomial equations requires the implementation of the Buchberger algorithm

computes for a given family of polynomials

𝑓 (𝑥 , . . . , 𝑥 ), … , 𝑓 (𝑥 , . . . , 𝑥 )

notherfamily of polynomials 𝑔 (𝑥 , . . . , 𝑥 ), … , 𝑔 (𝑥 , . . . , 𝑥 ), which admit in some senseUnfortunately, the Buchberger algorithm has double exponential

case complexity (with respect to thenumbern of the variables occurring in the polynomialsMathTool also implements the Buchberger algorithm and hence, it is able to solve

For example, we want to solve the system of equations 𝑥 𝑦 + 𝑥𝑦 + 𝑦

Gröbnerbases (in particular, the Buchberger algorithm) transforms this polynomial system into another, easier, system, which allows us to get all solutions equations (and in particular, the non-trivial ones). SoMathTool returns besides of the

, more complicated, solutions:

functionsandtheMarchingCubesAlgorithm

implicitly given functions belongs to the more sophisticated problemsintersections, in contrast to the case of explicit functions

This problem can be solved by the so calledMarchingCubesAlgorithmllowing steps:

The ambient space (a cuboid) is subdivided into finer cuboids aone decides, whether this vertex belongs to the “interior” of the grapDepending on the configuration of the inner vertices from step 1, one polygons, which are best approximations for the given piece of the graph

olygons from step 2 for every cuboid according to the subdivision of the

plotimplicit3d(x^3*y-y^3*z+z^3*x=1,x,y,z,-3,3,-3,3,-3,3)

Another complicated problem, which can be solved by modern computer algebra systems, is In particular, solving systems of polynomial

lgorithm. TheBuchberger

, which admit in some sense double exponential worst

the polynomials). and hence, it is able to solvesystems of

𝑦 = 21, 𝑦 𝑥 − 𝑥𝑦 =

s (in particular, the Buchberger algorithm) transforms this which allows us to get all solutions of this SoMathTool returns besides of the obvious

belongs to the more sophisticated problems, since in this intersections, in contrast to the case of explicit functions.

MarchingCubesAlgorithm, which consists,

The ambient space (a cuboid) is subdivided into finer cuboids and for each vertex one decides, whether this vertex belongs to the “interior” of the graph or not. Depending on the configuration of the inner vertices from step 1, one constructs polygons, which are best approximations for the given piece of the graph.

the subdivision of the

3,3)

Page 18: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

plots the graph of the implicit function x, y, z ≤3. The resulting graphic is as follows

Note:Plottingof graphs of two dimensional implicit functions works in a similar way. It uses the so calledMarchingSquares AlgorithmCubes Algorithm, but we have much fewer cases for the corresponding polytopes compared to the three dimensional case.

5. Algorithms in MathTool

5.1 The language MAL a

MathTool offers the possibility to write and to execute own algorithms. The syntax of this algorithm language called MAL (MathTool Algorithm Language) leans on the syntax of the object oriented language Java, but is quite more simple, because it is dmathematical problems.

5.2 Reserved characters and keywords

A number of characters are reserved in MAL and may because the compiler assigns them specific functions. Here is an overview of all reserved characters and operators.

plots the graph of the implicit function 𝑥 𝑦 − 𝑦 𝑧 + 𝑧 𝑥 = 1 inside the cube given by . The resulting graphic is as follows:

graphs of two dimensional implicit functions works in a similar way. It uses MarchingSquares Algorithm.The algorithm itself is similar to the

but we have much fewer cases for the corresponding polytopes compared

in MathTool

and itssyntax

MathTool offers the possibility to write and to execute own algorithms. The syntax of this algorithm language called MAL (MathTool Algorithm Language) leans on the syntax of the object oriented language Java, but is quite more simple, because it is designed for solving

Reserved characters and keywords

A number of characters are reserved in MAL and may only be used in a specific context because the compiler assigns them specific functions. Here is an overview of all reserved

inside the cube given by -3 ≤

graphs of two dimensional implicit functions works in a similar way. It uses The algorithm itself is similar to the Marching

but we have much fewer cases for the corresponding polytopes compared

MathTool offers the possibility to write and to execute own algorithms. The syntax of this algorithm language called MAL (MathTool Algorithm Language) leans on the syntax of the

esigned for solving

in a specific context because the compiler assigns them specific functions. Here is an overview of all reserved

Page 19: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

Reservedcharacter Definition , Separation ofparametern ; Separation ofcommands { and } Beginning and end of a code block ( and ) Beginning and end of parameters within the

signature of a method or of a condition inside a control structure

[ and ] Beginning and end of a matrix & And | Or ! Negation = Definition == Comparison on equality of values > Greaterthan >= Greaterorequalthan < Smallerthan <= Smallerorequalthan + Addition ofexpressions

Similarly, a number of keywords are reserved in MAL and may only be used in a particular context because the compiler assigns them particular meanings. Hereis an overviewof all reservedkeywords. Key word Definition main Entry point for every MAL programm false Boolean value „false“ true Boolean value „true“ return Exit point for an algorithm and instruction for

returning an identifier, if necessary. break Cancel a loop continue Instruction to continue in a loop if If else Else while Beginning of awhile loop do Beginning of a do while loop for Beginning of a for loop

5.3 Structure and priciples of MAL Any number of algorithms can be implemented in an algorithm file as long as they satisfy the following conditions:

1. The algorithms all have different signatures. A signature always consists of the name of the algorithm as well as the ordered tuple of input parameter types.

2. There exists an algorithm named "main" which is parameterless. The return type can be arbitrary (and alsoempty). This algorithm is the main entry point, as is the case in a classic Java application.

3. With a few exceptions, subalgorithm calls (that is, algorithms that are not named "main") are always call-by-value. The latter means that if an input parameter within the subalgorithmis

Page 20: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

assigned a new value, it then returns to its original value (i.e. the value it had possessed immediately before the subroutine was called) after the call of the subalgorithm.The (so far) only subalgorithms, which work according to the call-by-reference principle, are the MAL-internal methods inc and dec, which receive a variable of the type expression as the only parameter. The function inc increases the value of the passed variable by 1, decdecreases it by 1.

5.4 Data types First of all, MAL knows four different data types, which can be found in the following overview:

Data type Definition expression Arithmeticalexpression booleanexpression Boolean expression matrixexpression Matrix expression string String (a chain of characters)

1. The data type expression, i.e. a mathematicalexpression.Here, no further distinction is made, the expression being an integer (which in many programming languages is indicated as int or integer) or a complex expression. Example:expression a = 15;

2. The data typematrixexpression, also ein Matrizenausdruck.

Example:matrixexpression a = [1,2;4,1+x;2,7]; Here, x is an already definedvariable of typeexpression.

3. The data typebooleanexpression, i.e. a Boolean expression. Example:booleanexpression a = x >= 24; Here, x is an already definedvariable of typeexpression.

4. The data typestring, i.e. a chain of characters. Example: string a = “The variable x has the value “+a; Here, x is an already definedvariable of arbitrary type, for example of typeexpression.

5.5 Standard commands and standard algorithms MAL also knows some predefined commands and algorithms. The following is a complete list of commands defined in MAL:

Return type and signature Definition inc(expression) Erhöht den Wert des Parameters um 1. dec(expression) Reduziert den Wert des Parameters um 1.

Page 21: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

expression entry(matrixexpression,expression,expression)

Gibt den (i,j)-Eintrag der Matrix im 1. Parameter, wobei i der zweite und j der 3. Parameter ist, falls sich der Matrizenausdruck im 1. Parameter zu einer Matrix vereinfachen lässt. Wichtig: Die Indexzählung beginnt bei 0.

print(expression) Gibt den Parameter in der Konsole aus. print(matrixexpression) Gibt den Parameter in der Konsole aus. print(booleanexpression) Gibt den Parameter in der Konsole aus. print(string) Gibt den Parameter in der Konsole aus. approx(expression) Returns the approximated value of the given

expression. approx(matrixexpression) Returns the approximated value of the given

matrix expression.

5.6 Examples Below are some code samples with a detailed discussion.

5.6.1 Example 1: The first algorithm We consider the following code: expression main(){ expression result=1; if(result>0){ result=3*result; } return result; } Running the code yields the following output:

First, the identifier resultis assigned the value 1. The conditionresult> 0 is true, and thus result is set to the value 3 * result = 3. After that,MathTool returns the identifierresult.

5.6.2 Example2: Call of further algorithms We consider the following code: expression main(){ expression a=1; for(expression i=0,f(i)<=10,i=i+g(i)){

Page 22: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

a=3*a+2; } return a; } expression f(expression i){ return 2*i; } expression g(expression i){ return i^2+1; } Running the code yields the following output “53” for the identifier a. The computation is as follows:

In the For loop, i takes the following values: i = 0, i = 1 and i = 3 according to the increment instruction𝑖← 𝑖 + 𝑔(𝑖) = 𝑖 + 𝑖 + 1.Thus, a is replaced three times by 3 * a + 2, giving successively the values 5, 17, and 53.

5.6.3 Example3: Algorithm withmatrices We consider the following code: matrixexpression main(){ matrixexpression a=[1,2;3,4]; for(expression i=0,i<=3,i=i+1){ a=a^2; } return a; } In other words, the matrix a is squared four times, the result is therefore

𝑎 =115007491351 167615035490251422553235 366430044586

Indeed, running the code yields the following output:

Page 23: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

5.6.4 Example 4: Error due to missing return value The algorithm expression main(){ expression result=1; if(result>0){ result=3*result; } } returns an error when compiling, as it requires an expression as the return value, but this returns nothing. 5.7 Code generation MathTool's Algorithm Compiler also provides a little help for generating code. Before we go any further into this generation aid, it should be said at this point that the code generated in this way is not necessarily compilable or executable. This is due to the following reasons:

1. It is possible to generate method hulls, which are however without return value. This must always be added manually. Direct compilation would throw a corresponding error, at least in cases where a method expects a return value.

2. If you generate commands with parameters, you can freely choose the parameter name, but it is not certain that this parameter has been previously defined in the code. This istheresponsibility oft he user.

3. When defining mathematical expressions, syntactic correctness is not checked. 4. When generating control structures, all necessary conditions must be specified, but it is not

checked for syntactic correctness. This is also to be ensured by the user beforehand. In the following we consider the code generation mechanism more in detail.

5.7.1 Generate the main algorithmsand subroutines Under Code >Generate code >Generate main algorithmappears a GUI, where one can define the return value typeofthe main algorithm. The empty choice results in a main algorithm with void return type. Under Code >Generate code>Generate subroutinea GUI appears in which you can specify the name, the return value and the individual parameters of the subroutine. With an empty selection, the return value of the subroutine is accordingly empty. Of course, the individual parameters can also be removed if the user made a mistake.

Page 24: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

5.7.2 Generate Identifier definition Under Code >Generate Code >Generate command>Generate definition of identifiera GUI appears in which you can specify the type, name and value of the new identifier. The command can also be generated if no value has been set. In this case, a pure identifier declaration is generated without value assignment.

5.7.3 Generatecontrolstructures UnterCode >Generate Code >Generate control structureyou can generate any control structure supported by MAL. For example, under Generate if elsecontrol structure, you can generate an if else control structure by entering a Boolean condition.

Page 25: MathTool manual - EN - sergei-kovalenko.desergei-kovalenko.de/wp-content/uploads/2016/07/MathTool-manual-v… · &rqwhqwv í x t z ] d zd } } o m x x x x x x x x x x x x x x x x x

5.7.4 Generatereturncommand UnterCode >Generate Code>Generate command >Generate return command, a GUI appears in which you can specify the name of the identifier to be returned.

5.8 In the next versions The language MAL is still under construction. Accordingly, many useful features are not yet implemented. In the next versions, for example, dealing with arrays is planned so that, for example, solutions of equations can be stored therein and be further processed. Likewise, a debug mode will be implemented soon, which significantly improves the fixing of bugs.