iconEuler Reference

Basic Utilities

Content

Basic utility functions.

This file collects some important utility functions.

Reset Euler

Resetting Euler is best done with the menu item, or with Ctrl-N. Then Maxima is restarted too. All variables are lost. You will be asked to save your notebook first. After reset, Euler calls the reset function below.

Epsilon:=epsilon();
I$:=I;
verticallabels:=1;
E$:=E;
eulergamma:=0.577215664901532860606512;
function Pi () := pi();
function overwrite setfont (size=none,width=1,name="",
    markersize=0.2)
  Set the font relative to the screen size
  
  Small prints of graphics require a larger font size relative to the
  maximal dimension of the graphics. This function sets the font
  size. The default is about 12 pixel for the HTML export with images
  of maximal dimensions of 400.
  
  The default name is blank. This sets the default font, which is
  "Arial" when Euler starts. But the user can set the default font
  permanently in the Menu.
  
  size : Size of font.
  width : Size of the print in the same unit.
  name : Font name. Default is "Arial".
  markersize : Fraction of the text height for the marker radius.
  
  Uses the internal function _setfont(lines,name).
  
  Examples:
  setfont(11pt,10cm) : 11 point font for a print of 10cm height.
  setfont(12,400) : This is a good font size for web pages.
  setfont() : Resets to the default 1/40 of the screen.
  
  See: 
setfont (Euler Core)
function resetepsilon 
  Reset the default epsilon and return the current epsilon.
function overwrite exec (program:string, param:string="", dir:string="",
    print:integer=0, hidden:integer=0, wait:integer=1)
  Execute an external program
  
  This is a utility function for the built-in exec command. It runs
  an external program, and by default waits for it to finish. The
  result of the program can be returned in form of vector of strings.
  Communication is via standard named pipes. The pipes stdout and
  stderr are read as output from the program.
  
  By default, the builtin function exec will block and wait for user
  confirmation. This prevents security problems with downloaded Euler
  notebooks. The confirmation can be switched off in the options. It
  can be switched off in the first confirmation dialog for one
  session.
  
  If wait is false and print is true, the function starts the
  program, and generates pipes to and from the program. These pipes
  can later be written to with execwrite(string) or
  execwriteln(string) and read from with execread(), returning a
  vector of strings. Only one such program is available. Trying to
  start a second program with open pipes terminates the first one.
  
  program : the name of the program (plus path, if not in the system
  path).
  
  param : Parameters separated by blanks. If the parameters contain
  blanks, they must be enclosed by double quotes. Use strings as in
  
  param=''"first parameter" "second parameter"''
  
  dir : The working directory of the program. This can be used to
  locate the program instead of a full path.
  
  print : If true and wait is false, the function returns the output
  immediately in form of a vector of strings. If true and wait is
  true, the program will print the output of the program.
  
  hidden : If true, no window will be generated.
  
  wait : If true, the function will wait for the command to be
  finished, or for the escape key.
  
  Examples:
  
  >exec("cmd","/c dir /w *.en",home(),>print,>hidden,>wait)
  Volume in Laufwerk C: hat keine Bezeichnung.
  Volumeseriennummer: ECF3-71E6
  
  Verzeichnis von C:\euler\docs\Programs
  ...
  
  >filename=eulerhome()+"test.txt"; ...
  writematrix(random(5,5),filename,"%1.5f"); ...
  exec("cmd","/c start "+filename,eulerhome(),<wait);
  
  >exec("cmd","",home(),>print,>hidden,<wait);
  >execwriteln("dir /w");
  >execread()
  Microsoft Windows [Version 6.1.7601]
  Copyright (c) 2009 Microsoft Corporation. Alle Rechte vorbehalten.
  ...
  >execkill();
  
  See: 
exec (Euler Core),
execwrite (Euler Core),
execwriteln (Euler Core),
execread (Euler Core)

Vector and Matrix Functions

Functions to generate matrices or vectors with values spaced in various ways, as well as functions providing informations about vectors and matrices.

function matrix 
  matrix(v1,v2,v3,...) returns a matrix with rows v1,v2,v3,...
function equispace (a:real scalar, b:real scalar,
    n: positive integer scalar)
  Generates n+1 arcsin spaced values in [a,b].
  
  The arcsin distribution generates points which are the extremal
  points of the Chebyshev polynomial. These points are well suited
  for discrete approximation on an interval.
  
  See: 
linspace (Euler Core),
chebzeros (Basic Utilities)
function logspace (a:positive real scalar,b:positive real scalar,
    n:positive integer scalar)
  logspace(a,b,n) generates n+1 log spaced points in [a,b]
  
  See: 
equispace (Basic Utilities),
linspace (Euler Core)
function chebzeros (a: real scalar, b: real scalar,
    n: positive integer scalar)
  Generate the zeros of the n-th Chebyshev polynomial in [a,b]
  
  See: 
linspace (Euler Core),
equispace (Basic Utilities)
function length (v)
  Returns the length of a row or column vector.
  
  In fact, the function returns the maximum of the number of rows,
  and the number of columns of a matrix.
function differences (s)
  Computes vector of the differences s[i+1]-s[i]
  
  See: 
fold (Numerical Algorithms)
function tail (s, n:integer)
  The rest of the vector s starting from the n-th element.
  
  tail(s,-2) returns the last two elements of s.
  
  See: 
head (Basic Utilities)
function head (s, n:integer)
  The vector, up to the n-th element
  
  The function works for negative n too. head(s,-2) returns all
  elements, but the last.
  
  See: 
tail (Basic Utilities)
function args field (x:vector, y:vector)
  Returns {X,Y} such that the X+i*Y is a rectangular grid
  
  x and y must be 1xN and 1xM vectors.
  
  This is not necessary in most cases, since operators in the Euler
  matrix language combine x and y' automatically.

Text Menus

This is a simple text menu. It can be used for files with a user choice of options.

function menu ()
  Displays a menu and returns the number of the chosen item
  
  This is a simple menu in text form inside the text window of Euler.
  The menu items are the arguments to this function. The items should
  be labelled (a), (b), etc. The user can press the keys a, b, etc.,
  or the return key. In this case, the functin returns -1. Else the
  function returns the number of the chosen argument.

Number Bases

Functions for hexadecimal or binary input and conversion.

function baseinput (s:string, b:index=16)
  Read a number in base b.
function hex (s:string)
  Convert a hex string.
  
  See: 
printhex (Basic Utilities),
baseinput (Basic Utilities)
function dual (s:string)
  Convert a hex string.
  
  See: 
printdual (Basic Utilities),
baseinput (Basic Utilities)
function printbase (x:real scalar, base:index=16, digits=13,
    integer=false)
  Prints the real number x with mantissa and exponent to base b.
  
  The output is of the form 1.xxxxx...xxx*2^n with mantissa of
  length digits. If integer is true, the value is assumed to
  be integer, and it prints in the form xxxxx. x is between 0 and
  base, where A=11, B=12, etc.
  
  >dual("10001001"), printdual(%,>integer)
  137
  10001001
  >baseinput("24256",7), printbase(%,base=7,>integer)
  6313
  24256
  >6+5*7+2*7^2+4*7^3+2*7^4
  6313
  
  See: 
baseinput (Basic Utilities)
function printdual (x:real scalar, integer=false, length=1)
  Prints the real number x with dual mantissa.
  
  The output is of the form 1.xxxxx...xxx*2^n. If integer is true,
  then the output is of the form xxxxxx with x=0 or x=1.
  
  >dual("10001001"), printdual(%,>integer)
  137
  10001001
  >printdual(0.1)
  1.1001100110011001100110011001100110011001100110011010*2^-4
  
function printhex (x:real scalar, integer=false)
  Prints the real number x with hexadecimal mantissa.
  
  The output is of the form 1.xxxxx...xxx*16^n. If integer is true
  the output is of the form xxxxx where x is 0,...,9,A,B,C,D,E,F.
  
  >hex("DDFFD"), printhex(%,>integer)
  909309
  DDFFD
  >printhex(0.1)
  1.999999999999A*16^-1
  

Date and Time Functions

function day (y,
    m:integer scalar=1, d:integer scalar=1,
    h:integer scalar=0, min:real scalar=0,
    german=false, us=false)
  Convert a date to a number of days.
  
  The computation is based on the Gregorian calendar. It is intended
  to be used to compute differences between dates.
  
  The date can alternatively be a formatted string in ISO8601 format
  (yyyy-mm-dd) with an optional time (hh:mm or hh:mm:sec) appended
  with a blank. The function will detect the alternative day format
  (dd.mm.yyyy), and an English month name instead of a numerical
  value. The date order can also be set with >us to "mm-dd-yyyy", and
  with >german to "dd-mm-yyyy".
  
  >day(2020,1,1)-day(2010,1,1)
  3652
  >day("2012-12-03 16:00")-day("2012-01-01 13:00")
  337.125
  >day(2012,3,1,12)
  734993.5
  >day("jan-3-2012 12:00",>us)
  734935.5
  >day("3.jan.2012") // automatically German
  734935
  >day("3-1-2012",>german)
  734935
  
  See: 
date (Basic Utilities)
function args date (d:number)
  Converts a day number to the date.
  
  Reverse function of day(). Returns the date in multiple return
  values.
  
  >{y,m,d,h,min}=date(day(2012,11,1,23,12)); [y,m,d,h,min]
  [ 2012  11  1  23  12 ]
  
  See: 
day (Basic Utilities),
day (Astronomical Functions),
daynow (Basic Utilities),
weekday (Basic Utilities)
function daynow (utc=0)
  Date number for the current day and time.
  
  The computation is based on the Gregorian calendar.
  
  utc : Use UTC time.
  
  >daynow()-day(2000,1,1)
  >printdate(date(daynow()))
  2016-03-17 15:40
  
  See: 
day (Astronomical Functions),
date (Basic Utilities),
getnow (Basic Utilities),
printnow (Basic Utilities),
weekday (Basic Utilities)
function comment getnow (utc)
  Current date in vector format.
  
  utc : in UTC or local time.
  
  See: 
daynow (Basic Utilities),
weekday (Basic Utilities)
function overwrite printnow (utc=0)
  Current day and time as string.
  
  The functions uses the locale settings of the user.
  
  >printnow
  Donnerstag, 17. M�rz 2016 15:42:55
  
  See: 
getnow (Basic Utilities),
daynow (Basic Utilities),
weekday (Basic Utilities)
function printdate (y:integer scalar, m:integer scalar,
    d:integer scalar, h:integer scalar=0, min:integer scalar=0,
    sec: integer scalar=none, time=true, timeonly=false,
    german=false, us=false)
  Prints a day.
  
  The output is in ISO6801 standard format "yyyy-mm-dd hh:mm" by
  default. With <time, the output contains only the date, with
  >timeonly it contains only the time. With >german the format of
  the date is "dd.mm.yyyy". With >us, the output is mm-dd-yyyy with
  the month in string format.
  
  >printdate(date(day(2011,9,11,12)+1000))
  2014-06-07 12:00
  >printdate(date(day("jan-03-2012",>us)),>us)
  JAN-03-2012 00:00
  
  See: 
day (Basic Utilities),
day (Astronomical Functions),
getnow (Basic Utilities),
weekday (Basic Utilities)
function weekday (d:number, name=false)
  Gets the week day of a day (1=monday, 7=sunday), or its name
  
  >weekday(daynow())
  4
  >weekday(daynow(),>name)
  Thursday
  >weekday(day(2021,11,11),>name)
  Thursday
  
  See: 
day (Astronomical Functions),
date (Basic Utilities)

Continued Fractions

function contfrac (x,n=10)
  Compute the continued fraction of x.
  returns [a,b,c,...] with
  x = a + 1 / (b + 1 / (c + 1/(...
function contfracval (r)
  Evaluate the continued fraction
  x = a + 1 / (b + 1 / (c + 1/(...
  with r = [a,b,c,...]
  Return an Interval {x1,x2}
function contfracbest (x,n=3)
  Return the best rational
  approximation to x
function isstring (x)
  Tests, if x is a string.
function expreval (expr:string, x)
  Evaluate the expression, using x and global variables
  
  Note that the variable x is given as a parameter. Other variables
  can be set using assigned variables, as in expreval("x*y",3,y=4).
  Moreover, global variables can be used. Local variables in the
  calling functions cannot be used, however.
  
  This works very much line expr(x), or "a*x*y"(3,4,a=5).
function map case (b:real, x, y)
  Returns x, if b!=0, else y.
  
  This function works like if, but evaluates both, x and y. It works
  for matrices b, x and y too.

Output Formats

EMT can either set an output format for all numbers of a specific type, or print one scalar or vector value in some format, or convert a value to a string in that format. E.g., one can select fracformat(), printfrac() or frac(). Most settings specify a length of output and the accuracy of the output in some form.

The are some other functions and settings that affect the output. The setting denseoutput prints vectors in a tighter, comma separated format with brackets around them. The setting zerorounding rounds values close to 0 to print exactly as 0.

Note that the default format for Euler is longformat with 12 digits of precision. You can set this format with defformat. By default, zero rounding is on so that very small numbers print as 0. Dense output is on.

function overwrite print (x:real scalar, digits:integer=2, length:integer=10,
    unit:string="", sep=none, dot=none)
  Formats the real number x to a string.
  
  x : real value
  digits : number of digits after the decimal dot
  length : total length of output string
  unit : unit to append after the print
  sep : separator to group large numbers in groups of 3.
  dot : decimal dot
  
  sep and dot default to none, which means no separation and the
  usual decimal dot. If sep==1 (with >sep), then a hard space will be
  used.
  
  This function calls the built-in function _print() which takes the
  parameters _print(x,digits,length,sep,dot).
  
  >print(101/891,unit="%")
  0.11%
  >print(1234567890.23,2,20,>sep,dot=",",unit=" �")
  1�234�567�890,23 �
  
  See: 
printf (Basic Utilities),
printf (Maxima Documentation),
hardspace (Euler Core)
function comment printstr (s, length, mode, char)
  String with x and n characters according to mode.
  
  s : string
  length : length of output (at least length of string)
  mode : (optional)
  -1 = left justified
  0 = centered
  1 = right justified
  char : (optional)
  ascii code of fill character or string with one character
  
  >printstr("Test",10,0,"-")
  ---Test---
  >s=""; for i=1:5; s=s+"|"+printstr("Test",10,0); end; s+"|",
  |   Test   |   Test   |   Test   |   Test   |   Test   |
  >printstr(""+24,10,1,"0")
  0000000024
  
  See: 
print (Maxima Documentation)
function prefix show (x$)
  Prints a variable with its name.
  
  This will print x=... if the provided argument is a variable.
  Otherwise, it will print the value only as usual.
  
  >x=pi/2; show x
  x =
  1.57079632679
  
  See: 
showlarge (Basic Utilities)
function prefix showlarge (x$)
  Prints large matrices in full.
  
  By default EMT eclipses lines and rows of large matrices. This can
  be used to see the full matrix. If the parameter is a variable the
  variable name will be printed.
  
  The default can be changes with largematrices on/off.
  
  >x=random(20,5); showlarge(x)
  >showlarge(random(20,5))
  
  See: 
largematrices (Euler Core),
show (Maxima Documentation)
function comment printf (format,x)
  Print a value with a C-format.
  
  The format can be decimal (%d, %x) or floating point (%g, %e, %f)
  if x is a number, or a string format (%s) if x is a string. Length
  modifiers (%20g), digits settings (%10.5f) or adjustments (%-20.5f)
  are allowed.
  
  The format string is checked for a valid format. It should not be
  possible to crash Euler via this function.
  
  x : real number
  format : a format string
  
  >printf("pi = %0.2f",pi)
  pi = 3.14
  >printf("left adjusted: --- %-20.10e ---",pi)
  left adjusted: --- 3.1415926536e+000    ---
  >printf("pi = %0.10g",pi)
  pi = 3.141592654
  >printf("%20s","Just a test")
  Just a test
  >printf(''String: "%20s"'',"Just a test")
  String: "         Just a test"
  
  See: 
printf (Maxima Documentation),
Formats (Overview)
function overwrite format (n, digits=none, all=0)
  format(n,m) sets the output format to m digits and width n.
  
  format(n,m) : Turns zero rounding and dense output off. Then calls
  the builtin function _format, which sets the output width to n
  places, and the precision digits to m.
  
  format(n) : Works like goodformat with n digits of acccuracy. Dense
  output and zero rounding is on.
  
  all : If true, the set scalar format will be disabled.
  
  >format(6,2); (1:10)/3, longformat; // reset to default
  0.33  0.67  1.00  1.33  1.67  2.00  2.33  2.67  3.00  3.33
  >format(20,5); (1:4)'/3, longformat; // reset to default
  0.33333
  0.66667
  1.00000
  1.33333
  >format(3); pi, // like goodformat
  3.14
  
  See: 
goodformat (Basic Utilities),
Formats (Overview)
function comment zerorounding (f)
  Sets rounding to 0 of small numbers for output.
  
  See: 
Formats (Overview)
function comment denseoutput (f)
  Sets dense output for row vectors.
  
  If f is not zero, its value is used to set the number of spaces
  after each comma in the vector.
  
  See: 
Formats (Overview)
function comment scalarformat (f)
  Enables or disables the special output for scalars.
  
  If this is off the same format will be used for vectors and
  scalars. Many specific format command turn this off. The function
  defformat will set this on. Turning it off manually for a format
  makes sense only if setscalarformat(n) is used too.
  
  >format(10,5);
  >1/3
  0.33333
  >(1:5)/3
  0.33333   0.66667   1.00000   1.33333   1.66667
  >defformat;
  >1/3
  0.333333333333
  >(1:5)/3
  [0.333333,  0.666667,  1,  1.33333,  1.66667]
  
  See: 
setscalarformat (Basic Utilities),
Formats (Overview)
function comment setscalarformat (n)
  Sets the number of digits for the scalar format.
  
  By default, the scalar format is different from the vector format.
  This function can be used to set the number of digits for the
  scalar format.
  
  See: 
Formats (Overview)
function comment iformat (n)
  Sets the number of digits for interval output.
function overwrite goodformat (n,digits=none,all=0)
  goodformat(n,m) sets the output format to m digits and width n.
  
  Selects a nice format. For integers, the decimal dot will not be
  included. For very large or very small numbers, the exponential
  format will be used.
  
  This turn zero rounding on and dense output on. Then it calls the
  builtin function _goodformat, which sets the width to m digits and
  the precession to n digits. The width will only be used for matrix
  output with more than one row unless dense output is off.
  
  goodformat(n,m) : sets m digits of precission and a total length of
  n digits.
  
  goodformat(m) : total length is m+8, which is sufficient for
  exponential formats.
  
  all : if on, the scalar format is disabled.
  
  The difference to format is that the output of integers uses no
  decimal dot. Moreover, the dense output prints row vectors with
  brackets.
  
  >goodformat(6,2); (1:10)/3, defformat; // reset to default
  [ 0.33  0.67  1  1.3  1.7  2  2.3  2.7  3  3.3 ]
  
  See: 
Formats (Overview)
function overwrite expformat 
  expformat(n,m) sets the output format to m digits and width n.
  
  Turns zero rounding off and dense output on. This works like
  format, but uses exponential output always. It calls the builtin
  function _expformat.
  
  >expformat(6,2); (1:10)/3, longformat; // reset to default
  [ 3.33e-001  6.67e-001  1.00e+000  1.33e+000  1.67e+000  2.00e+000
  2.33e+000  2.67e+000  3.00e+000  3.33e+000 ]
  
  See: 
Formats (Overview)
function overwrite fixedformat 
  fixedformat(n,m) sets the output format to m digits and width n.
  
  This works like expformat(), but always uses fixed point format. It
  calls the builtin function _fixedformat.
  
  Turns zero rounding on. Zero rounding is used to round very small
  numbers to 0.
  
  See: 
Formats (Overview)
function longestformat 
  Sets a very long format for numbers.
  
  Turns zero rounding and dense output off. Uses a format, that
  allows to see the internal accuracy of IEEE double precision.
  
  See: 
Formats (Overview)
function longformat (all=0)
  Sets a long format for numbers
  
  This is the default format for Euler with 12 digits precision.
  Turns zero rounding and dense output on, and uses a good format,
  which does not show a decimal dot if possible.
  
  See: 
Formats (Overview)
function defformat 
  Sets the default format for Euler
  
  Turns zero rounding and dense output on, and uses a good format,
  which does not show a decimal dot if possible.
  
  See: 
Formats (Overview)
function shortformat (all=0)
  Sets a short format for numbers.
  
  See: 
Formats (Overview)
function shortestformat (all=0)
  Sets a very short format for numbers.
  
  See: 
Formats (Overview)
function overwrite fracformat (n:integer=0, eps=1e-10)
  Sets the fractional format.
  
  Turns zero rounding on. If n>0 it turns dense output off. A
  continued fraction is used to approximate the numbers with
  fractions. The accuracy can be set with eps.
  
  >fracformat; (1:10)/3, longformat;
  [ 1/3  2/3  1  4/3  5/3  2  7/3  8/3  3  10/3 ]
  >fracformat(10); (1:4)'/3, longformat;
  1/3
  2/3
  1
  4/3
  
function fracprint (x:numerical, n:integer=10, eps=1e-10)
  Prints x in fractional format with n places.
  
  Uses a temporary format to print a value in fractional format. The
  format is then reset to the default longformat.
  
  >fracprint(pi,eps=0.01)
  22/7
  
function overwrite frac (x:numerical, mixed:integer=0,
    eps:scalar=none)
  Returns a string containing the fractional representation of x.
  
  This can be used to convert a number to a fraction contained in a
  string. If mixed, then the integer part is separated from the
  fractional part. The function uses the builtin function _frac to
  find a continued fraction, which approximates the number.
  
  The function can also be used for vectors and matrices to convert
  decimals into good fractions, e.g. for Maxima.
  
  mixed : split the integer part from the fractional part
  eps : allowed relative accuracy.
  
  >frac(2/3+5/4,>mixed)
  1+11/12
  >(1:4)/3
  [0.333333,  0.666667,  1,  1.33333]
  >frac((1:4)/3)
  [1/3,2/3,1,4/3]
  
  See: 
fracformat (Basic Utilities)
function prefix short (x)
  Print x in short format
  
  >short pi^2
function prefix shortest (x)
  Print x in shortest format
  
  >shortest pi^2
function prefix long (x)
  Print x in long format
  
  >long pi^2
function prefix longest (x)
  Print x in the longest format
  
  >longest pi^2
function rad ()
  rad(d[,min,sec]) converts to radians
  
  rad(x) transfers degree x to radians. If min and sec are present,
  these will be used to set minutes and seconds of the angle.
  
  x� works too instead of rad(x).
  
  See: 
deg (Basic Utilities),
degprint (Basic Utilities)
function deg (x)
  deg(x) transfers radians x to degrees
  
  See: 
rad (Basic Utilities),
degprint (Basic Utilities)
function degprint (x : real scalar, dms:integer=1)
  Converts radians x to string in degrees, minutes and seconds.
  
  This function returns a string with a representation of the radial
  angle x in degrees. By default, the function will print minutes and
  seconds. Turn this off with <dms. Returns a string.
  
  See: 
degformat (Basic Utilities)
function degformat (on:integer=1)
  Use degree format from now on.
  
  This calls userformat with the degprint function.
  
  See: 
userformat (Basic Utilities),
degprint (Basic Utilities)
function polarprint (x:complex scalar, format="%g")
  Converts a complex x to a string in polar form.
  
  Converts the complex number in the form (r,phi�). The format for r
  can be set with format="...". Returns a string.
  
  >polarprint(1+I,format="%0.12g")
  (1.41421356237,45�)
  >polarprint(1+I)
  (1.41421,45�)
  
  See: 
polarformat (Basic Utilities),
polar (Mathematical Functions),
polar (Maxima Documentation)
function polarformat (on:integer=1)
  Sets the format to polar form.
  
  See: 
userformat (Basic Utilities),
polarprint (Basic Utilities)
function ipmprint (x:interval scalar)
  Print an interval using plus-minus notation.
  
  >ipmprint(~1,2~)
  1.5�0.5
  
  See: 
ipmformat (Basic Utilities)
function ipmformat (on:integer=1)
  Set the interval format to plus-minus notation.
  
  See: 
ipmprint (Basic Utilities)
function prefix cformat (x)
  Print x in currency format
  
  >long pi^2
function prefix fraction (x)
  Print x in fractional format
  
  >longest pi^2
function printeuro (x,n=0)
  The value in Euro rounded to cent
function printdollar (x,n=0)
  The value in Dollar rounded to cent
function prefix uprint (x)
  Print in the format in userformat$.
  
  >userformat$="%10.2f Yen";
  >uprint 119569*119%
  142287.11 Yen
  
  See: 
userformat (Basic Utilities)
function comment userformat (f$)
  Uses f$(x) for the output of the number x.
  
  f$ : A function to format a number x.
  The function should be able to detect real, complex or interval
  values. If f$=="" then the user format is reset to the default
  format.
  
  >function prefix money (x) := print(x,2,12,>sep,dot=",",unit="Euro");
  >money 12345.678
  

Diverse Helper Functions

function isstring (x)
  Tests, if x is a string.
function expreval (expr:string, x)
  Evaluate the expression, using x and global variables
  
  Note that the variable x is given as a parameter. Other variables
  can be set using assigned variables, as in expreval("x*y",3,y=4).
  Moreover, global variables can be used. Local variables in the
  calling functions cannot be used, however.
  
  This works very much line expr(x), or "a*x*y"(3,4,a=5).
function map case (b:real, x, y)
  Returns x, if b!=0, else y.
  
  This function works like if, but evaluates both, x and y. It works
  for matrices b, x and y too.
function prefix sel (a)
  Prefix version of nonzeros(a)
  

Documentation Homepage