Engee documentation

cos

Page in progress.

The cosine of the argument is in radians.

Library

EngeeDSP

Syntax

Function call

  • Y = cos(X) — returns the cosine value for each element from X. Function cos works with arrays piecemeal. The function accepts both real and complex inputs.

    • For real values from X, function cos returns real values in the interval [-1, 1].

    • For complex values from X, function cos returns complex values.

Arguments

Input arguments

# X is the value of the input angle in rad

+ scalar | vector | matrix | N-dimensional array

Details

The value of the input angle in rad, specified as a scalar, vector, matrix, or multidimensional array.

Data types

Float32, Float64, Char, String

Support for complex numbers

Yes

Output arguments

# Y is the cosine value of the input angle

+ scalar | vector | matrix | N-dimensional array

Details

The cosine value of the input angle returned as a real or complex scalar, vector, matrix, or multidimensional array.

Data types

Float32, Float64, Char, String

Support for complex numbers

Yes

Examples

Graph of the cosine function

Details

Let’s plot the cosine function for .

import EngeeDSP.Functions: cos
using Plots

x = -pi:0.01:pi
plot(x, cos.(x), grid = true)
xlabel!("x")
ylabel!("cos(x)")

cos 2

Cosine of the vector of complex angles

Details

Calculate the cosine of the complex angles of the vector .

import EngeeDSP.Functions: cos

x = [-im, pi + im*pi/2, -1 + im*4]
y = cos.(x)
3-element Vector{ComplexF64}:
  1.5430806348152437 + 0.0im
 -2.5091784786580567 - 2.818278334591946e-16im
  14.754701170483758 + 22.96367349919304im

Additional information

Cosine function

Details

Cosine of the angle a right triangle is equal to:

Where

  • — adjacent cathet;

  • — the hypotenuse of a right triangle.

sin en

The cosine of a complex quantity equal to: