From 26b04bba715f31549c42f2ca52f3d4e9211611ac Mon Sep 17 00:00:00 2001 From: newtykins Date: Mon, 27 Dec 2021 01:54:37 +0000 Subject: [PATCH] trig! --- python/calculators/Trigometric Functions.py | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 python/calculators/Trigometric Functions.py diff --git a/python/calculators/Trigometric Functions.py b/python/calculators/Trigometric Functions.py new file mode 100644 index 0000000..b6edaad --- /dev/null +++ b/python/calculators/Trigometric Functions.py @@ -0,0 +1,22 @@ +from math import e +from _helpers import floatInput + +def sin(radians): + x = radians + return (((e ** (1j * x)) - (e ** -(1j * x))) / 2j).real + +def cos(radians): + x = radians + return (((e ** (1j * x)) + (e ** -(1j * x))) / 2).real + +def tan(radians): + x = radians + return (((e ** (1j * x)) - (e ** -(1j * x))) / (1j * ((e ** (1j * x)) + (e ** -(1j * x))))).real + +a = floatInput("Please enter an amount of radians: ") + +print("""Where x = %i: +sin(x) = %f +cos(x) = %f +tan(x) = %f +""" % (a, sin(a), cos(a), tan(a)))