Python | math.sin() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.sin() function returns the sine of value passed as argument. The value passed in this function should be in radians.

Syntax: math.sin(x)

Parameter:
x : value to be passed to sin()

Returns: Returns the sine of value passed as argument

Code #1:

# Python code to demonstrate the working of sin() # importing "math" for mathematical operations import math a = math.pi / 6 # returning the value of sine of pi / 6 print ( "The value of sine of pi / 6 is : " , end = "") print (math.sin(a)) Output:
The value of sine of pi/6 is : 0.49999999999999994


Code #2:

# Python program showing # Graphical representation of # sin() function import math import matplotlib.pyplot as plt in_array = [ - 3.14159265 , - 2.57039399 , - 0.28559933 , 0.28559933 , 2.57039399 , 3.14159265 ] for i in range ( len (in_array)): out_array.append(math.sin(in_array[i])) print ( "in_array : " , in_array) print ( "\nout_array : " , out_array) # red for numpy.sin() plt.plot(in_array, out_array, color = 'red' , marker = "o" ) plt.title( "math.sin()" ) plt.xlabel( "X" ) plt.ylabel( "Y" ) Output:

in_array : [-3.14159265, -2.57039399, -0.28559933, 0.28559933, 2.57039399, 3.14159265]

out_array : [-3.5897930298416118e-09, -0.5406408168673427, -0.2817325547837714, 0.2817325547837714, 0.5406408168673427, 3.5897930298416118e-09]

Like Article -->

Please Login to comment.

Similar Reads

Python - cmath.sin() function

cmath is Python built-in module that is used for complex number mathematics. cmath module has a method sin() that returns sine of the complex number passed to it. Syntax: cmath.sin(Z) Parameter: It requires only one parameter i.e the number for which sine needs to be calculated. Return: Returns a complex number that is the sine of the number passed

1 min read Python | PyTorch sin() method

PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.sin() provides support for the sine function in PyTorch. It expects the input in radian form and the output is in the range [-1, 1]. The input type is tensor and if the input conta

2 min read Python | sympy.sin() method

In sympy, the sin() method is a sine function. Using the sin(x) method in the sympy module, we can compute the sine of x. Syntax : sympy.sin(x) Return : Returns the sine of x Code #1: Below is the example using the sin() method to find the sine function. C/C++ Code # importing sympy library from sympy import * # calling sin() method on expression g

1 min read Python - tensorflow.raw_ops.Sin()

TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning neural networks. TensorFlow raw_ops provides low level access to all TensorFlow operations. Sin() is used to find element wise sine of x. Syntax: tf.raw_ops.Sin(x, name) Parameters: x: It's the input tensor. Allowed dtype for this tensor

2 min read numpy.sin() in Python

numpy.sin(x[, out]) = ufunc 'sin') : This mathematical function helps user to calculate trigonometric sine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. 2pi Radians = 36o degrees Return : An array with trigonometric sine of x for all x i.e. array elements Code #1 : Working Python Code # Python progra

1 min read Python math.sqrt() function | Find Square Root in Python

sqrt() function returns square root of any number. It is an inbuilt function in Python programming language. In this article, we will learn more about the Python Program to Find the Square Root. sqrt() Function We can calculate square root in Python using the sqrt() function from the math module. In this example, we are calculating the square root

3 min read Python math function | modf()

modf() function is an inbuilt function in Python that returns the fractional and integer parts of the number in a two-item tuple. Both parts have the same sign as the number. The integer part is returned as a float. Syntax : modf(number) Time Complexity: O(1) Auxiliary Space: O(1) Parameter : There is only one mandatory parameter which is the numbe

3 min read Python math function | hypot()

hypot() function is an inbuilt math function in Python that return the Euclidean norm, [Tex]\sqrt <(x*x + y*y)>[/Tex]. Syntax : hypot(x, y) Parameters : x and y are numerical values Returns : Returns a float value having Euclidean norm, sqrt(x*x + y*y). Error : When more than two arguments are passed, it returns a TypeError. Note : One has to impor

2 min read Python | math.fabs() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.fabs() function returns the absolute value of the number. Syntax: math.fabs(x) Parameter: x: This is a numeric expression. Returns: the absolute value of the number. Time Complexity: O(1) Auxiliary Space: O(1) Code #1: C/C++

1 min read Python | math.floor() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.floor() function returns the largest integer not greater than x. If number is already integer, same number is returned. Syntax: math.floor(x) Parameter: x: This is a numeric expression. Returns: largest integer not greater th

1 min read Python math function | copysign()

math.copysign() is a function exists in Standard math Library of Python. This function returns a float value consisting of magnitude from parameter x and the sign (+ve or -ve) from parameter y. Syntax : math.copysign(x, y) Parameters : x : Integer value to be converted y : Integer whose sign is required Returns : float value consisting of magnitude

1 min read Python | math.ceil() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.ceil() function returns the smallest integral value greater than the number. If number is already integer, same number is returned. Syntax: math.ceil(x) Parameter: x: This is a numeric expression. Returns: Smallest integer no

1 min read Python | math.factorial() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.factorial() function returns the factorial of desired number. Syntax: math.factorial(x) Parameter: x: This is a numeric expression. Returns: factorial of desired number. Time Complexity: O(n) where n is the input number. Auxi

2 min read Python | math.copysign() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.copysign(a, b) function return a float with the magnitude (absolute value) of a but the sign of b. Syntax: math.copysign(a, b) Parameter: a, b: numeric values. Returns: Return absolute value of a but the sign of b. Code #1: #

1 min read Python | math.gcd() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.gcd() function compute the greatest common divisor of 2 numbers mentioned in its arguments. Syntax: math.gcd(x, y) Parameter: x : Non-negative integer whose gcd has to be computed. y : Non-negative integer whose gcd has to be

2 min read Python | math.cos() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.cos() function returns the cosine of value passed as argument. The value passed in this function should be in radians. Syntax: math.cos(x) Parameter: x : value to be passed to cos() Returns: Returns the cosine of value passed

2 min read Python | math.tan() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.tan() function returns the tangent of value passed as argument. The value passed in this function should be in radians. Syntax: math.tan(x) Parameter: x : value to be passed to tan() Returns: Returns the tangent of value pass

1 min read Python - math.acos() function

Math module contains a number of functions which is used for mathematical operations. The math.acos() function returns the arc cosine value of a number. The value passed in this function should be in between -1 to 1. Syntax: math.acos(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be passed to acos() Retu

2 min read Python - math.acosh() function

Math module contains a number of functions which is used for mathematical operations. The math.acosh() function returns the hyperbolic arc cosine value of a number. The value passed in this function should be greater than or equal to 1. Syntax: math.acosh(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be

2 min read Python - math.asin() function

Math module contains a number of functions which is used for mathematical operations. The math.asin() function returns the arc sine value of a number. The value passed in this function should be between -1 to 1. Syntax: math.asin(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be passed to asin() Returns:T

2 min read Python - math.asinh() function

Math module contains a number of functions which is used for mathematical operations. The math.asinh() function returns the hyperbolic arc sine value of a number. Syntax: math.asinh(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be passed to asinh() Returns:This function returns the hyperbolic arc sine va

1 min read Python - math.atan() function

Math module contains a number of functions which is used for mathematical operations. The math.atan() function returns the arctangent of a number as a value. The value passed in this function should be between -PI/2 and PI/2 radians. Syntax: math.atan(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be pass

2 min read Python - math.atanh() function

Math module contains a number of functions which is used for mathematical operations. The math.atanh() function returns the hyperbolic arctangent of a number as a value. The value passed in this function should be between -0.99 to 0.99. Syntax: math.atanh(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be

1 min read Python - math.sinh() function

Math module contains a number of functions which is used for mathematical operations. The math.sinh() function returns the hyperbolic sine value of a number. Syntax: math.sinh(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be passed to sinh() Returns:This function returns the hyperbolic sine value of a nu

2 min read Python - math.cosh() function

Math module contains a number of functions which is used for mathematical operations. The math.cosh() function returns the hyperbolic cosine value of a number. Syntax: math.cosh(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be passed to cosh() Returns:This function returns the hyperbolic cosine value of

2 min read Python - math.tanh() function

Math module contains a number of functions which is used for mathematical operations. The math.tanh() function returns the hyperbolic tangent value of a number. Syntax: math.tanh(x) Parameter:This method accepts only single parameters. x :This parameter is the value to be passed to tanh() Returns:This function returns the hyperbolic tangent value o

2 min read Python math function - nextafter()

math.nextafter() is a function introduced in python 3.9.0. nextafter(x,y) returns the next float value after x towards y, if x is equal to y then y is returned. Syntax: math.nextafter(x, y) Parameter: x and y are two integers/floating point values. Returns: Return the next floating-point value after x towards y. If x is equal to y, return y. Exampl

1 min read Python - math.ulp(x) function

ULP stands for “Unit in the Last Place”. math.ulp() is introduced in python 3.9.0 version, it returns the value of the least significant bit of the float x. In numerical analysis and computer science, unit of least precision (ULP) or unit in the last place is the spacing between floating-point numbers. Note: If the argument is a NaN (not a number),

2 min read Python Value Error :Math Domain Error in Python

Errors are the problems in a program due to which the program will stop the execution. One of the errors is 'ValueError: math domain error' in Python. In this article, you will learn why this error occurs and how to fix it with examples. What is 'ValueError: math domain error' in Python?In mathematics, we have certain operations that we consider un

4 min read fabs() method of Python's math Library

fabs() is a method specified in math library in Python 2 and Python 3. Sometimes while computing the difference between 2 numbers to compute the closeness of a number with the other number, we require to find the magnitude of certain number, fabs() can come handy in the cases where we are dealing with ints and want the result in float number to per

3 min read Article Tags :