8.3.2 Standard functions
The max command finds the maximum of
a sequence of real numbers.
-
max takes seq, a sequence (or list) of real numbers.
- max(seq) returns the largest number in the
sequence seq.
Example
The min command finds the minimum of
a sequence of real numbers.
-
min takes seq, a sequence (or list) of real numbers.
- min(seq) returns the smallest number in the
sequence seq.
Example
The abs command finds the absolute value of a real
or complex number.
-
abs takes
x, a real or complex number.
- abs(x) returns the absolute value of x.
Examples
The sign command finds the sign of a real
number (+1 if it is positive, 0 if it is zero, and -1 if it is
negative).
-
sign takes
x, a real number.
- sign(x) returns the sign of x.
Examples
The floor or
iPart) command finds the floor of a real
number; namely, the largest integer less than or equal to the number.
-
floor takes
x, a real number.
- floor(x) returns the floor of x.
Examples
The round command rounds a number to the
nearest integer, rounding up in the case of a half-integer.
-
round takes
x, a real number.
- round(x) returns the nearest integer to x.
Examples
The ceil or
ceiling
command finds the ceiling of a real number; namely,
the smallest integer greater than or equal to the number.
-
ceil takes
x, a real number.
- ceil(x) returns the ceiling of x.
Examples
The frac or
fPart command finds the
fractional part of a number; informally, the part of the number to the
right of the decimal point with the appropriate plus or minus sign.
For a positive real number x, the fractional part is x minus the
floor of x; for a negative real number x, the fractional part is
x minus the ceiling of x.
-
frac takes
x, a real number.
- frac(x) returns the fractional part
of x.
Examples
The trunc command truncates a real
number; namely, it removes the fractional part. The truncated number
added to the fractional part will equal the original number.
-
trunc takes
x, a real number.
- trunc(x) returns the truncated value of x.
Examples
The id command is the identity function.
Example
The sq command squares its argument.
-
sq takes
x, any object that can be multiplied by itself.
- sq(x) returns x2.
Examples
(This is a matrix product; see Section 14.2).
(This is the dot product of [1,2,3] with itself.)
The sqrt command finds the square root of
its argument.
-
sqrt takes
x, any object for which the 1/2 power makes sense.
- sqrt(x) returns x1/2.
Examples
simplify(sqrt([[2,3],[3,5]])) |
The surd command finds roots of quantities.
-
surd takes two arguments:
x and n, numbers.
- surd(x,n) returns the nth root of x; i.e., x1/n.
Example
The exp command computes the exponential
function.
-
exp takes
x, a number.
- exp(x) returns ex.
Example
The log or
ln command
computes the natural logarithm.
-
log takes
x, a number.
- log(x) returns the natural logarithm
of x.
Example
The log10 command
computes the common logarithm.
-
log10 takes
x, a number.
- log10(x) returns the base-10 logarithm of x.
Example
The log2 command computes the
binary logarithm.
-
log2 takes
x, a number.
- log2(x) returns the base-2 logarithm of x.
Example
The logb computes the logarithm to a
specified base.
-
logb takes two arguments:
x and b, non-zero numbers.
- logb(x,b) returns the base-b logarithm of x.
Example
Trigonometric functions.
Examples
Input with angle_radian equal to 1:
Input with angle_radian equal to 0:
cos(x) returns the cosine of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
tan(x) returns the tangent of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
cot(x) returns the cotangent of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
sec(x) returns the secant of x.
For example,
input with angle_radian equal to 1:
Input with angle_radian equal to 0:
csc(x) returns the cosecant of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
Inverse trigonometric functions.
The asin,
acos,
atan,
acot, asec,
acsc commands are the inverse
trigonometric functions. The latter are defined by:
-
asec(x)=acos(1/x),
- acsc(x)=asin(1/x),
- acot(x)=atan(1/x).
arcsin,
arccos and
arctan are synonyms for
asin, acos and atan, respectively.
-
These functions take one argument:
x, a number.
- They return a number which can represent an angle; by default,
the angles will be in radians, but you can set Xcas to
use degrees (see Section 2.5.3) by setting the variable
angle_radian to 0; resetting it to 1 will change the
angle measure to radians again.
Examples
Input with angle_radian equal to 1:
Input with angle_radian equal to 0:
acos(x) returns the arccosine of x.
For example:
Input with angle_radian equal to 1:
Input with angle_radian equal to 0:
atan(x) returns the arctangent of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 1:
acot(x) returns the arccotangent of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
asec(x) returns the arcsecant of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
acsc(x) returns the arccosecant of x.
For example, input with angle_radian equal to 1:
Input with angle_radian equal to 0:
Hyperbolic functions.
The sinh, cosh,
and tanh commands compute the hyperbolic
sine, hyperbolic cosine, and hyperbolic tangent functions.
-
These functions take one argument:
x, a number.
- sinh(x) returns the hyperbolic sine of x.
Examples
cosh(x) returns the hyperbolic cosine of x.
For example:
tanh(x) returns the hyperbolic tangent of x.
For example:
Inverse hyperbolic functions.
The asinh,
acosh, and
atanh commands compute the inverse
hyperbolic functions.
arcsinh,
arccosh and
arctanh are synonyms for
asinh, acosh and atanh, respectively.
-
These functions take one argument:
x, a number.
- asinh(x), acosh(x), and atanh(x) return
the inverse hyperbolic sine, cosine, and tangent of x, respectively.
Examples
acosh(x) returns the inverse hyperbolic cosine of x.
For example:
atanh(x) returns the inverse hyperbolic tangent of x.
For example: