sin

sin(x)

Compute sine of x, where x is in radians

Examples

  1. Calculate the sine of a single value:

    julia> x = 0.5;
    julia> sin(x)
    0.479425538604203

    This example computes the sine of the value 0.5 in radians.

  2. Compute the sine of an array of values:

    julia> angles = [0.0, π/6, π/4, π/3, π/2];
    julia> sin(angles)
    5-element Array{Float64,1}:
    0.0
    0.5
    0.7071067811865476
    0.8660254037844386
    1.0

    It calculates the sine of each element in the angles array.

  3. Evaluate the sine function for a matrix:
    julia> mat = [0.0  π/4;
                 π/3 π/2];
    julia> sin(mat)
    2×2 Array{Float64,2}:
    0.0              0.7071067811865476
    0.8660254037844386  1.0

    In this example, the sin function is applied element-wise to each entry of the matrix.

Common mistake example:

julia> sin("1.0")
ERROR: MethodError: no method matching sin(::String)

In this case, the argument provided to the sin function is of type String, which is not compatible. Ensure that the input to sin is a numeric type, such as Float64 or Int.

See Also

acos, acosd, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, asecd, asech, asin, asind, asinh, atan, atan2, atand, atanh, cos, cosc, cosd, cosh, cospi, cot, cotd, coth, csc, cscd, csch, deg2rad, rad2deg, sin, sinc, sind, sinh, sinpi, tan, tand, tanh,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: