This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Secant function

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




sec(x) represents the secant function 1/cos(x).

Specify the argument x in radians, not in degrees. For example, use π to specify an angle of 180o.

All trigonometric functions are defined for complex arguments.

Floating-point values are returned for floating-point arguments. Floating-point intervals are returned for floating-point interval arguments. Unevaluated function calls are returned for most exact arguments.

Translations by integer multiples of π are eliminated from the argument. Further, arguments that are rational multiples of π lead to simplified results; symmetry relations are used to rewrite the result using an argument from the standard interval . Explicit expressions are returned for the following arguments:


See Example 2.

The result is rewritten in terms of hyperbolic functions, if the argument is a rational multiple of I. See Example 3.

The functions expand and combine implement the addition theorems for the trigonometric functions. See Example 4.

The trigonometric functions do not respond to properties set via assume. Use simplify to take such properties into account. See Example 4.

sec(x) is immediately rewritten as 1/cos(x). To rewrite the secant function in terms of other target functions, use rewrite. For example, you can rewrite expressions involving the secant function in terms of other trigonometric functions and vice versa. See Example 5.

The inverse function is implemented as arcsec. See Example 6.

The float attributes are kernel functions, thus, floating-point evaluation is fast.

Environment Interactions

When called with a floating-point argument, the functions are sensitive to the environment variable DIGITS which determines the numerical working precision.


Example 1

Call sec with the following exact and symbolic input arguments. The secant function is rewritten in terms of the cosine function.

sec(0), sec(1), sec(5 + I), sec(PI), sec(PI/11), sec(PI/8)

sec(-x), sec(x + PI), sec(x^2 - 4)

Floating-point values are computed for floating-point arguments:

sec(123.4), sec(5.6 + 7.8*I), sec(1.0/10^20)

Floating-point intervals are computed for interval arguments:

sec(-1...1), sec(-4...-2), sec(3*PI/4...5*PI/4)

For intervals containing discontinuities, the result is a union of intervals:


-RD_INF...-1.747888503e17  union 1.0 ...RD_INF

Example 2

Some special values are implemented:

sec(PI/10), sec(2*PI/5), sec(123/8*PI), sec(-PI/12)

Translations by integer multiples of π are eliminated from the argument:

sec(x + 10*PI), sec(3 - PI), sec(x + PI), sec(2 - 10^100*PI)

All arguments that are rational multiples of π are transformed to arguments from the interval :

sec(4/7*PI), sec(-20*PI/9), sec(123/11*PI), sec(-PI/13)

Example 3

Arguments that are rational multiples of I are rewritten in terms of hyperbolic functions:

sec(5*I), sec(5/4*I), sec(-3*I)

For other complex arguments, use expand to rewrite the result:

sec(5*I + 2*PI/3), sec(PI/4 - 5/4*I), sec(-3*I + PI/2)

expand(sec(5*I + 2*PI/3)),
expand(sec(5/4*I - PI/4)),
expand(sec(-3*I + PI/2))

Example 4

The expand function implements the addition theorems:

expand(sec(x + PI/2)), expand(sec(x + y))

The combine function uses these theorems in the other direction, trying to rewrite products of trigonometric functions:

combine(1/(sec(x)*sec(y)), sincos)

The trigonometric functions do not immediately respond to properties set via assume:

assume(n, Type::Integer):

Use simplify to take such properties into account:


assume(n, Type::Even):
sec(n*PI + x), simplify(sec(n*PI + x))

y := sec(x + n*PI) + sec(x - n*PI);

delete n, y

Example 5

sec(x) is immediately rewritten as 1/cos(x):


Use rewrite to obtain a representation in terms of a specific target function:

rewrite(sec(x)*exp(2*I*x), exp);
rewrite(sec(x), tan)

Example 6

The inverse functions is implemented as arcsec:


Note that arcsec(sec(x)) is rewritten as arccos(cos(x)) and does not necessarily yield x because arccos produces values with real parts in the interval [0,π]:

arcsec(sec(4)), arcsec(sec(3.2 + I))

Example 7

diff, float, limit, taylor and other system functions handle expressions involving the trigonometric functions:

diff(sec(x), x), float(sec(3)*csc(5 + I))

limit((1 - 1/sec(x))/x^2, x = 0)

taylor(sec(x), x = 0)

Return Values

Arithmetical expression or a floating-point interval

Overloaded By


See Also

MuPAD Functions

Was this topic helpful?