Transforms and Functions

IC-CAP Function List

Math Functions

abs
Abso1ute value function (magnitude when input data is complex)
acs
Inverse cosine in radians.
acsh
Inverse hyperbolic cosine.
arg
Argument (phase angle), in radians, for a complex number.
asn
Inverse sine in radians.
asnh
Inverse hyperbolic sine.
atn
Inverse tangent in radians.
atnh
Inverse hyperbolic tangent.
conjg
Complex conjugate function.
correlation
Calculates the correlation coefficient for one data set versus another, at a particular curve (step number). Indicates the degree to which the 2 data sets share a linear dependence.
cos
Cosine of an angle in radians.
cosh
Hyperbolic cosine.
derivative
Calculates the derivative of data set Y relative to data set X. The order can be specified. Data set X must be an evenly spaced sweep. A three-point numerical derivative formula is used, except for the endpoints, where a two-point formula is used.
equation
Uses the Parameter Extraction Language interpreter to evaluate an expression and produce a data set. This function is rarely needed, since arithmetic expressions are directly accepted in plot definitions and in the input fields to all of the other functions listed here. Chapter 14, Transforms and Functions contains a complete description of the expressions supported by the Parameter Extraction Language.
exp
The arithmetic exponential function; the inverse of the function log.
fit_line
Calculates and returns a least-squares fitted line. Accepts an X data set followed by a Y data set. If the Y data has multiple curves (steps), fit_line yields multiple fitted lines, one for each curve. Use linfit for the slope and intercept, rather than a plottable data set. NOTE: the imaginary part of the input data sets is disregarded.
log
Natural logarithm.
log10
Base 10 logarithm.
mean
Calculates the arithmetic mean of a data set. Returns a single value. Adequate for a real or complex data set, but if a data set of matrices is received, only the 1, 1 data is considered. A data set specification like S.21 is adequate, since this is a data set of complex numbers.
random
Creates a data set of random numbers with values lying between 0 and 1.
sin
Sine of an angle in radisns.
sinh
Hyperbolic sine.
sqrt
Square root function. Note that sqrt(-1) correctly produces an imaginary result.
tan
Tangent of an angle in radians.
tanh
Hyperbolic tangent.
variance
Calculates the statistical variance of a data set. Adequate for a real or complex data set, but if a data set of matrices is received, only the 1, 1 data is considered. A data set specification like S.21 is adequate, since this is a data set of complex numbers.

Built-in Functions

The following functions are built into the Parameter Extraction Language. Their names can be entered in all upper-case or all lower-case, as in HP BASIC. Some of these are duplicated in the IC-CAP Function List, like log but most are not. Some of these functions were built-in for efficiency with scalsr data (the Function List has functions designed to operate best on data sets). Other built-in functions are for programming convenience, like the size function, and the system$ function.

NOTE: A function applied to a data set, unless otherwise noted, generates a new data set in which the specified function has been applied to every point. However, the functions max, min, and size each return single numbers only.

abs
Absolute value of a single real number or magnitude of a complex number.
exp
e is raised to the power specified by the argument.
imag
Extracts the imaginary part of a data set, matrix, or complex number.
imaginary
Extracts the imaginry part of a data set, matrix, or complex number.
log
Computes log base e.
log10 or lgt
Computes log base 10.
mag
Computes the magnitude for a complex number, or for each complex number in a matrix, data set, or data set of matrices.
magnitude
Computes the magnitude for a complex number, or for each complex number in a matrix, data set, or data set of matrices.
max
As in HP BASIC, max takes any number of arguments. The argument list can be a mixture of scalars and data sets, and the function returns the maximum value found in any of them. This always returns a single real number, and only the real parts are considered. If matrices are received, only the 1, 1 points are considered.
min
Behaves like max, but returns the minimum value.
ph
Computes the phase angle in radians for a complex number, or for each complex number in a matrix, data set, or data set of matrices.
phase
Computes the phase angle in radians for a complex number, or for each complex number in a matrix, data set, or data set of matrices.
real
Extracts the real part of a data set, matrix, or complex number.
size
Returns the number of points in a data set, which is an integer.
sqrt
Square root function. Complex and negative quantities produce correct complex or imaginary results.
system
Accepts a string argument, which is a shell command to invoke. You can employ all valid shell I/O on and other shell syntax within the string argument. It returns an integer, which is the exit status of the shell. If the shell command generates output, it is printed in the terminal window from which the IC-CAP program was started. Refer to system$, below.
system$
Similsr to system, above. It differs in that it captures the command's output, instead of letting it go to the terminal window. Instead of returning an integer, it returns the output that the shell command generated. For example:
   !initialize my date$ with output
   ! of HP-UX date command
   my date$ = system$("date")
val
Generates a number, given a string presentation of a simple (not expression) integer, floating point, or complex number. For example:
   linput "give a number",x$
   x = val (x$)
val$
Generates a string, given a numeric expression. In conjunction with the & operator (string concatenation), it can be useful for formatting.

Real and complex scalars and data sets are accepted by all functions, with the following exceptions: system, system$, and val expect to receive string data, and val$ expects a scalar number.

Built-in Constants

Several constants are recognized. Like statement names and built-in function names, these are reserved words. This means, for example, that you should not attempt to name a variable pi. The recognized constants are as follows:

PI or pi
2PI or 2pi
J or j (square root of -1)

Expressions

As explsined in the Data Types section, each type of data can be considered a simple expression. The primitive data types can make up more complex expressions by applying functions, like log, or operators, like "+". In this section, the abbreviation expr denotes an expression. The abbreviation string_expr denotes a string expression.

(expr)
Parentheses force precedence and group expressions.

expr + expr
expr - expr
expr * expr

expr / expr
expr // expr
In IC-CAP, objects, including data sets, may be named using the "/" symbol. These same data sets could be used as arguments in a divide operation. To assure that "/" is understood as the divide operator, enter "/" surrounded by white space, or enter "//". If a "/" is followed by a digit, divide is also understood, since no data set name in IC-CAP can start with a digit. The expression (ic)/(ib) is an example of another technique to use.

expr ^ expr
expr ** expr
Both of these operators express exponentiation, and are equivalents.

string_expr & string_expr
As in HP BASIC, this operator performs string concatenation

log(expr)
Performs a natural log function. Refer to Built-in Functions for a list of other functions. Refer also to Calls to the Function List Library.

Most operations make reasonable attempts to promote certain operands, if that is necessary to complete a computation. For example:

   ib + 2e-6
promotes the scalar number 2e-6 to be a data set, which in turn can be added to the data set ib.

For most arithmetic operations performed on a data set, the function or operator is applied point-by-point, producing a data set. The behavior of individual functions in this regard is clarified in their descriptions, in the Built-in Functions section.

There are some limitations in the ability of the 5 basic arithmetic operators, like "/" and "^", to work with data sets. They are as follows:

The arithmetic in Programs is generally complex floating point. Thus, it is possible to see a residue not expected from integer or real arithmetic. For example:

   print (0+j)^2
may produce
   -1+j*1.22461E-16
rather than
   -1+j*0

This is due to finite precision in the library function that handles exponentiation of complex quantities.

Since complex arithmetic is used, success can occur in cases where a function could be expected to fail. For example,

   acsh(.5)
yields
   0+j*1.05

If acsh were implemented to accept a real argument and return a real result, this call would fail. The complex arithmetic permits a wider domain of valid inputs, but in cases where a real input should produce a real output, the complex arithmetic is indistinguishable from real arithmetic.

Boolean Expressions

The following expressions can be used in the branching constructs (IF, IF...ENDIF, and WHILE...ENDWHILE), or simply to generate the quantities 0 and 1. In this section, the abbreviation bool_expr denotes a boolean expression.

NOTE: Be careful to note the distinction between the "=" operator (used for assignment) and the "==" operator. BASIC differs, in using "=" for both assignment and comparison.

With a SUN workstation, be aware that cases have been observed in which == may not behave as expected. For example, if you repeatedly increment the quantity 0.3 by the smount 0.025, the results may be slightly less (in the 15th decimal place) than the expected sequence of values: 0.325, 0.350,..., 0.4. Under these circumstances, == may yield FALSE unexpectedly. This results from the presentation of fractional quantities in SunOS.

expr == expr
This operator tests for equality, and can be used with string, integer, double, complex, and matrix types.

expr <> expr
This operator can be used with string, integer, double, complex, and matrix types to test for inequality.

expr > expr
expr >= expr
expr < expr
expr <= expr
These four operators can be used with integers, doubles, and complex quantities. They designate the standard comparison operations found in BASIC languages. With complex quantities, imaginary parts are discarded. (You can apply the mag function to each quantity to compare magnitudes of complex quantities.)

bool_expr AND bool_expr

bool_expr OR bool_expr

NOT boolean_expr

Any non-zero integer, double, or complex number is considered TRUE. For example:

   IF 2 THEN PRINT 'hi' ! this always prints
A string with length > 0 is TRUE. For example:
   IF "Hello world" THEN PRINT "HI TO YOU TOO"
prints the second expression in the string,
   HI TO YOU TOO

Copyright 1990-1993 Hewlett-Packard Company
All rights reserved.
Used with permission.
No part of this document may be redistributed without prior written constent of Hewlett-Packard Company.

Warning! This is the archived 1999 Fabweb site! Here is the latest site