From 9715eaaf60a69188112629143bb09310484250b3 Mon Sep 17 00:00:00 2001 From: Johannes Date: Fri, 15 Jul 2016 17:29:37 +0200 Subject: [PATCH] Add atan function --- math.scss | 18 ++++++++++++++---- test.html | 3 ++- test.scss | 8 +++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/math.scss b/math.scss index 5dd2a43..9092e80 100644 --- a/math.scss +++ b/math.scss @@ -62,16 +62,26 @@ $ret: 0; $n: 1; $dx: .001; - + @while $n <= $x { $ret: $ret + $dx / $n; - + $n: $n + $dx; } - + @return $ret; } -@function sqrt($x) { +@function sqrt($x) { @return exp(0.5 * ln($x)); } + +@function atan ($x) { + $ret: 0; + + @for $n from 0 to 25 { + $ret: $ret + power(-1, $n) * power($x, 2 * $n + 1) / (2 * $n + 1); + } + + @return $ret; +} diff --git a/test.html b/test.html index ed586aa..59465bf 100644 --- a/test.html +++ b/test.html @@ -11,6 +11,7 @@
e^x function

ln function
Sqrt function
+
Atan function
- \ No newline at end of file + diff --git a/test.scss b/test.scss index 0619b4b..3582ac8 100644 --- a/test.scss +++ b/test.scss @@ -41,6 +41,12 @@ #test-ln { @if ln(exp(1)) != 1.001 { background-color:red; }; } + #test-sqrt { @if sqrt(4) != 2 { background-color:red; }; -} \ No newline at end of file +} + +#test-atan { + @if atan(0) != 0 { background-color: red; } + //@if atan(1) != 0.79539 { background-color: red; } +}