One-dimensional functions



1 One-dimensional functions

This example shows how functions can be defined and used in wasora.

1.1 algebraic.was

Two algebraic functions f(x) and g(x) are defined and afterward printed and plotted using qdp, along with the integral of their product.

Output of algebraic.was
Output of algebraic.was

1.2 inline.was

Now, another function called f(x) is defined by a set of scattered points. By default, wasora interpolates the data with linear functions. If PRINT_FUNCTION does not get a range, it prints the definition points. Otherwise, the function is interpolated at the corresponding points. Finally, f(x) can be evaluated at any value of x.

Output of inline.was
Output of inline.was

1.3 file.was

This example shows three different methods of one-dimensional interpolation provided by wasora (indeed, by the GNU Scientific Library). The data is read from a file, so the three functions use the same data set but are interpolated in different ways. Recall that whenever a one-dimensional point-wise function called f is defined, three new variables are also defined:

  1. f_a contains the first point-wise value of the independent variable
  2. f_b contains the last point-wise value of the independent variable
  3. f_n contains the number of points of definition
Output of file.was
Output of file.was

1.4 vectors.was

The same data set is now used to define the same three functions f(x), g(x) and h(x) as before but using vectors instead of files. The usage of the derivative and integral functionals to construct new functions of x by means of an intermediate variable~x' is ilustrated. Also, note that the size of the vector datax is defined as a constant NUMBER. Refer to the documentation of the VECTOR keyword for further information.

Derivatives
Derivatives
Integrals
Integrals

1.5 satwater.was

This example builds functions of saturated water properties by reading a file, which can be freely downloaded from NIST, containing several columns with data. The terminal shows the actual content of the file. The first two columns contain the saturation temperature and pressure, and the third one contains the liquid density. First, saturation pressure vs. temperature and the inverse saturation temperature vs. pressure functions are constructed. Also functions of the saturated liquid density as a function of the temperature and of the pressure are constructed by selecting the appropriate columns as the independent and dependent variable. Finally, the partial derivatives of the density with respect to temperature and pressure are defined as continuous functions, with the derivative functional acting on the akima-interpolated data set. Three out of the many possible curves are plotted in this example, giving the optional range to explicitly show how the interpolation works. The original points are also plotted for comparison. More columns could have also been retained from the original data set obtained from NIST.

Saturation pressure
Saturation pressure
Saturation temperature
Saturation temperature
Derivative of density with respect to temperature \partial \rho/\partial T
Derivative of density with respect to temperature \partial \rho/\partial T