diff --git a/.husky/pre-commit b/.husky/pre-commit index 1ec3a16..d0a8bed 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,3 +3,4 @@ npx pretty-quick --staged node .husky/scripts/cleanMaths.js +git add . diff --git a/languages/python/calculators/Trigometric Functions.py b/languages/python/calculators/Trigometric Functions.py index 33eb62a..d0f39df 100644 --- a/languages/python/calculators/Trigometric Functions.py +++ b/languages/python/calculators/Trigometric Functions.py @@ -1,10 +1,10 @@ -from cmath import e, sqrt, log +from cmath import e, pi, sqrt, log from _helpers import floatInput i = sqrt(-1) compute = lambda numerator, denominator: (numerator / denominator).real -ln = lambda x: log(x, e) +computeInverse = lambda x: (-i * log(x, e)).real sin = lambda x: compute(pow(e, i * x) - pow(e, -i * x), 2 * i) cos = lambda x: compute(pow(e, i * x) + pow(e, -i * x), 2) @@ -13,14 +13,20 @@ csc = lambda x: 1 / sin(x) sec = lambda x: 1 / cos(x) cot = lambda x: 1 / tan(x) -arcsin = lambda x: (-i * ln((i * x) + sqrt(1 - pow(x, 2)))).real +arcsin = lambda x: computeInverse((i * x) + sqrt(1 - pow(x, 2))) +arccos = lambda x: computeInverse(x + sqrt(pow(x, 2) - 1)) +arctan = lambda x: computeInverse((i - x) / (i + x)) / 2 +arccsc = lambda x: computeInverse((pow(x, -1) * i) + sqrt(1 - pow(x, -2))) +arcsec = lambda x: computeInverse((pow(x, -1)) + sqrt(pow(x, -2) - 1)) +arccot = lambda x: computeInverse((x + i) / (x - i)) / 2 -# todo: finish arc functions -arccos = lambda x: None -arctan = lambda x: None -arccsc = lambda x: (-i * (ln((pow(x, -1) * i) + sqrt(1 - pow(x, -2))))).real -arcsec = lambda x: None -arccot = lambda x: None +# todo: hyperbolic functions + +# todo: hyperbolic inverse functions + +# todo: hyperbolic reciprocal functions + +# todo: hyperbolic inverse reciprocal functions radians = floatInput("Please enter an amount of radians: ") diff --git a/maths/style.cls b/maths/style.cls index 48621a0..0ae58c8 100644 --- a/maths/style.cls +++ b/maths/style.cls @@ -1,2 +1,8 @@ \LoadClass[17pt]{extarticle} \pagenumbering{gobble} + +\newcommand{\euler}{\begin{gather*} + \text{By Euler's formula:} \\ + e^{i\theta} = cos(\theta) + i\sin(\theta) \\ + e^{-i\theta} = cos(\theta) - i\sin(\theta) +\end{gather*}} diff --git a/maths/trigometric functions/cos.png b/maths/trigometric functions/cos.png new file mode 100644 index 0000000..3aabec7 Binary files /dev/null and b/maths/trigometric functions/cos.png differ diff --git a/maths/trigometric functions/cos.tex b/maths/trigometric functions/cos.tex new file mode 100644 index 0000000..a16e6e7 --- /dev/null +++ b/maths/trigometric functions/cos.tex @@ -0,0 +1,27 @@ +\documentclass{../style} +\usepackage{amsmath} +\usepackage{amssymb} +\begin{document} +\euler + +\begin{gather*} + \therefore \cos(\theta) = \frac{e^{i\theta} + e^{-i\theta}}{2} +\end{gather*} + +\begin{gather*} + \text{let} \quad \cos(\theta) = x \\ + 2x = e^{i\theta} + e^{-i\theta} \\ + 2xe^{i\theta} = (e^{i\theta})^2 + 1 \\ + (e^{i\theta})^2 + (-2x)e^{i\theta} + 1 = 0 +\end{gather*} + +\begin{gather*} + e^{i\theta} = \frac{-(-2x) \pm \sqrt{(-2x)^2 - 4}}{2} = x \pm \sqrt{x^2 - 1} \\ + i\theta = \ln(x \pm \sqrt{x^2 - 1}) \\ + \theta = -i\ln(x \pm \sqrt{x^2 - 1}) +\end{gather*} + +\begin{gather*} + \therefore \arccos(\theta) = -i\ln(\theta \pm \sqrt{\theta^2 - 1}) +\end{gather*} +\end{document} diff --git a/maths/trigometric functions/cot-1.png b/maths/trigometric functions/cot-1.png new file mode 100644 index 0000000..9a62e0d Binary files /dev/null and b/maths/trigometric functions/cot-1.png differ diff --git a/maths/trigometric functions/cot-2.png b/maths/trigometric functions/cot-2.png new file mode 100644 index 0000000..2e2d9e0 Binary files /dev/null and b/maths/trigometric functions/cot-2.png differ diff --git a/maths/trigometric functions/cot.tex b/maths/trigometric functions/cot.tex new file mode 100644 index 0000000..6ca9479 --- /dev/null +++ b/maths/trigometric functions/cot.tex @@ -0,0 +1,29 @@ +\documentclass{../style} +\usepackage{amsmath} +\usepackage{amssymb} +\begin{document} +\euler + +\begin{gather*} + \therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} \\ + \cos(\theta) = \frac{e^{i\theta} + e^{-i\theta}}{2} \\ + \tan(\theta) = \frac{\sin(\theta)}{\cos{\theta}} = -\frac{i(-1 + e^{2i\theta})}{1 + e^{2i\theta}} \\ + \cot(\theta) = \frac{1}{\tan(\theta)} = -\frac{1 + e^{2i\theta}}{i(-1 + e^{2i\theta})} +\end{gather*} + +\begin{gather*} + \text{let} \quad \cot(\theta) = x \\ + x(i + ie^{2i\theta}) = -1(1 + e^{2i\theta}) \\ + ix + ixe^{2i\theta} = -e^{2i\theta} - 1 \\ + ixe^{2i\theta} + e^{2i\theta} = -1 - ix \\ + (ix + 1)e^{2i\theta} = -1 - ix \\ + e^{2i\theta} = -\frac{1 - ix}{1 + ix} \\ + 2i\theta = \ln(\frac{x + i}{x - i}) \\ + i\theta = \frac{1}{2}\ln(\frac{x + i}{x - i}) \\ + \theta = -\frac{i}{2}\ln(\frac{x + i}{x - i}) +\end{gather*} + +\begin{gather*} + \therefore \text{arccot}(\theta) = -\frac{i}{2}\ln(\frac{\theta + i}{\theta - i}) +\end{gather*} +\end{document} diff --git a/maths/trigometric functions/csc-1.png b/maths/trigometric functions/csc-1.png index 7065cbe..bfd7616 100644 Binary files a/maths/trigometric functions/csc-1.png and b/maths/trigometric functions/csc-1.png differ diff --git a/maths/trigometric functions/csc.tex b/maths/trigometric functions/csc.tex index 1c43896..4a2c240 100644 --- a/maths/trigometric functions/csc.tex +++ b/maths/trigometric functions/csc.tex @@ -2,11 +2,7 @@ \usepackage{amsmath} \usepackage{amssymb} \begin{document} -\begin{gather*} - \text{By Euler's formula:} \\ - e^{i\theta} = cos(\theta) + i\sin(\theta) \\ - e^{-i\theta} = cos(\theta) - i\sin(\theta) -\end{gather*} +\euler \begin{gather*} \therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} \\ @@ -21,7 +17,7 @@ \end{gather*} \begin{gather*} - e^{i\theta} = \frac{-(\frac{2i}{x}) \pm \sqrt{(\frac{2i}{x})^2 - 4(1)(-1)}}{2} = x^{-1}i \pm \sqrt{1 - x^2} \\ + e^{i\theta} = \frac{-(\frac{2i}{x}) \pm \sqrt{(\frac{2i}{x})^2 - 4(-1)}}{2} = x^{-1}i \pm \sqrt{1 - x^2} \\ i\theta = \ln(x^{-1}i \pm \sqrt{1 - x^2}) \\ \theta = -i\ln(x^{-1}i \pm \sqrt{1 - x^2}) \end{gather*} diff --git a/maths/trigometric functions/sec-1.png b/maths/trigometric functions/sec-1.png new file mode 100644 index 0000000..b5a71f7 Binary files /dev/null and b/maths/trigometric functions/sec-1.png differ diff --git a/maths/trigometric functions/sec-2.png b/maths/trigometric functions/sec-2.png new file mode 100644 index 0000000..0fed58a Binary files /dev/null and b/maths/trigometric functions/sec-2.png differ diff --git a/maths/trigometric functions/sec.tex b/maths/trigometric functions/sec.tex new file mode 100644 index 0000000..4b5d5b2 --- /dev/null +++ b/maths/trigometric functions/sec.tex @@ -0,0 +1,29 @@ +\documentclass{../style} +\usepackage{amsmath} +\usepackage{amssymb} +\begin{document} +\euler + +\begin{gather*} + \therefore \cos(\theta) = \frac{e^{i\theta} + e^{-i\theta}}{2} \\ + \sec(\theta) = \frac{1}{\cos(\theta)} = \frac{2}{e^{i\theta} + e^{-i\theta}} +\end{gather*} + +\begin{gather*} + \text{let} \quad \sec(\theta) = x \\ + x(e^{i\theta} + e^{-i\theta}) = 2 \\ + e^{i\theta} + e^{-i\theta} = \frac{2}{x} \\ + (e^{i\theta})^2 + 1 = \frac{2}{x}e^{i\theta} \\ + (e^{i\theta})^2 + (-\frac{2}{x})e^{i\theta} + 1 = 0 +\end{gather*} + +\begin{gather*} + e^{i\theta} = \frac{-(-\frac{2}{x}) \pm \sqrt{(-\frac{2}{x})^2 - 4}}{2} = x^{-1} \pm \sqrt{x^{-2} - 1} \\ + i\theta = \ln(x^{-1} \pm \sqrt{x^{-2} - 1}) \\ + \theta = -i\ln(x^{-1} \pm \sqrt{x^{-2} - 1}) +\end{gather*} + +\begin{gather*} + \therefore \text{arcsec}(\theta) = -i\ln(\theta^{-1} \pm \sqrt{\theta^{-2} - 1}) +\end{gather*} +\end{document} diff --git a/maths/trigometric functions/sin.png b/maths/trigometric functions/sin.png index 2fe55bd..50f9ede 100644 Binary files a/maths/trigometric functions/sin.png and b/maths/trigometric functions/sin.png differ diff --git a/maths/trigometric functions/sin.tex b/maths/trigometric functions/sin.tex index d361a53..7724d8b 100644 --- a/maths/trigometric functions/sin.tex +++ b/maths/trigometric functions/sin.tex @@ -2,11 +2,7 @@ \usepackage{amsmath} \usepackage{amssymb} \begin{document} -\begin{gather*} - \text{By Euler's formula:} \\ - e^{i\theta} = cos(\theta) + i\sin(\theta) \\ - e^{-i\theta} = cos(\theta) - i\sin(\theta) -\end{gather*} +\euler \begin{gather*} \therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} @@ -15,12 +11,12 @@ \begin{gather*} \text{let} \quad \sin(\theta) = x \\ 2ix = e^{i\theta} - e^{-i\theta} \\ - 2ie^{i\theta}x = (e^{i\theta})^2 - 1 \\ + 2ixe^{i\theta} = (e^{i\theta})^2 - 1 \\ (e^{i\theta})^2 + (-2ix)e^{i\theta} - 1 = 0 \end{gather*} \begin{gather*} - e^{i\theta} = \frac{-(-2ix) \pm \sqrt{(-2ix)^2 - 4(1)(-1)}}{2} = ix \pm \sqrt{1 - x^2} \\ + e^{i\theta} = \frac{-(-2ix) \pm \sqrt{(-2ix)^2 - 4(-1)}}{2} = ix \pm \sqrt{1 - x^2} \\ i\theta = \ln(ix \pm \sqrt{1 - x^2}) \\ \theta = -i\ln(ix \pm \sqrt{1 - x^2}) \end{gather*} diff --git a/maths/trigometric functions/tan-1.png b/maths/trigometric functions/tan-1.png new file mode 100644 index 0000000..de63b2b Binary files /dev/null and b/maths/trigometric functions/tan-1.png differ diff --git a/maths/trigometric functions/tan-2.png b/maths/trigometric functions/tan-2.png new file mode 100644 index 0000000..ba54fb9 Binary files /dev/null and b/maths/trigometric functions/tan-2.png differ diff --git a/maths/trigometric functions/tan.tex b/maths/trigometric functions/tan.tex new file mode 100644 index 0000000..a1324fa --- /dev/null +++ b/maths/trigometric functions/tan.tex @@ -0,0 +1,28 @@ +\documentclass{../style} +\usepackage{amsmath} +\usepackage{amssymb} +\begin{document} +\euler + +\begin{gather*} + \therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} \\ + \cos(\theta) = \frac{e^{i\theta} + e^{-i\theta}}{2} \\ + \tan(\theta) = \frac{\sin(\theta)}{\cos{\theta}} = -\frac{i(-1 + e^{2i\theta})}{1 + e^{2i\theta}} +\end{gather*} + +\begin{gather*} + \text{let} \quad \tan(\theta) = x \\ + x(1 + e^{2i\theta}) = -i(-1 + e^{2i\theta}) \\ + x + xe^{2i\theta} = i - ie^{2i\theta} \\ + xe^{2i\theta} + ie^{2i\theta} = i - x \\ + e^{2i\theta}(i + x) = i - x \\ + e^{2i\theta} = \frac{i - x}{i + x} \\ + 2i\theta = \ln(\frac{i - x}{i + x}) \\ + i\theta = \frac{1}{2}\ln(\frac{i - x}{i + x}) \\ + \theta = -\frac{i}{2}\ln(\frac{i - x}{i + x}) +\end{gather*} + +\begin{gather*} + \therefore \arctan(\theta) = -\frac{i}{2}\ln(\frac{i - \theta}{i + \theta}) +\end{gather*} +\end{document}