Computers

Octave Trigonometric Functions

Octave Trigonometric Functions

In this tutorial, we will learn about Octave Trigonometric Functions. All the trigonometric functions are available in Octave.

Trigonometric Functions

Octave supports basic trigonometric functions like sin, cos, tan, etc.

The trigonometric functions are as follows:

 

Trigonometric Function
Description
sin(x)

 

To compute the sine of an angle, x in radians.
cos(x) To compute the cosine of an angle, x in radians.
tan(x) To compute the tangent of an angle, x in radians.
sec(x) To compute the secant of an angle, x in radians.
csc(x) To compute the cosecant of an angle, x in radians.
cot(x) To compute the cotangent of an angle, x in radians.

Examples

It is important to note that the argument for the function should be in radians.

Compute sin of 30 degrees.

>> % To calculate sin of 30 degrees
>> sin(30)
ans = -0.9880
>> % The above answer is wrong
>> sin(30*pi/180)
ans = 0.5000
>>
>>

 

Octave Trigonometric Functions

Compute the value of  \large sin(\frac{\pi }{2})

>> sin(pi/2)
ans = 1

Compute the value of  \large cos(\frac{\pi }{4})

>> cos(pi/4)
ans = 0.70711

Compute the value of \large tan( \frac{\pi }{4})

>> tan(pi/4)
ans = 1.00000

 

Note that Octave is a case-sensitive language. The function names sin(x) and Sin(x) are different. In fact, if we haven’t defined any function with the name Sin, we would get the following function undefined error:

>> Sin(x)
error: ‘Sin’ undefined near line 1, column 1

 

Octave Function Case Sensitive

Inverse Trigonometric Functions

https://www.testingdocs.com/inverse-trigonometric-functions-in-octave/

 

Octave Tutorials

Octave Tutorial on this website can be found at: