usencrypt.sin#

usencrypt.sin(x, n=14, debug=False)#

Computes the sine of \(x\) using the cosine series approximation method.

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

  • n (int) – The number of iterations for the cosine series approximation. Defaults to 14.

Returns

The sine of x.

Return type

usencrypt.cipher.Float

Note

As \(\sin(x)\) is equivalent to \(\cos(\frac{x − \pi}{2})\), this function simply uses the cosine series with an altered parameter.

Warning

  • Our current implementation of \(\sin\) is dependent on the cosine series, and as such faces the same issues.

  • 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.

See also

Examples
>>> import usencrypt as ue
>>> a = ue.encrypt(0.75)
>>> a_sin = ue.sin(a)
>>> a_sin
(0x7f843a4af430) Float: 0xa776d35b095a0f4fde5fa26aacb1ee4a9621a792ee575a0a4ff56ae0a94003be
>>> ue.decrypt(a_sin)
0.6816387616563588