# usencrypt.cos#

usencrypt.cos(x, n=12, debug=False)#

Computes the cosine of $$x$$ using $$n$$ iterations of the Taylor series approximation method.

Parameters
• x (usencrypt.cipher.Float or float) – The input value.

• n (int) – The number of iterations for the Taylor series approximation method. Defaults to 12.

Returns

The cosine of x.

Return type

usencrypt.cipher.Float

Note

With a degree of 12, the series converges with minimal error on the range $$-\pi < x < \pi$$.

Warning

• The Taylor series does not converge nicely for values greater than $$\pi$$ or less than $$−\pi$$, at least without a very high number of iterations.

• Some slight loss of precision occurs from the initial subtraction, so a slightly higher degree $$n$$ is used for the cosine polynomial to account for it.

Examples
>>> import usencrypt as ue
>>> a = ue.encrypt(0.75)
>>> a_cos = ue.cos(a)
>>> a_cos
(0x7f843af52be0) Float: 0xfca5aeb697d40679b3d7570be7969c212f1210a163ebf18f74516d30eee2483c
>>> ue.decrypt(a_cos)
0.7316888677887619