Wasora reference sheet


This reference sheet is for wasora v0.5.160-g53c190f .

$ wasora
wasora v0.5.159-g4df4130 
wasora’s an advanced suite for optimization & reactor analysis
$

1 Keywords

1.1 =

1.2 .=

1.3 ABORT

Catastrophically abort the execution and quit wasora.

Whenever the instruction ABORT is executed, wasora quits without closing files or unlocking shared memory objects. The objective of this instruction is, as illustrated in the examples, either to debug complex input files and check the values of certain variables or to conditionally abort the execution using IF clauses.

1.4 ALIAS

Defines a scalar alias of an already-defined indentifier.

1.5 CALL

Executes a previously dynamically-loaded user-provided routine.

1.6 CLOSE

1.7 CONST

Marks a scalar variable, vector or matrix as a constant.

1.8 DEFAULT_ARGUMENT_VALUE

Give a default value for an optional commandline argument.

If a $n construction is found in the input file but the commandline argument was not given, the default behavior is to fail complaining that an extra argument has to be given in the commandline. With this keyword, a default value can be assigned if no argument is given, thus avoiding the failure and making the argument optional.

1.9 DIFFERENTIAL

1.10 FILE

Defines a file, either as input or as output, for further reference.

1.11 FIT

1.12 FUNCTION

Defines a function of one or more variables.

1.13 HISTORY

Record the time history of a variable as a function of time.

1.14 IF

Begins a conditional block.

1.15 IMPLICIT

Defines whether implicit declaration of variables is allowed or not. Asks wasora not to evaluate assignments at parse time.

By default, wasora allows variables (but not vectors nor matrices) to be implicitly declared. To avoid introducing errors due to typos, explicit declaration of variables can be forced by giving IMPLICIT NONE. Whether implicit declaration is allowed or explicit declaration is required depends on the last IMPLICIT keyword given, which by default is ALLOWED.

1.16 INCLUDE

Include another wasora input file.

Includes the input file located in the string file_path at the current location. The effect is the same as copying and pasting the contents of the included file at the location of the INCLUDE keyword. The path can be relative or absolute. Note, however, that when including files inside IF blocks that instructions are conditionally-executed but all definitions (such as function definitions) are processed at parse-time independently from the evaluation of the conditional. The optional FROM and TO keywords can be used to include only portions of a file.

1.17 INITIAL_CONDITIONS_MODE

Defines how initial conditions of DAE problems are computed.

In DAE problems, initial conditions may be either:

  • equal to the provided expressions (AS_PROVIDED)
  • the derivatives computed from the provided phase-space variables (FROM_VARIABLES)
  • the phase-space variables computed from the provided derivatives (FROM_DERIVATIVES)

In the first case, it is up to the user to fulfill the DAE system at \(t = 0\). If the residuals are not small enough, a convergence error will occur. The FROM_VARIABLES option means calling IDA’s IDACalcIC routine with the parameter IDA_YA_YDP_INIT. The FROM_DERIVATIVES option means calling IDA’s IDACalcIC routine with the parameter IDA_Y_INIT. Wasora should be able to automatically detect which variables in phase-space are differential and which are purely algebraic. However, the DIFFERENTIAL keyword may be used to explicitly define them. See the “SUNDIALS documentation”: “https://computation.llnl.gov/casc/sundials/documentation/ida_guide.pdf” for further information.

1.18 LOAD_PLUGIN

Loads a wasora plug-in from a dynamic shared object.

A wasora plugin in the form of a dynamic shared object (i.e. .so) can be loaded either with the LOAD_PLUGIN keyword or from the command line with the -p option. Either a file path or a plugin name can be given. The following locations are tried:

  • the current directory ./
  • the parent directory ../
  • the user’s LD_LIBRARY_PATH
  • the cache file /etc/ld.so.cache
  • the directories /lib, /usr/lib, /usr/local/lib

If a wasora plugin was compiled and installed following the make install procedure, the plugin should be loaded by just passing the name to LOAD_PLUGIN.

1.19 LOAD_ROUTINE

Loads one or more routines from a dynamic shared object.

1.20 M4

Calls the m4 macro processor with definitions from wasora variables.

1.21 MATRIX

Defines a matrix.

1.22 MINIMIZE

1.23 PARAMETRIC

Sistematically sweeps a zone of the parameter space.

1.24 PHASE_SPACE

1.25 PRINT

Prints plaint-text data to the standard output or to an output file.

Each argument object that is not a keyword is expected to be part of the output, can be either a matrix, a vector, an scalar algebraic expression. If the given object cannot be solved into a valid matrix, vector or expression, it is treated as a string literal if IMPLICIT is ALLOWED, otherwise a parser error is raised. To explicitly interpret an object as a literal string even if it resolves to a valid numerical expression, it should be prefixed with the TEXT keyword. Hashes~# appearing literal strings have to be quoted to prevent the parser to treat them as comments within the wasora input file. Whenever an argument starts with a porcentage sign ‘%’, it is treated as a printf-compatible format definition and all the objects that follow it are printed using the given format until a new format definition is found. All the objects are treated as double-precision floating point numbers, so only floating point formats
should be given. The default format is ‘%e’. Matrices, vectors, scalar expressions, format modifiers and string literals can be given in the desired order, and are processed from left to right. Vectors are printed element-by-element in a single row. See PRINT_VECTOR to print vectors column-wise. Matrices are printed element-by-element in a row-major fashion if mixed with other objects but in the natural row and column fashion if it is the only given object.
If the FILE keyword is not provided, default is to write to stdout. If the NONEWLINE keyword is not provided, default is to write a newline ‘\n’ character after all the objects are processed. The SEP keywords expects a string used to separate printed objects, the default is a tab ‘\t’ character. Use the NOSEP keyword to define an empty string as object separator. If the HEADER keyword is given, a single line containing the literal text given for each object is printed at the very first time the PRINT instruction is processed, starting with a hash # character.
If the SKIP_STEP (SKIP_STATIC_STEP)keyword is given, the instruction is processed only every the number of transient (static) steps that results in evaluating the expression, which may not be constant. By default the PRINT instruction is evaluated every step. The SKIP_HEADER_STEP keyword works similarly for the optional HEADER but by default it is only printed once. The SKIP_TIME keyword use time advancements to choose how to skip printing and may be useful for non-constant time-step problems.

Prints one or more functions as a table of values of dependent and independent variables.

Prints one or more vectors.

1.28 READ

Reads data (variables, vectors o matrices) from external objects.

1.29 SEMAPHORE

Performs either a wait or a post operation on a named shared semaphore.

1.30 SHELL

Executes a shell command.

1.31 SOLVE

Solves a non-linear system of~\(n\) equations with~\(n\) unknowns.

1.32 TIME_PATH

Forces transient problems to pass through specific instants of time.

The time step dt will be reduced whenever the distance between the current time t and the next expression in the list is greater than dt so as to force t to coincide with the expressions given. The list of expresssions should evaluate to a sorted list of values.

1.33 VAR

Defines one or more scalar variables.

1.34 VECTOR

Defines a vector.

1.35 WRITE

Writes data (variables, vectors o matrices) to external objects. See the READ keyword for usage details.

2 Mesh-related keywords

2.1 MATERIAL

2.2 MESH

2.3 MESH_FILL_VECTOR

2.4 MESH_FIND_MAX

2.5 MESH_INTEGRATE

2.6 MESH_MAIN

2.7 MESH_POST

2.8 PHYSICAL_ENTITY

2.9 PHYSICAL_PROPERTY

3 Variables

3.1 done

Flag that indicates whether the overall calculation is over.

3.2 done_outer

Flag that indicates whether the parametric, optimization of fit calculation is over or not. It is set to true (i.e. \(\neq 0\)) by wasora whenever the outer calculation is considered to be finished, which can be that the parametric calculation swept the desired parameter space or that the optimization algorithm reached the desired convergence criteria. If the user sets it to true, the current step is marked as the last outer step and the transient calculation ends after finishing the step.

3.3 done_static

Flag that indicates whether the static calculation is over or not. It is set to true (i.e. \(\neq 0\)) by wasora if step_static \(\ge\) static_steps. If the user sets it to true, the current step is marked as the last static step and the static calculation ends after finishing the step.

3.4 done_transient

Flag that indicates whether the transient calculation is over or not. It is set to true (i.e. \(\neq 0\)) by wasora if t \(\ge\) end_time. If the user sets it to true, the current step is marked as the last transient step and the transient calculation ends after finishing the step.

3.5 dt

Actual value of the time step for transient calculations. When solving DAE systems, this variable is set by wasora. It can be written by the user for example by importing it from another transient code by means of shared-memory objects. Care should be taken when solving DAE systems and overwriting t. Default value is 1/16, which is a power of two and roundoff errors are thus reduced.

3.6 end_time

Final time of the transient calculation, to be set by the user. The default value is zero, meaning no transient calculation.

3.7 i

Dummy index, used mainly in vector and matrix row subindex expressions.

3.8 infinite

A very big positive number, which can be used as end_time = infinite or to define improper integrals with infinite limits. Default is \(2^{50} \approx 1 \times 10^{15}\).

3.9 in_outer_initial

Flag that indicates if the current step is the initial step of an optimization of fit run.

3.10 in_static

Flag that indicates if wasora is solving the iterative static calculation. Flag that indicates if wasora is in the first step of the iterative static calculation. Flag that indicates if wasora is in the last step of the iterative static calculation.

3.11 in_transient

Flag that indicates if wasora is solving transient calculation.

3.12 in_transient_first

Flag that indicates if wasora is in the first step of the transient calculation.

3.13 in_transient_last

Flag that indicates if wasora is in the last step of the transient calculation.

3.14 j

Dummy index, used mainly in matrix column subindex expressions.

3.15 max_dt

Maximum bound for the time step that wasora should take when solving DAE systems.

3.16 min_dt

Minimum bound for the time step that wasora should take when solving DAE systems.

3.17 ncores

The number of online available cores, as returned by sysconf(_SC_NPROCESSORS_ONLN). This value can be used in the MAX_DAUGHTERS expression of the PARAMETRIC keyword (i.e ncores/2).

3.18 on_gsl_error

This should be set to a mask that indicates how to proceed if an error ir raised in any routine of the GNU Scientific Library.

3.19 on_ida_error

This should be set to a mask that indicates how to proceed if an error ir raised in any routine of the SUNDIALS IDA Library.

3.20 on_nan

This should be set to a mask that indicates how to proceed if Not-A-Number signal (such as a division by zero) is generated when evaluating any expression within wasora.

3.21 pi

A double-precision floating point representaion of the number \(\pi\), equal to math.h ’s M_PI constant.

3.22 pid

The UNIX process id of wasora (or the plugin).

3.23 realtime_scale

If this variable is not zero, then the transient problem is run trying to syncrhonize the problem time with realtime, up to a scale given. For example, if the scale is set to one, then wasora will advance the problem time at the same pace that the real wall time advances. If set to two, wasora’s time wil advance twice as fast as real time, and so on. If the calculation time is slower than real time modified by the scale, this variable has no effect on the overall behavior and execution will proceed as quick as possible with no delays.

3.24 rel_error

Maximum allowed relative error for the solution of DAE systems. Default value is is \(1 \times 10^{-6}\). If a fine per-variable error control is needed, special vector abs_error should be used.

3.25 static_steps

Number of steps that ought to be taken during the static calculation, to be set by the user. The default value is one, meaning only one static step.

3.26 step_outer

Indicates the current step number of the iterative outer calculation (parametric, optimization or fit). Indicates the current step number of the iterative inner calculation (optimization or fit).

3.27 step_static

Indicates the current step number of the iterative static calculation.

3.28 step_transient

Indicates the current step number of the transient static calculation.

3.29 t

Actual value of the time for transient calculations. This variable is set by wasora, but can be written by the user for example by importing it from another transient code by means of shared-memory objects. Care should be taken when solving DAE systems and overwriting t.

3.30 zero

A very small positive number, which is taken to avoid roundoff errors when comparing floating point numbers such as replacing \(a \leq a_\text{max}\) with \(a < a_\text{max} +\) zero. Default is \((1/2)^{-50} \approx 9\times 10^{-16}\) .

4 Mesh-related variables

4.1 cells

Number of cells of the unstructured grid. This number is the actual quantity of volumetric elements in which the domain was discretized.

4.2 elements

Number of total elements of the unstructured grid. This number include those surface elements that belong to boundary physical entities.

4.3 eps

Small value. Default is \(10^{-6}\).

4.4 nodes

Number of nodes of the unstructured grid.

4.5 x

Holder variable for spatial dependance of functions, such spatial distribution of physical properties or results of partial differential equations.

4.6 y

Idem as x.

4.7 z

Idem as x.

5 Functions

5.1 abs

Returns the absolute value of the argument \(x\).

5.2 acos

Computes arc in radians whose cosine is equal to the argument \(x\). A NaN error is raised if \(|x|>1\).

5.3 asin

Computes arc in radians whose sine is equal to the argument \(x\). A NaN error is raised if \(|x|>1\).

5.4 atan

Computes, in radians, the arc tangent of the argument \(x\).

5.5 atan2

Computes, in radians, the arc tangent of quotient \(y/x\), using the signs of the two arguments to determine the quadrant of the result, which is in the range \([-\pi,\pi]\).

5.6 ceil

Returns the smallest integral value not less than the argument \(x\).

5.7 clock

Returns the value of a certain clock in seconds measured from a certain (but specific) milestone. The kind of clock and the initial milestone depends on the optional flag \(f\). It defaults to zero, meaning wall time since the UNIX Epoch. The list and the meanings of the other available values for \(f\) can be checked in the clock_gettime (2) system call manual page.

5.8 cos

Computes the cosine of the argument \(x\), where \(x\) is in radians. A cosine wave can be generated by passing as the argument \(x\) a linear function of time such as \(\omega t+\phi\), where \(\omega\) controls the frequency of the wave and \(\phi\) controls its phase.

5.9 cosh

Computes the hyperbolic cosine of the argument \(x\), where \(x\) is in radians.

5.10 d_dt

Computes the time derivative of the signal \(x\) using the difference between the value of the signal in the previous time step and the actual value divided by the time step. For \(t=0\), the return value is zero. Unlike the functional derivative, this function works with expressions and not with functions. Therefore the argument \(x\) may be for example an expression involving a variable that may be read from a shared-memory object, whose time derivative cannot be computed with derivative.

5.11 deadband

Filters the first argument \(x\) with a deadband centered at zero with an amplitude given by the second argument \(a\).

5.12 equal

Checks if the two first expressions \(a\) and \(b\) are equal, up to the tolerance given by the third optional argument \(\epsilon\). If either \(|a|>1\) or \(|b|>1\), the arguments are compared using GSL’s gsl_fcmp, otherwise the absolute value of their difference is compared against \(\epsilon\). This function returns zero if the arguments are not equal and one otherwise. Default value for \(\epsilon = 10^{-16}\).

5.13 exp

Computes the exponential function the argument \(x\), i.e. the base of the natural logarithms raised to the \(x\)-th power.

5.14 expint1

Computes the first exponential integral function of the argument \(x\). If \(x\) equals zero, a NaN error is issued.

5.15 expint2

Computes the second exponential integral function of the argument \(x\).

5.16 expint3

Computes the third exponential integral function of the argument \(x\).

5.17 expintn

Computes the \(n\)-th exponential integral function of the argument \(x\). If \(n\) equals zero or one and \(x\) zero, a NaN error is issued.

5.18 floor

Returns the largest integral value not greater than the argument \(x\).

5.19 heaviside

Computes the zero-centered Heaviside step function of the argument \(x\). If the optional second argument \(\epsilon\) is provided, the discontinuous step at \(x=0\) is replaced by a ramp starting at \(x=0\) and finishing at \(x=\epsilon\).

5.20 if

Performs a conditional testing of the first argument \(a\), and returns either the second optional argument \(b\) if \(a\) is different from zero or the third optional argument \(c\) if \(a\) evaluates to zero. The comparison of the condition \(a\) with zero is performed within the precision given by the optional fourth argument \(\epsilon\). If the second argument \(c\) is not given and \(a\) is not zero, the function returns one. If the third argument \(c\) is not given and \(a\) is zero, the function returns zero. The default precision is \(\epsilon = 10^{-16}\). Even though if is a logical operation, all the arguments and the returned value are double-precision floating point numbers.

5.21 integral_dt

Computes the time integral of the signal \(x\) using the trapezoidal rule using the value of the signal in the previous time step and the current value. At \(t = 0\) the integral is initialized to zero. Unlike the functional integral, this function works with expressions and not with functions. Therefore the argument \(x\) may be for example an expression involving a variable that may be read from a shared-memory object, whose time integral cannot be computed with integral.

5.22 integral_euler_dt

Idem as integral_dt but uses the backward Euler rule to update the integral value. This function is provided in case this particular way of approximating time integrals is needed.

5.23 is_even

Returns one if the argument \(x\) rounded to the nearest integer is even.

5.24 is_in_interval

Returns true if the argument~\(x\) is in the interval~\([a,b)\), i.e. including~\(a\) but excluding~\(b\).

5.25 is_odd

Returns one if the argument \(x\) rounded to the nearest integer is odd.

5.26 j0

Computes the regular cylindrical Bessel function of zeroth order evaluated at the argument \(x\).

5.27 lag

Filters the first argument \(x(t)\) with a first-order lag of characteristic time \(\tau\), i.e. this function applies the transfer function !bt [ G(s) = ] !et to the time-dependent signal \(x(t)\), by assuming that it is constant during the time interval \([t-\Delta t,t]\) and using the analytical solution of the differential equation for that case at \(t = \Delta t\) with the initial condition \(y(0) = y(t-\Delta t)\).

5.28 lag_bilinear

Filters the first argument \(x(t)\) with a first-order lag of characteristic time \(\tau\), i.e. this function applies the transfer function !bt [ G(s) = ] !et to the time-dependent signal \(x(t)\) by using the bilinear transformation formula.

5.29 lag_euler

Filters the first argument \(x(t)\) with a first-order lag of characteristic time \(\tau\), i.e. this function applies the transfer function !bt [ G(s) = ] !et to the time-dependent signal \(x(t)\) by using the Euler forward rule.

5.30 last

Returns the value the signal \(x\) had in the previous time step. This function is equivalent to the \(Z\)-transform operator “delay” denoted by \(z^{-1}\left[x\right]\). For \(t=0\) the function returns the actual value of \(x\). The optional flag \(p\) should be set to one if the reference to last is done in an assignment over a variable that already appears insi expression \(x\). See example number 2.

5.31 limit

Limits the first argument \(x\) to the interval \([a,b]\). The second argument \(a\) should be less than the third argument \(b\).

5.32 limit_dt

Limits the value of the first argument \(x(t)\) so to that its time derivative is bounded to the interval \([a,b]\). The second argument \(a\) should be less than the third argument \(b\).

5.33 log

Computes the natural logarithm of the argument \(x\). If \(x\) is zero or negative, a NaN error is issued.

5.34 mark_max

Returns the integer index \(i\) of the maximum of the arguments \(x_i\) provided. Currently only maximum of ten arguments can be provided.

5.35 mark_min

Returns the integer index \(i\) of the minimum of the arguments \(x_i\) provided. Currently only maximum of ten arguments can be provided.

5.36 max

Returns the maximum of the arguments \(x_i\) provided. Currently only maximum of ten arguments can be provided.

5.37 min

Returns the minimum of the arguments \(x_i\) provided. Currently only maximum of ten arguments can be provided.

5.38 mod

Returns the remainder of the division between the first argument \(a\) and the second \(b\). Both arguments may be non-integral.

5.39 not

Returns one if the first argument \(x\) is zero and zero otherwise. The second optional argument \(\epsilon\) gives the precision of the “zero” evaluation. If not given, default is \(\epsilon = 10^{-16}\).

5.40 random

Returns a random real number uniformly distributed between the first real argument \(x_1\) and the second one \(x_2\). If the third integer argument \(s\) is given, it is used as the seed and thus repetitive sequences can be obtained. If no seed is provided, the current time (in seconds) plus the internal address of the expression is used. Therefore, two successive calls to the function without seed (hopefully) do not give the same result. This function uses a second-order multiple recursive generator described by Knuth in Seminumerical Algorithms, 3rd Ed., Section 3.6.

5.41 random_gauss

Returns a random real number with a Gaussian distribution with a mean equal to the first argument \(x_1\) and a standard deviation equatl to the second one \(x_2\). If the third integer argument \(s\) is given, it is used as the seed and thus repetitive sequences can be obtained. If no seed is provided, the current time (in seconds) plus the internal address of the expression is used. Therefore, two successive calls to the function without seed (hopefully) do not give the same result. This function uses a second-order multiple recursive generator described by Knuth in Seminumerical Algorithms, 3rd Ed., Section 3.6.

5.42 round

Rounds the argument \(x\) to the nearest integer. Halfway cases are rounded away from zero.

5.43 sawtooth_wave

Computes a sawtooth wave betwen zero and one with a period equal to one. As with the sine wave, a sawtooh wave can be generated by passing as the argument \(x\) a linear function of time such as \(\omega t+\phi\), where \(\omega\) controls the frequency of the wave and \(\phi\) controls its phase.

5.44 sgn

Returns minus one, zero or plus one depending on the sign of the first argument \(x\). The second optional argument \(\epsilon\) gives the precision of the “zero” evaluation. If not given, default is \(\epsilon = 10^{-16}\).

5.45 sin

Computes the sine of the argument \(x\), where \(x\) is in radians. A sine wave can be generated by passing as the argument \(x\) a linear function of time such as \(\omega t+\phi\), where \(\omega\) controls the frequency of the wave and \(\phi\) controls its phase.

5.46 sinh

Computes the hyperbolic sine of the argument \(x\), where \(x\) is in radians.

5.47 sqrt

Computes the positive square root of the argument \(x\). If \(x\) is negative, a NaN error is issued.

5.48 square_wave

Computes a square function betwen zero and one with a period equal to one. The output is one for \(0 < x < 1/2\) and goes to zero for \(1/2 < x < 1\). As with the sine wave, a square wave can be generated by passing as the argument \(x\) a linear function of time such as \(\omega t+\phi\), where \(\omega\) controls the frequency of the wave and \(\phi\) controls its phase.

5.49 tan

Computes the tangent of the argument \(x\), where \(x\) is in radians.

5.50 tanh

Computes the hyperbolic tangent of the argument \(x\), where \(x\) is in radians.

5.51 threshold_max

Returns one if the first argument \(x\) is greater than the threshold given by the second argument \(a\), and zero otherwise. If the optional third argument \(b\) is provided, an hysteresis of width \(b\) is needed in order to reset the function value. Default is no hysteresis, i.e. \(b=0\).

5.52 threshold_min

Returns one if the first argument \(x\) is less than the threshold given by the second argument \(a\), and zero otherwise. If the optional third argument \(b\) is provided, an hysteresis of width \(b\) is needed in order to reset the function value. Default is no hysteresis, i.e. \(b=0\).

5.53 triangular_wave

Computes a triangular wave betwen zero and one with a period equal to one. As with the sine wave, a triangular wave can be generated by passing as the argument \(x\) a linear function of time such as \(\omega t+\phi\), where $$ controls the frequency of the wave and \(\phi\) controls its phase.

6 Functionals

6.1 derivative

Computes the derivative of the expression \(f(x)\) given in the first argument with respect to the variable \(x\) given in the second argument at the point \(x=a\) given in the third argument using an adaptive scheme. The fourth optional argument \(h\) is the initial width of the range the adaptive derivation method starts with. The fifth optional argument \(p\) is a flag that indicates whether a backward (\(p < 0\)), centered (\(p = 0\)) or forward (\(p > 0\)) stencil is to be used. This functional calls the GSL functions gsl_deriv_central or gsl_deriv_forward according to the indicated flag \(p\). Defaults are \(h = (1/2)^{-10} \approx 9.8 \times 10^{-4}\) and \(p = 0\).

6.2 func_min

Finds the value of the variable \(x\) given in the second argument which makes the expression \(f(x)\) given in the first argument to take local a minimum in the in the range \([a,b]\) given by the third and fourth arguments. If there are many local minima, the one that is closest to \((a+b)/2\) is returned. The optional fifth argument \(\epsilon\) gives a relative tolerance for testing convergence, corresponding to GSL epsrel (note that epsabs is set also to \(\epsilon)\). The sixth optional argument is an integer which indicates the algorithm to use: 0 (default) is quad_golden, 1 is brent and 2 is goldensection. See the GSL documentation for further information on the algorithms. The seventh optional argument \(p\) is a flag that indicates how to proceed if there is no local minimum in the range \([a,b]\). If \(p = 0\) (default), \(a\) is returned if \(f(a) < f(b)\) and \(b\) otherwise. If \(p = 1\) then the local minimum algorimth is tried nevertheless. Default is \(\epsilon = (1/2)^{-20} \approx 9.6\times 10^{-7}\).

6.3 gauss_kronrod

Computes the integral of the expression \(f(x)\) given in the first argument with respect to variable \(x\) given in the second argument over the interval \([a,b]\) given in the third and fourth arguments respectively using a non-adaptive procedure which uses fixed Gauss-Kronrod-Patterson abscissae to sample the integrand at a maximum of 87 points. It is provided for fast integration of smooth functions. The algorithm applies the Gauss-Kronrod 10-point, 21-point, 43-point and 87-point integration rules in succession until an estimate of the integral is achieved within the relative tolerance given in the fifth optional argument \(\epsilon\) It correspondes to GSL’s epsrel parameter (epsabs is set to zero).
The rules are designed in such a way that each rule uses all the results of its predecessors, in order to minimize the total number of function evaluations. Defaults are \(\epsilon = (1/2)^{-10} \approx 10^{-3}\). See GSL reference for further information.

6.4 gauss_legendre

Computes the integral of the expression \(f(x)\) given in the first argument with respect to variable \(x\) given in the second argument over the interval \([a,b]\) given in the third and fourth arguments respectively using the \(n\)-point Gauss-Legendre rule, where \(n\) is given in the optional fourth argument. It is provided for fast integration of smooth functions with known polynomic order (it is exact for polynomials of order \(2n-1\)). This functional calls GSL function gsl_integration_glfixedp. Default is \(n = 12\). See GSL reference for further information.

6.5 integral

Computes the integral of the expression \(f(x)\) given in the first argument with respect to variable \(x\) given in the second argument over the interval \([a,b]\) given in the third and fourth arguments respectively using an adaptive scheme, in which the domain is divided into a number of maximum number of subintervals and a fixed-point Gauss-Kronrod-Patterson scheme is applied to each quadrature subinterval. Based on an estimation of the error commited, one or more of these subintervals may be split to repeat the numerical integration alogorithm with a refined division. The fifth optional argument \(\epsilon\) is is a relative tolerance used to check for convergence. It correspondes to GSL’s epsrel parameter (epsabs is set to zero). The sixth optional argument \(1\leq k \le 6\) is an integer key that indicates the integration rule to apply in each interval. It corresponds to GSL’s parameter key. The seventh optional argument gives the maximum number of subdivisions, which defaults to 1024. If the integration interval \([a,b]\) if finite, this functional calls the GSL function gsl_integration_qag. If \(a\) is less that minus the internal variable infinite, \(b\) is greater that infinite or both conditions hold, GSL functions gsl_integration_qagil, gsl_integration_qagiu or gsl_integration_qagi are called. The condition of finiteness of a fixed range \([a,b]\) can thus be changed by modifying the internal variable infinite. Defaults are \(\epsilon = (1/2)^{-10} \approx 10^{-3}\) and \(k=3\). The maximum numbers of subintervals is limited to 1024. Due to the adaptivity nature of the integration method, this function gives good results with arbitrary integrands, even for infinite and semi-infinite integration ranges. However, for certain integrands, the adaptive algorithm may be too expensive or even fail to converge. In these cases, non-adaptive quadrature functionals ought to be used instead. See GSL reference for further information.

6.6 prod

Computes product of the \(N=b-a\) expressions \(f(i)\) given in the first argument by varying the variable~\(i\) given in the second argument between~\(a\) given in the third argument and~\(b\) given in the fourth argument,~\(i = a, a+1, \dots ,b-1,b\).

6.7 root

Computes the value of the variable \(x\) given in the second argument which makes the expression \(f(x)\) given in the first argument to be equal to zero by using a root bracketing algorithm. The root should be in the range \([a,b]\) given by the third and fourth arguments. The optional fifth argument \(\epsilon\) gives a relative tolerance for testing convergence, corresponding to GSL epsrel (note that epsabs is set also to \(\epsilon)\). The sixth optional argument is an integer which indicates the algorithm to use: 0 (default) is brent, 1 is falsepos and 2 is bisection. See the GSL documentation for further information on the algorithms. The seventh optional argument \(p\) is a flag that indicates how to proceed if the sign of \(f(a)\) is equal to the sign of \(f(b)\). If \(p=0\) (default) an error is raised, otherwise it is not. If more than one root is contained in the specified range, the first one to be found is returned. The initial guess is \(x_0 = (a+b)/2\). If no roots are contained in the range and \(p \neq 0\), the returned value can be any value. Default is \(\epsilon = (1/2)^{-10} \approx 10^{3}\).

6.8 sum

Computes sum of the \(N=b-a\) expressions \(f_i\) given in the first argument by varying the variable \(i\) given in the second argument between \(a\) given in the third argument and \(b\) given in the fourth argument, \(i=a,a+1,\dots,b-1,b\).

7 Vector functions

7.1 vecdot

Computes the dot product between vectors \(\vec{a}\) and \(\vec{b}\), which should have the same size.

7.2 vecmax

Returns the biggest element of vector \(\vec{b}\), taking into account its sign (i.e. \(1 > -2\)).

7.3 vecmaxindex

Returns the index of the biggest element of vector \(\vec{b}\), taking into account its sign (i.e. \(2 > -1\)).

7.4 vecmin

Returns the smallest element of vector \(\vec{b}\), taking into account its sign (i.e. \(-2 < 1\)).

7.5 vecminindex

Returns the index of the smallest element of vector \(\vec{b}\), taking into account its sign (i.e. \(-2 < 1\)).

7.6 vecnorm

Computes euclidean norm of vector \(\vec{b}\). Other norms can be computed explicitly using the sum functional, as illustrated in the example.

7.7 vecsize

Returns the size of vector \(\vec{b}\).

7.8 vecsum

Computes the sum of all the components of vector \(\vec{b}\).