iconEuler Home

The Syntax of Euler

This notebook presents a rather complete overview of the syntax of
Euler, including its numerical and symbolic commands, variables and
assignments. 

We start with command lines.

An Euler command can be an expression or a primitive command. An
expression is made of operators and functions. If necessary, it must
contain brackets to force the correct order of execution. In doubt,
setting a bracket is a good idea.
>(cos(pi/4)+1)^3*(sin(pi/4)+1)^2
14.4978445072
Euler interprets the command line and executes it at the same time. It
does not preview the syntax.

In the following example, we see a correct expression with an extra
closing bracket. Euler will print the result. But we also get an error
message.
>(3+4))
7
Found too many closing brackets )!

Error in :
(3+4))
     ^
The numerical operators of Euler include

+ unary or operator plus
- unary or operator minus
*, /
a^b power for positive a or integer b
n! the faculty operator

and many more.

Here are some of the most functions you might need. There are many
more.

sin,cos,tan,atan,asin,acos,rad,deg
log,exp,log10,sqrt,logbase
bin,logbin,logfac,mod,floor,ceil,round,abs,sign
conj,re,im,arg,conj,real,complex
beta,betai,gamma,complexgamma,ellrf,ellf,ellrd,elle
bitand,bitor,bitxor,bitnot

Some commands have aliases, e.g. ln for log.
>ln(E^2), arctan(tan(0.5))
2
0.5
Trigonometric functions work in radians. To convert, use the degree
symbol (F7), or the deg(x) conversion.
>sin(30°)
0.5
Make sure to use brackets, whenever there is doubt about the order of
execution! The following is not the same as 2^(3^4), which is the
default for 2^3^4 in Euler.
>(2^3)^4
4096

Numerical Variables

Numerical variables are assigned with := or =. We use := in this
overview, since it displays the assignment in a clear way. An
assignment prints the assigned value, unless it is followed by a
semicolon.
>r := 2.24
2.24
Other assignment operators are covered later, but we give a complete
list for reference here.

a := 3 // numerical
a &= x^2 // symbolical
a &:= 3 // numerical value for symbolical expressions

Expressions can use variables and constants. The constant pi is
defined in Euler as a function pi(), which can be called without the
brackets.
>r^2*pi
15.7632552987
Euler allows to omit the multiplication sign immediately after
numbers.
>2r
4.48
This binds stronger than other operators.
>1/2r
0.223214285714
An example for an Euler command is "listvar", which prints all defined
variables.
>listvar
r                   2.24
Variable names can contain "$", but not start with "$". They cannot
contain "_", since this is an operator in Euler. For special purposes
(see below) they can end with "$" or start with "_".
>last$x:=4, 32+last$x
4
36
To delete a variable, use remvalue. This works only globally not from
within a function.
>remvalue last$x
There is a special variable %, which stores the previous result. But
it is only available for global commands. In a function, use a proper
variable instead.
>3+4; %*5
35

Several Commands

A command line of Euler consists of one or several Euler commands
followed by a semicolon ";" or a comma ",". The semicolon prevents the
printing of the result. The comma after the last command can be
omitted.

The following command line will only print the result of the
expression, not the assignments or the format commands. "shortformat"
and "longformat" are functions, which can be called without any
parameters in Euler.
>shortformat; r:=2; h:=4; pi*r^2*h/3, longformat;
16.755
For reference, here is a list of the most important output formats.

shortestformat, shortformat, longformat (the default), longestformat.
format(length,digits)
goodformat(length)
fracformat(length)

Within one command line % refers to the previous result. We remark
that this does not work in functions, only in the command line. Both
results are printed in the following command line due to the comma
after the first command.
>pi*2*r*h, %+2*pi*r*h
50.2654824574
100.530964915
Command lines are executed in the order the user presses return. So
you get a new value each time you execute the second line.
>x := 1;
>x := cos(x)
0.540302305868
>x := cos(x)
0.857553215846
If two lines are connected with "..." both lines will always execute
simultaneously.
>x := 1.5; ...
 x := (x+2/x)/2, x := (x+2/x)/2, x := (x+2/x)/2, 
1.41666666667
1.41421568627
1.41421356237
This is also a good way to spread a long command over two or more
lines.

You can press Ctrl+Return to split a line in two at the current cursor
position.
>plot2d("1-x+x^2/2-x^3/4+x^4/4-x^5/5+x^6/6", ...
   a=0,b=2,c=0,d=2,color=blue,style="--",thickness=2);   ...
   plot2d("exp(-x)",add=true,color=gray):

00 - Overview of the Syntax of Euler

Euler supports loops, as long as they fit into one single line. For
more information consult the notebook about programming.

  05 - Introduction to Programming
>x := 1.5; for i=1 to 10; x := (x+2/x)/2; end; x,
1.41421356237

Real Numbers

The primary data type in Euler is the real number. Reals are
represented in IEEE format with about 16 decimal digits of accuracy.
>longestformat; 1/3, longformat;
     0.3333333333333333 
The internal dual representation takes 8 bytes.
>printdual(1/3)
1.0101010101010101010101010101010101010101010101010101*2^-2

Units

Euler can convert units, but it does not check if the conversion makes
sense. The units are stored in global variables, which end with "$".
These variables are globally visible in functions.
>rEarth$, cm$,
6367453.47766
0.01
A unit variable can be appended to a number to convert from the unit
to the standard units (IS system). If a unit is used like this, the
"$" can be omitted.
>5inch
0.127
There is a special operator -> to convert units, which converts either
to a number or to a string.
>5km/hour->miles/day, 5kJ->" cal"
74.5645430685
1194.22948314 cal
Here is a list of all units in Euler. It includes some other
variables, which are defined with $.

  ../reference/units

The units module does also contain some functions.
>FahrenheitToCelsius(100)
37.7777777778

Complex Numbers

For more details, see the introduction on complex numbers.

  07 - Introduction to Complex Numbers

Complex numbers are entered using the constant I or with the 1i
syntax.
>I^2, 1+3i
-1+0i 
1+3i
Euler uses the principal values to compute logarithms and square roots
for complex numbers, making these functions analytic in the plane cut
along the negative axis.
>sqrt(-1+0.01i), sqrt(-1-0.01i),
0.00499993750273+1.00001249961i
0.00499993750273-1.00001249961i
Some functions return complex values by default. The values can be
made real, if they are real. If they are not within the numerical
accuracy epsilon(), an error will be generated. 

An example is the function polysolve, which finds the roots of a
polynomial. We apply it to the Chebyshev polynomial of degree 5.
>real(polysolve(chebpoly(5)))
[ 0  0.587785252292  0.951056516295  -0.587785252292  -0.951056516295 ]

Intervals

For details about intervals, see the introduction notebook.

  08 - Introduction to Interval Computation

Intervals are entered using plusminus, or the with the ~a,b~ notation.
>1±0.1, ~0.7,1.3~
~0.9,1.1~
~0.7,1.3~
The basic rule for intervals is:

Operators and functions compute all possible results for all numbers
in each parameter interval, and find an enclosing interval for all
these results.

The resulting interval is not always the smallest possible. But for
the usual operators, it is very close to the optimal interval.
>~0,2~*~3,4~, ~-1,1~^2, cos(~1,5~)
~0,8~
~0,1~
~-1,0.54~
There are functions for guaranteed inclusions of solutions in Euler.
These functions return intervals or vectors of intervals. An example
is ilgs, which returns an inclusion for the solution of linear
systems.
>ilgs(hilbert(8),sum(hilbert(8)))
 ~0.99999999999999978,1.0000000000000002~ 
 ~0.99999999999999978,1.0000000000000002~ 
 ~0.99999999999999967,1.0000000000000002~ 
    ~0.999999999999998,1.000000000000002~ 
 ~0.99999999999999867,1.0000000000000011~ 
 ~0.99999999999999778,1.0000000000000024~ 
 ~0.99999999999999789,1.0000000000000018~ 
 ~0.99999999999999956,1.0000000000000007~ 

Vectors and Matrices

The following notebooks contain more details about vectors, matrices,
and the matrix language of Euler.

  01 - Introduction to the Matrix Language
  04 - Introduction to Linear Algebra

A matrix is entered using "[...]" with the values in each row
separated by commas, the rows separated by semicolons. You may wish to
select a shorter format for output.
>shortestformat; [1,2,3;4,5,6]
        1         2         3 
        4         5         6 
Row vectors are printed in a compact format by default.
>[1,2,3,4]
[ 1  2  3  4 ]
For matrices the special operator . denotes matrix multiplication, and
A' denotes transposing. A 1x1 matrix can be used just like a real
number.
>v:=[1,2]; v.v', %^2
[ 5 ]
25
Operators and functions obey the matrix language of Euler. For
details, see the special notebook about the matrix language.

Here is just a summary of the rules.

- A function applied to a vector or matrix is applied to each element.

- An operator operating on two matrices of same size is applied
pairwise to the elements of the matrices.

- If the two matrices have different dimensions, both are expanded in
a sensible way, so that they have the same size.

E.g., a scalar value times a vector multiplies the value with each
element of the vector. Or a matrix times a vector (with *, not .)
expands the vector to the size of the matrix by duplicating it.

The following is a simple case with the operator ^.
>[1,2,3]^2
[ 1  4  9 ]
Here is a more complicated case. A row vector times a column vector
expands both by duplicating.
>v:=[1,2,3]; v*v'
        1         2         3 
        2         4         6 
        3         6         9 
Note that the scalar product uses the matrix product, not the *!
>v.v'
[ 14 ]
There are numerous functions for matrices. We give a short list. You
should to consult the documentation for more information on these
commands.

sum,prod computes the sum and products of the rows
cumsum,cumprod does the same cumulatively
min,max computes the extremal values of each row
extrema returns a vector with the extremal information
diag(A,i) returns the i-th diagonal
setdiag(A,i,v) sets the i-th diagonal
id(n) the identity matrix
det(A) the determinant
charpoly(A) the characteristic polynomial
eigenvalues(A) the eigenvalues
>v*v, sum(v*v), cumsum(v*v)
[ 1  4  9 ]
14
[ 1  5  14 ]
The : operator generates an equally spaces row vector, optionally with
a step size.
>1:4, 1:2:10
[ 1  2  3  4 ]
[ 1  3  5  7  9 ]
To concatenate matrices and vectors there are the operators "|" and
"_".
>[1,2,3]|[4,5], [1,2,3]_1
[ 1  2  3  4  5 ]
        1         2         3 
        1         1         1 
The elements of a matrix is referred with "A[i,j]".
>A:=[1,2,3;4,5,6;7,8,9]; A[2,3]
6
For row or column vectors, v[i] is the i-th element of the vector. For
matrices, this returns the complete i-th line of the matrix.
>v:=[2,4,6,8]; v[3], A[3]
6
[ 7  8  9 ]
The indices can also be row vectors of indices. : denotes all indices.
>v[1:2], A[:,2]
[ 2  4 ]
        2 
        5 
        8 
A short form for : is omitting the index completely.
>A[,2:3]
        2         3 
        5         6 
        8         9 

Strings

A string in Euler is defined with "...".
>"A string can contain anything."
A string can contain anything.
Strings can be concatenated with | or with +. This also works with
numbers, which are converted to strings in that case.
>"The area of the circle with radius " + 2 + " cm is " + pi*4 + " cm^2."
The area of the circle with radius 2 cm is 12.6 cm^2.
The print function does also convert a number to a string. It can take
a number of digits and a number of places (0 for dense output), and
optimally a unit.
>"Golden Ratio : " + print((1+sqrt(5))/2,5,0)
Golden Ratio : 1.61803
There is a special string none, which does not print. It is returned
by some functions, when the result does not matter. (It is returned
automatically, if the function does not have a return statement.)
>none
To define a string vector, use the vector [...] notation.
>v:=["affe","charlie","bravo"]
affe
charlie
bravo
The empty string vector is denoted by [none]. String vectors can be
concetenated.
>w:=[none]; w|v|v
affe
charlie
bravo
affe
charlie
bravo

Boolean Values

Boolean values are represented with 1=true or 0=false in Euler.
Strings can be compared, just like numbers.
>2<1, "ape"<"banana"
0
1
"and" is the operator "&&" and "or" is the operator "||", as in the C
language. (The words "and" and "or" can only be used in conditions for
"if".)
>2<E && E<3
1
Boolean operators obey the rules of the matrix language.
>(1:10)>5, nonzeros(%)
[ 0  0  0  0  0  1  1  1  1  1 ]
[ 6  7  8  9  10 ]
You can use the function nonzeros to extract specific elements form a
vector. In the example, we use the conditional isprime(n).
>N=2|3:2:99; N[nonzeros(isprime(N))]
[ 2  3  5  7  11  13  17  19  23  29  31  37  41  43  47  53  59  61  67
71  73  79  83  89  97 ]

Numerical Expressions

For examples of numerical expressions, have a look at the first
introduction notebook.

  00 - A first Welcome

Strings can contain mathematical expressions, which can be evaluated
by Euler. For this, use brackets after after the expression.

Global variables can be used in the evaluation.
>longformat; r:=2; expr:="pi*r^2"; expr()
12.5663706144
Parameters are assigned to x, y, and z in that order. Additional
parameters can be added using assigned parameters.
>expr:="a*sin(x)^2"; expr(5,a=-1)
-0.919535764538
Expressions in x are often used just functions. E.g., the following
command plots a function in x and y.
>plot3d("x*y^2",r=2):

00 - Overview of the Syntax of Euler

Symbolic Expressions and Variables

Symbolic expressions and variables are explained in detail in the
Maxima notebook.

  10 - Introduction to Maxima

Symbolic epxressions are special strings in Euler. They are defined
with "&...". Euler scans the input to find the end of the symbolic
expression automatically.

Symbolic expressions are printed by Maxima in 2D form.
>&(3+x)/(x^2+1)
                                x + 3
                                ------
                                 2
                                x  + 1

Symbolic expressions are parsed by Euler. If you need a complex syntax
in one expression, you can enclose the expression in "...". To use
more than a simple expression is possible, but stronly discouraged.
>&"v := 5; v^2"
                                  25

For completeness, we remark that symbolic expressions can be used in
programs, but need to be enclosed in quotes. Moreover, it is much
better to call Maxima at compile time.

  05 - Introduction to Programming

Symbolic variables are defined with "&=".
>fexpr &= (x+1)/(x^4+1)
                                x + 1
                                ------
                                 4
                                x  + 1

Symbolic expressions can be used in other symbolic expressions.
>&factor(diff(fexpr,x))
                               4      3
                          - 3 x  - 4 x  + 1
                          -----------------
                                4     2
                              (x  + 1)

If you have Latex installed, you can print a symbolic expression with
Latex. If not, the following command will issue an error message. 

Learn about how to install Latex for Euler in the documentation.

  ../documentation/installation

To print a symbolic expression with Latex, use $... instead of &...
Comment out the following command, if you have Latex installed.
>$factor(diff(fexpr,x,2))

00 - Overview of the Syntax of Euler

To get the Latex code for an expression, you can use the tex command.
>tex(fexpr)
\frac{x+1}{x^4+1}
Symbolic expressions can be evaluated just like numerical expressions.
>fexpr(0.5)
1.41176470588
In symbolic expressions, this does not work, since Maxima does not
support it. Instead, use the "with" syntax (a nicer form of the
at(...) command of Maxima).
>&fexpr with x=1/2
                                  24
                                  --
                                  17

The assignment can also be symbolic.
>&fexpr with x=1+t
                                t + 2
                             ------------
                                    4
                             (t + 1)  + 1

Symbolic expressions can be plotted just like numerical expressions.
>plot2d(fexpr,-1,1); plot2d(&diff(fexpr,x),add=true,color=red):

00 - Overview of the Syntax of Euler

The command solve solves symbolic expressions for a variable in
Maxima. The result is a vector of solutions.
>&solve(x^2+x=4,x)
                     - sqrt(17) - 1      sqrt(17) - 1
                [x = --------------, x = ------------]
                           2                  2

Compare with the numerical "solve" command in Euler, which needs a
start value, and optionally a target value.
>solve("x^2+x",1,y=4)
1.56155281281
The numerical values can be computed by evaluation of the symbolic
result.
>&solve(x^2+2*x=4,x), %()
                 [x = - sqrt(5) - 1, x = sqrt(5) - 1]

[ -3.2360679775  1.2360679775 ]
To use a specific solution, we need to use "with" and an index.
>&solve(x^2+x=1,x), x2 &= x with %[2]
                      - sqrt(5) - 1      sqrt(5) - 1
                 [x = -------------, x = -----------]
                            2                 2


                             sqrt(5) - 1
                             -----------
                                  2

To solve a system of equations, use a vector of equations. The result
is a vector of solutions.
>sol &= solve([x+y=3,x^2+y^2=5],[x,y]), &x*y with sol[1]
                   [[x = 2, y = 1], [x = 1, y = 2]]


                                  2

Symbolic expressions can have flags, which indicate a special
treatment in Maxima. Some flags can be used as commands too, others
can't. Flags are appended with "|".
>& diff((x^3-1)/(x+1),x) | ratsimp
                              3      2
                           2 x  + 3 x  + 1
                           ---------------
                             2
                            x  + 2 x + 1

Numerical one-line Functions

In this overview, we cover only one-line functions. For more complex
functions, see the introduction notebook about programming.

  05 - Introduction to Programming

A numerical one-line function is defined by ":=".
>function f(x) := x*sqrt(x^2+1)
For an overview, we show all possible definitions for one-line
functions. The details will be covered later.

function f(x) := exp(x) // numerical function
function f(x) &= diff(x*exp(x),x) // symbolic function
function D(f,x) &&= D(f,x)+D(f,x,2) // purely symbolic function

A function can be evaluated just like any built-in Euler function.
>f(2)
4.472135955
This function will work for vectors too, obeying the matrix language
of Euler.
>f(0:0.1:1)
[ 0  0.100498756211  0.203960780544  0.313209195267  0.430813184571
0.559016994375  0.699714227381  0.854458893101  1.02449987799
1.21082616424  1.41421356237 ]
Functions can be plotted. Instead of expressions, we need only provide
the function name.

In contrast to symbolic or numerical expressions, the function name
must be provided in a string.
>plot2d("f",-1,1):

00 - Overview of the Syntax of Euler

plot2d, plot3d and other commands understand strings, containing the
function name.
>solve("f",1,y=1)
0.786151377757
By default, if you need to overwrite a built-in function, you must add
the keyword "overwrite". Overwriting built-in functions is dangerous
and can cause problems for other functions depending on them.

You can still call the built-in function as "_...", if it is function
in the Euler core.
>function overwrite sin (x) := _sin(x°)
>sin(45)
0.707106781187
We better remove this redefinition of sin.
>forget sin; sin(pi/4)
0.707106781187

Default Parameters

Numerical function can have default parameters.
>function f(x,a=1) := a*x^2
Omitting this parameter uses the default value.
>f(4)
16
Setting it overwrites the default value.
>f(4,5)
80
An assigned parameter overwrite it too. This is used by many Euler
functions like plot2d, plot3d.
>f(4,a=1)
16
If a variable is not a parameter, it must be global. One-line
functions can see global variables.
>function f(x) := a*x^2
>a=6; f(2)
24
But an assigned parameter overrides the global value.
>f(2,a=5)
20
There is a special form to assign the value false=0 and true=1 to an
assigned parameter.

>flag : flag=true
<flag : flag=false

This makes the meaning of parameters more clear to the reader. In the
example we want a bar plot.
>plot2d(1:10,>bar,style="/"):

00 - Overview of the Syntax of Euler

Symbolic Functions

Many details can be found in the introduction to Maxima in Euler.

  10 - Introduction to Maxima

Symbolic functions are defined with "&=". They are defined in Euler
and Maxima, and work in both worlds. The defining expression is run
through Maxima before the definition.
>function g(x) &= x^3-x*exp(-x)
                              3      - x
                             x  - x E

Symbolic functions can be used in symbolic expressions.
>&diff(g(x),x), &% with x=4/3
                            - x    - x      2
                         x E    - E    + 3 x


                              - 4/3
                             E        16
                             ------ + --
                               3      3

They can also be used in numerical expressions.
>g(5+g(1))
178.635099908
They can be used to define other symbolic functions or expressions.
>function G(x) &= factor(integrate(g(x),x))
                         - x   4  x
                        E    (x  E  + 4 x + 4)
                        ----------------------
                                  4

They can be plotted, since they are also numerical functions.
>plot2d("g",-1,1):

00 - Overview of the Syntax of Euler

They can also be plotted or used in symbolic form if they appear in a
symbolic expression.
>solve(&g(x),0.5)
0.703467422498
The following works too, since Euler uses the symbolic expression in
the function g, if it does not find a symbolic variable g, and if
there is a symbolic function g.
>solve(g,0.5)
0.703467422498

Symbolic Matrices

The usual [...] form to define matrices can be used in Euler to define
symbolic matrices.
>A &= [1,a;b,2]
                               [ 1  a ]
                               [      ]
                               [ b  2 ]

Like all symbolic variables, these matrices can be used in other
symbolic expressions.
>&det(A-x*ident(2)), &solve(%,x)
                        (1 - x) (2 - x) - a b


               3 - sqrt(4 a b + 1)      sqrt(4 a b + 1) + 3
          [x = -------------------, x = -------------------]
                        2                        2

The eigenvalues can also be computed automatically. The result is a
vector with two vectors of eigenvalues and multiplicities.
>&eigenvalues([a,1;1,a])
                       [[a - 1, a + 1], [1, 1]]

To extract a specific eigenvector needs careful indexing.
>&eigenvectors([a,1;1,a]), &%[2][1][1]
          [[[a - 1, a + 1], [1, 1]], [[[1, - 1]], [[1, 1]]]]


                               [1, - 1]

Symbolic matrices can be evaluated in Euler numerically just like
other symbolic expressions.
>A(a=4,b=5)
                  1                   4 
                  5                   2 
In symbolic expressions, use with.
>&A with [a=4,b=5]
                               [ 1  4 ]
                               [      ]
                               [ 5  2 ]

Access to rows of symbolic matrices work just like with numerical
matrices.
>&A[1]
                                [1, a]

A symbolic expression can contain an assignment.
>&A[1,1]:=t+1; &A
                             [ t + 1  a ]
                             [          ]
                             [   b    2 ]

Numerical Values in symbolic Expressions

A symbolic expression is just a string containing an expression. If we
want to define a value both for symbolic expressions and for numerical
expressions, we must use "&:=".
>A &:= [1,pi;4,5]
                  1       3.14159265359 
                  4                   5 
There is still a difference between the numerical and the symbolic
form. When transferring the matrix to the symbolic form, fractional
approximations for reals will be used.
>&A
                            [    1146408 ]
                            [ 1  ------- ]
                            [    364913  ]
                            [            ]
                            [ 4     5    ]

To avoid this, there is the function "mxmset(variable)".
>mxmset(A); &A
                       [ 1  3.141592653589793 ]
                       [                      ]
                       [ 4          5         ]

Maxima can also compute with floating point numbers, and even with big
floating numbers with 32 digits. The evaluation is much slower,
however.
>&bfloat(sqrt(2)), &float(sqrt(2))
                 1.4142135623730950488016887242097b0


                          1.414213562373095

The precision of the big floating point numbers can be changed.
>&fpprec:=100; &bfloat(pi)
        3.14159265358979323846264338327950288419716939937510582097494\
4592307816406286208998628034825342117068b0

A numerical variable can be used in any symbolic expressions using
"@var".

Note that this is only necessary, if the variable has been defined
with ":=" or "=" as a numerical variable.
>B:=[1,pi;3,4]; &det(@B)
                         - 5.424777960769379

Purely symbolic Functions

Symbolic functions can be defined for symbolic use only. Use "&&=" in
the function definition. 

This is necessary, if the function can not work numerically, or does
purely symbolic stuff only.
>function D(f,x) &&= diff(f,x)+x*diff(f,x,2)
                     diff(f, x, 2) x + diff(f, x)

Symbolic functions are not evaluated when they are defined. They work
like macros in Maxima. 
>&D(exp(x^2),x)
                              2       2          2
                          2  x       x          x
                    x (4 x  E   + 2 E  ) + 2 x E

Functions as Parameters

For examples to the topic of this sections, see the introduction to
programming.

  05 - Introduction to Programming

Many functions, like plot2d, accept functions and expressions as
parameters.

In case of expressions, the variables x or y are used e.g. by plot3d.
Other variables must be global. In case of functions, plot3d passes
the variables x and y to the function. Other variables must be passed
by semicolon parameters.

Have a look into the documentation about programming how this is
handled inside the function plot3d.
>function f(x,a) := a*x^2
>plot2d("f",-1,1;0.5); // with a=0.5 ...
 insimg;

00 - Overview of the Syntax of Euler

Note that by internal reasons assigned parameters cannot be defined
before the semicolon parameters. Assigned parameters must be added as
last parameters, as in the following example.
>plot2d("f";0.5,r=2):

00 - Overview of the Syntax of Euler

Mapping to Parameters

Some functions do not work for vector input. Here is an example. 

We wish to define the inverse of the following function numerically.
>function f(t) := t*sqrt(t^2+1)
We define the inverse function by solving f(x)=s for x. We use the
numerical solve algorithm of Euler with a starting value s, and target
value y=s.
>function map invf(s) := solve("f(x)",s,y=s)
It does indeed work.
>invf(f(2))
2
The map keyword in the definition of the function makes it work for
vectors too. The function is simply applied to all elements of the
parameter, if it is a vector.
>f(invf(1:5))
[ 1  2  3  4  5 ]

Syntax of Euler Comments

The comment editor of Euler knows lines of text, which it wraps into
paragraphs. For the reader, it is convenient to have one line of space
between normal paragraphs. Comments should be formatted with a fixed
font, in Euler and in the HTML output. The default width is 80
characters.

Euler comments can contain headers, Latex equations, links and images.
All these items are lines starting with a special sequence of
characters. The heading above has been generated with

 * Syntax of Euler Comments

with the * at the first place of the line.
Other items in a line are formulas. Here examples of the two possible
forms

 latex: \int_0^1 x^2 \, dx = \frac{1}{3}
 maxima: 'integrate(x^2,x,0,1) = integrate(x^2,x,0,1)

The result is

00 - Overview of the Syntax of Euler

00 - Overview of the Syntax of Euler

The second result was computed by Maxima, with 'integrate on the left
side to prevent evaluation.

Of course, Latex must be installed properly for this, and the latex
directory must be in the path. Or you can set the necessary binaries
in the Options menu.
Moreover, comments can contain links. The following are possible:

 http://euler.rene-grothmann.de
 See: 00 - Overview of the Syntax of Euler
 See: ../reference/eulercore.html#Units | Units

The result is

  http://euler.rene-grothmann.de
  00 - Overview of the Syntax of Euler
  Units

These links will be properly exported to HTML. For the second link,
the HTML file must be in the current directory, of course. This is the
case for this introduction.
Another type of special lines are images. The syntax is

 image: ../images/autor.jpg

The result is

00 - Overview of the Syntax of Euler

This image is installed with Euler. You can also load an image into a
command line of Euler.
>loadimg("../images/Icon.png");

00 - Overview of the Syntax of Euler

Euler Home