Skip to main content

sin, cos, tan

sin, cos, tan Function

Syntax:

sin radians → number

cos radians → number

tan radians → number

Arguments and Values:

radians—a number given in radians.

number—a number .

Description:

sin, cos, and tan return the sine, cosine, and tangent, respectively, of radians.

Examples:

(sin 0)0.0 
(cos 0.7853982)0.707107
(tan #c(0 1)) → #C(0.0 0.761594)

Exceptional Situations:

Should signal an error of type type-error if radians is not a number . Might signal arithmetic-error.

See Also:

asin, acos, atan, Section 12.1.3.3 (Rule of Float Substitutability)

asin, acos, atan

Expanded Reference: sin, cos, tan

Basic trigonometric functions

sin, cos, and tan take an angle in radians and return the sine, cosine, and tangent respectively.

(sin 0)
=> 0.0
(cos 0)
=> 1.0
(tan 0)
=> 0.0

Common angle values

The constant pi provides the value of pi for computing standard angles.

(sin (/ pi 2))
=> 1.0d0
(cos pi)
=> -1.0d0
(sin pi)
;; => impl-dependent
(tan (/ pi 4))
;; => impl-dependent

Working with degrees

Convert degrees to radians by multiplying by pi/180.

(defun deg-to-rad (degrees)
(* degrees (/ pi 180)))

(sin (deg-to-rad 30))
;; => impl-dependent
(cos (deg-to-rad 60))
;; => impl-dependent
(tan (deg-to-rad 45))
;; => impl-dependent

Trigonometric identity

The Pythagorean identity holds: sin^2(x) + cos^2(x) = 1.

(let ((x 1.0))
(+ (expt (sin x) 2) (expt (cos x) 2)))
=> 0.99999994

Complex arguments

These functions also accept complex number arguments.

(sin #c(0 1))
=> #C(0.0 1.1752012)
(cos #c(0 1))
;; => impl-dependent
(tan #c(0 1))
=> #C(0.0 0.7615942)