Previous Page Next Page Contents

sin, cos, tan, csc, sec, cot -- the trigonometric functions

Introduction

sin(x) represents the sine function.

cos(x) represents the cosine function.

tan(x) represents the tangent function sin(x)/cos(x).

csc(x) represents the cosecant function 1/sin(x).

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

cot(x) represents the cotangent function cos(x)/sin(x).

Call(s)

sin(x)
cos(x)
tan(x)
csc(x)
sec(x)
cot(x)

Parameters

x - an arithmetical expression

Returns

an arithmetical expression.

Overloadable:

x

Side Effects

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

Related Functions

arcsin, arccos, arctan, arccsc, arcsec, arccot

Details

Example 1

We demonstrate some calls with exact and symbolic input data:

>> sin(PI), cos(1), tan(5 + I), csc(PI/2), sec(PI/11), cot(PI/8)
                                             1       1/2
               0, cos(1), tan(5 + I), 1, ---------, 2    + 1
                                            / PI \
                                         cos| -- |
                                            \ 11 /
>> sin(-x), cos(x + PI), tan(x^2 - 4)
                                              2
                       -sin(x), -cos(x), tan(x  - 4)

Floating point values are computed for floating point arguments:

>> sin(123.4), cos(5.6 + 7.8*I), cot(1.0/10^20)
            -0.7693905459, 946.4239673 + 770.3351731 I, 1.0e20

Example 2

Some special values are implemented:

>> sin(PI/10), cos(2*PI/5), tan(123/8*PI), cot(-PI/12)
                1/2         1/2
               5           5            1/2         1/2
               ---- - 1/4, ---- - 1/4, 2    + 1, - 3    - 2
                4           4

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

>> sin(x + 10*PI), cos(3 - PI), tan(x + PI), cot(2 - 10^100*PI)
                      sin(x), -cos(3), tan(x), cot(2)

All arguments that are rational multiples of PI are transformed to arguments from the interval [0,PI/2):

>> sin(4/7*PI), cos(-20*PI/9), tan(123/11*PI), cot(-PI/13)
               / 3 PI \     / 2 PI \     / 2 PI \       / PI \
            sin| ---- |, cos| ---- |, tan| ---- |, - cot| -- |
               \  7   /     \  9   /     \  11  /       \ 13 /

Example 3

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

>> sin(5*I), cos(5/4*I), tan(-3*I)
                     I sinh(5), cosh(5/4), -I tanh(3)

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

>> sin(5*I + 2*PI/3), cos(5/4*I - PI/4), tan(-3*I + PI/2)
              / 2 PI       \     /         PI \     / PI       \
           sin| ---- + 5 I |, cos| 5/4 I - -- |, tan| -- - 3 I |
              \  3         /     \         4  /     \ 2        /
>> expand(sin(5*I + 2*PI/3)), expand(cos(5/4*I - PI/4)),
   expand(tan(-3*I + PI/2))
       1/2                           1/2
      3    cosh(5)                  2    cosh(5/4)
      ------------ - 1/2 I sinh(5), -------------- +
           2                              2
      
                1/2              I cosh(3)
         1/2 I 2    sinh(5/4), - ---------
                                  sinh(3)

Example 4

The expand function implements the addition theorems:

>> expand(sin(x + PI/2)), expand(cos(x + y))
                   cos(x), cos(x) cos(y) - sin(x) sin(y)

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

>> combine(sin(x)*sin(y), sincos)
                          cos(x - y)   cos(x + y)
                          ---------- - ----------
                              2            2

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

>> assume(n, Type::Integer): sin(n*PI), cos(n*PI)
                           sin(n PI), cos(n PI)

Use simplify to take such properties into account:

>> simplify(sin(n*PI)), simplify(cos(n*PI))
                                        n
                                 0, (-1)
>> assume(n, Type::Odd): sin(n*PI + x), simplify(sin(n*PI + x))
                          sin(x + n PI), -sin(x)
>> y := cos(x - n*PI) + cos(n*PI - x): y , simplify(y)
                 cos(x - n PI) + cos(n PI - x), -2 cos(x)
>> delete n, y:

Example 5

Various relations exist between the trigonometric functions:

>> csc(x), sec(x)
                                1       1
                              ------, ------
                              sin(x)  cos(x)

The function expand rewrites all trigonometric functions in terms of sin and cos:

>> expand(tan(x)), expand(cot(x))
                              sin(x)  cos(x)
                              ------, ------
                              cos(x)  sin(x)

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

>> rewrite(tan(x)*exp(2*I*x), sincos), rewrite(sin(x), cot)
                                                     / x \
                                                2 cot| - |
               sin(x) (cos(2 x) + I sin(2 x))        \ 2 /
               ------------------------------, -------------
                           cos(x)                 / x \2
                                               cot| - |  + 1
                                                  \ 2 /

Example 6

The inverse functions are implemented by arcsin, arccos etc.:

>> sin(arcsin(x)), sin(arccos(x)), cos(arctan(x))
                                 2 1/2       1
                        x, (1 - x )   , -----------
                                          2     1/2
                                        (x  + 1)

Note that arcsin(sin(x)) does not necessarily yield x, because arcsin produces values with real parts in the interval [-PI/2, PI/2]:

>> arcsin(sin(3)), arcsin(sin(1.6 + I))
                        PI - 3, 1.541592654 - 1.0 I

Example 7

Various system functions such as diff, float, limit, or series handle expressions involving the trigonometric functions:

>> diff(sin(x^2), x), float(sin(3)*cot(5 + I))
                        2
               2 x cos(x ), - 0.01668502608 - 0.1112351327 I
>> limit(x*sin(x)/tan(x^2), x = 0)
                                     1
>> series((tan(sin(x)) - sin(tan(x)))/sin(x^7), x = 0, 10)
                                      2
                                  29 x       3
                           1/30 + ----- + O(x )
                                   756

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000