Standard functions

### 7.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

max(0,1,2,-1,-2)

2 |  |  |  |  |  |  |  |  |  |

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

min(0,1,2,-1,-2)

−2 |  |  |  |  |  |  |  |  |  |

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

abs(-5)

5 |  |  |  |  |  |  |  |  |  |

abs(3+4*i)

5 |  |  |  |  |  |  |  |  |  |

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

sign(-4)

−1 |  |  |  |  |  |  |  |  |  |

sign(0)

0 |  |  |  |  |  |  |  |  |  |

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

floor(4.1)

4 |  |  |  |  |  |  |  |  |  |

floor(-4.1)

−5 |  |  |  |  |  |  |  |  |  |

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

round(3.4)

3 |  |  |  |  |  |  |  |  |  |

round(-3.4)

−3 |  |  |  |  |  |  |  |  |  |

round(3.5)

4 |  |  |  |  |  |  |  |  |  |

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

ceiling(4.1)

5 |  |  |  |  |  |  |  |  |  |

ceiling(-4.1)

−4 |  |  |  |  |  |  |  |  |  |

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

frac(3.24)

0.24 |  |  |  |  |  |  |  |  |  |

frac(-3.24)

−0.24 |  |  |  |  |  |  |  |  |  |

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

trunc(3.24)

3 |  |  |  |  |  |  |  |  |  |

trunc(-3.24)

−3 |  |  |  |  |  |  |  |  |  |

The id command is the identity function.

- id takes one argument or a sequence of:

  seq, whose elements can be any type.

- id(seq) returns seq.

#### Example

id(a,1,"abc",[1,2,3])

a,1,“abc”, | ⎡ ⎣ | 1,2,3 | ⎤ ⎦

The sq command squares its argument.

- sq takes x, any object that can be multiplied by itself.
- sq(x) returns x2.

#### Examples

sq(5)

25 |  |  |  |  |  |  |  |  |  |

sq(x+y)

| ⎛ ⎝ | x+y | ⎞ ⎠ | 2

sq([[1,2],[3,4]])

⎡ ⎢ ⎣ |
7 | 10
15 | 22
| ⎤ ⎥ ⎦

(This is a matrix product; see Section 13.2).

sq([1,2,3])

14 |  |  |  |  |  |  |  |  |  |

(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

sqrt(9)

3 |  |  |  |  |  |  |  |  |  |

sqrt((x+y)^2)

| ⎪ ⎪ | x+y | ⎪ ⎪

simplify(sqrt([[2,3],[3,5]]))

⎡ ⎢ ⎣ |
1 | 1
1 | 2
| ⎤ ⎥ ⎦

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

surd(15.625,3)

2.5 |  |  |  |  |  |  |  |  |  |

The exp command computes the exponential function.

- exp takes x, a number.
- exp(x) returns ex.

#### Example

exp(1.0)

2.71828182846 |  |  |  |  |  |  |  |  |  |

The log or ln command computes the natural logarithm function.

- log takes x, a number.
- log(x) returns the natural logarithm of x.

#### Example

log(2.0)

0.69314718056 |  |  |  |  |  |  |  |  |  |

The log10 computes the the base-10 logarithm.

- log10 takes x, a number.
- log10(x) returns the base-10 logarithm of x.

#### Example

log10(1000)

3 |  |  |  |  |  |  |  |  |  |

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

logb(10.0,2)

3.32192809489 |  |  |  |  |  |  |  |  |  |

##### Trigonometric functions.

- The sin command is the sine function.
- The cos command is the cosine function.
- The tan command is the tangent function, tanx=sinx/cosx.
- The cot command is the cotangent function, cotx=cosx/sinx.
- The sec command is the secant function, secx=1/cosx.
- The csc command is the cosecant function, cscx=1/sinx.
- These commands take one argument: x, a number.

  The number x will by default represent an angle measured 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.

- sin(x) returns the sine of x.

#### Examples

Input with angle_radian equal to 1:

sin(pi/4)

√ |
2
2

Input with angle_radian equal to 0:

sin(30)

1
2

cos(x) returns the cosine of x. For example, input with angle_radian equal to 1:

cos(pi/6)

√ |
3
2

Input with angle_radian equal to 0:

cos(90)

0 |  |  |  |  |  |  |  |  |  |

tan(x) returns the tangent of x. For example, input with angle_radian equal to 1:

tan(pi/4)

1 |  |  |  |  |  |  |  |  |  |

Input with angle_radian equal to 0:

tan(60)

| √ |
3

cot(x) returns the cotangent of x. For example, input with angle_radian equal to 1:

cot(pi/6)

2 | √ |
3
2

Input with angle_radian equal to 0:

cot(45)

1 |  |  |  |  |  |  |  |  |  |

sec(x) returns the secant of x. For example, input with angle_radian equal to 1:

sec(pi/3)

2 |  |  |  |  |  |  |  |  |  |

Input with angle_radian equal to 0:

sec(30)

2
√ |
3

csc(x) returns the cosecant of x. For example, input with angle_radian equal to 1:

csc(pi/4)

2
√ |
2

Input with angle_radian equal to 0:

csc(30)

2 |  |  |  |  |  |  |  |  |  |

##### 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:

asin(1/2)

π
6

Input with angle_radian equal to 0:

asin(1)

π
2

acos(x) returns the arccosine of x. For example: Input with angle_radian equal to 1:

acos(sqrt(3)/2)

1
6
| π

Input with angle_radian equal to 0:

acos(-1/2)

120 |  |  |  |  |  |  |  |  |  |

atan(x) returns the arctangent of x. For example, input with angle_radian equal to 1:

atan(sqrt(3))

π
3

Input with angle_radian equal to 1:

atan(1)

45 |  |  |  |  |  |  |  |  |  |

acot(x) returns the arccotangent of x. For example, input with angle_radian equal to 1:

acot(sqrt(3))

π
6

Input with angle_radian equal to 0:

acot(1/sqrt(3))

60 |  |  |  |  |  |  |  |  |  |

asec(x) returns the arcsecant of x. For example, input with angle_radian equal to 1:

asec(1)

0 |  |  |  |  |  |  |  |  |  |

Input with angle_radian equal to 0:

asec(sqrt(2))

45 |  |  |  |  |  |  |  |  |  |

acsc(x) returns the arccosecant of x. For example, input with angle_radian equal to 1:

acsc(1)

π
2

Input with angle_radian equal to 0:

acsc(2)

30 |  |  |  |  |  |  |  |  |  |

##### 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

sinh(1.0)

1.17520119364 |  |  |  |  |  |  |  |  |  |

cosh(x) returns the hyperbolic cosine of x. For example:

cosh(0)

1 |  |  |  |  |  |  |  |  |  |

tanh(x) returns the hyperbolic tangent of x. For example:

tanh(-1.0)

−0.761594155956 |  |  |  |  |  |  |  |  |  |

##### 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

asinh(2)

ln | ⎛ ⎜ ⎝ | 2+ | √ |
5
| ⎞ ⎟ ⎠

acosh(x) returns the inverse hyperbolic cosine of x. For example:

acosh(1)

0 |  |  |  |  |  |  |  |  |  |

atanh(x) returns the inverse hyperbolic tangent of x. For example:

atanh(1/2)

ln | ⎛ ⎝ | 3 | ⎞ ⎠
2