Main Content


Symbolic sine function




sin(X) returns the sine function of X.


Sine Function for Numeric and Symbolic Arguments

Depending on its arguments, sin returns floating-point or exact symbolic results.

Compute the sine function for these numbers. Because these numbers are not symbolic objects, sin returns floating-point results.

A = sin([-2, -pi, pi/6, 5*pi/7, 11])
A =
   -0.9093   -0.0000    0.5000    0.7818   -1.0000

Compute the sine function for the numbers converted to symbolic objects. For many symbolic (exact) numbers, sin returns unresolved symbolic calls.

symA = sin(sym([-2, -pi, pi/6, 5*pi/7, 11]))
symA =
[ -sin(2), 0, 1/2, sin((2*pi)/7), sin(11)]

Use vpa to approximate symbolic results with floating-point numbers:

ans =
[ -0.90929742682568169539601986591174,...

Plot Sine Function

Plot the sine function on the interval from -4π to 4π.

syms x
fplot(sin(x),[-4*pi 4*pi])
grid on

Figure contains an axes object. The axes object contains an object of type functionline.

Handle Expressions Containing Sine Function

Many functions, such as diff, int, taylor, and rewrite, can handle expressions containing sin.

Find the first and second derivatives of the sine function:

syms x
diff(sin(x), x)
diff(sin(x), x, x)
ans =
ans =

Find the indefinite integral of the sine function:

int(sin(x), x)
ans =

Find the Taylor series expansion of sin(x):

taylor(sin(x), x)
ans =
x^5/120 - x^3/6 + x

Rewrite the sine function in terms of the exponential function:

rewrite(sin(x), 'exp')
ans =
(exp(-x*1i)*1i)/2 - (exp(x*1i)*1i)/2

Evaluate Units with sin Function

sin numerically evaluates these units automatically: radian, degree, arcmin, arcsec, and revolution.

Show this behavior by finding the sine of x degrees and 2 radians.

u = symunit;
syms x
f = [x* 2*u.radian];
sinf = sin(f)
sinf =
[ sin((pi*x)/180), sin(2)]

You can calculate sinf by substituting for x using subs and then using double or vpa.

Input Arguments

collapse all

Input, specified as a symbolic number, scalar variable, matrix variable (since R2021a), expression, or function, or as a vector or matrix of symbolic numbers, scalar variables, expressions, or functions.

More About

collapse all

Sine Function

The sine of an angle, α, defined with reference to a right angled triangle is

sin(α)=opposite sidehypotenuse=ah.

The sine of a complex argument, α, is


Version History

Introduced before R2006a

See Also

| | | | | | | | | | |