feat: finish arcus functions

This commit is contained in:
newt 2024-10-09 18:02:46 +01:00
parent 1b26e034f7
commit ad631f177d
18 changed files with 140 additions and 22 deletions

View file

@ -3,3 +3,4 @@
npx pretty-quick --staged npx pretty-quick --staged
node .husky/scripts/cleanMaths.js node .husky/scripts/cleanMaths.js
git add .

View file

@ -1,10 +1,10 @@
from cmath import e, sqrt, log from cmath import e, pi, sqrt, log
from _helpers import floatInput from _helpers import floatInput
i = sqrt(-1) i = sqrt(-1)
compute = lambda numerator, denominator: (numerator / denominator).real 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) 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) 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) sec = lambda x: 1 / cos(x)
cot = lambda x: 1 / tan(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 # todo: hyperbolic functions
arccos = lambda x: None
arctan = lambda x: None # todo: hyperbolic inverse functions
arccsc = lambda x: (-i * (ln((pow(x, -1) * i) + sqrt(1 - pow(x, -2))))).real
arcsec = lambda x: None # todo: hyperbolic reciprocal functions
arccot = lambda x: None
# todo: hyperbolic inverse reciprocal functions
radians = floatInput("Please enter an amount of radians: ") radians = floatInput("Please enter an amount of radians: ")

View file

@ -1,2 +1,8 @@
\LoadClass[17pt]{extarticle} \LoadClass[17pt]{extarticle}
\pagenumbering{gobble} \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*}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View file

@ -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}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -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}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -2,11 +2,7 @@
\usepackage{amsmath} \usepackage{amsmath}
\usepackage{amssymb} \usepackage{amssymb}
\begin{document} \begin{document}
\begin{gather*} \euler
\text{By Euler's formula:} \\
e^{i\theta} = cos(\theta) + i\sin(\theta) \\
e^{-i\theta} = cos(\theta) - i\sin(\theta)
\end{gather*}
\begin{gather*} \begin{gather*}
\therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} \\ \therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} \\
@ -21,7 +17,7 @@
\end{gather*} \end{gather*}
\begin{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}) \\ i\theta = \ln(x^{-1}i \pm \sqrt{1 - x^2}) \\
\theta = -i\ln(x^{-1}i \pm \sqrt{1 - x^2}) \theta = -i\ln(x^{-1}i \pm \sqrt{1 - x^2})
\end{gather*} \end{gather*}

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

@ -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}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -2,11 +2,7 @@
\usepackage{amsmath} \usepackage{amsmath}
\usepackage{amssymb} \usepackage{amssymb}
\begin{document} \begin{document}
\begin{gather*} \euler
\text{By Euler's formula:} \\
e^{i\theta} = cos(\theta) + i\sin(\theta) \\
e^{-i\theta} = cos(\theta) - i\sin(\theta)
\end{gather*}
\begin{gather*} \begin{gather*}
\therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i} \therefore \sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i}
@ -15,12 +11,12 @@
\begin{gather*} \begin{gather*}
\text{let} \quad \sin(\theta) = x \\ \text{let} \quad \sin(\theta) = x \\
2ix = e^{i\theta} - e^{-i\theta} \\ 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 (e^{i\theta})^2 + (-2ix)e^{i\theta} - 1 = 0
\end{gather*} \end{gather*}
\begin{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}) \\ i\theta = \ln(ix \pm \sqrt{1 - x^2}) \\
\theta = -i\ln(ix \pm \sqrt{1 - x^2}) \theta = -i\ln(ix \pm \sqrt{1 - x^2})
\end{gather*} \end{gather*}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -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}