Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

sin
julia
math
communitycreator

How to use the sin method in Julia

Programming Bytes

Overview

The sin() method calculates the sine value of x , where xis in radians.

Syntax

sin(x)
Julia's sin function syntax

Parameter

This method takes the parameter x, which represents the radian value for which the sine value is to be found.

Return value

This method returns the sine value of the argument.

Code

The code below demonstrates the use of the sin method:

## find sin of radian
degree = 0
radian = deg2rad(degree)
println( "sin($(radian)) => $(sin(radian))")

## find sin of 10
degree = 10
radian = deg2rad(degree)
println( "sin($(radian)) => $(sin(radian))")
Using the sin method

Explanation

Line 2: We create a new variable degree and assign 0 as a value to it.

Line 3: We use the deg2rad method with the degree variable as an argument. This method converts the degree to radians. The radian value of 0 degrees is 0.0.

Line 4: We use the sin method with the variable radian as an argument. This method calculates the sine value of the radian. In our case, the sine value of radian is 0.0.

Line 7: We assign 10 as the value for the degree variable.

Line 8: We use the deg2rad method with the degree variable as an argument. This method converts the degree to radians. The radian value of 10 degrees is 0.17453292519943295.

Line 9: We use the sin method with the variable radian as an argument. This method calculates the sine value of the radian. In our case, the sine value of radian is 0.17364817766693033.

RELATED TAGS

sin
julia
math
communitycreator
RELATED COURSES

View all Courses

Keep Exploring