From 5b7ba4e2d8303bf326f62406a94bcf888d5ba01a Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Thu, 11 Jul 2019 01:14:29 +0200 Subject: [PATCH] Added logarithm skeleton --- src/test/kc/logarithm.kc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/kc/logarithm.kc diff --git a/src/test/kc/logarithm.kc b/src/test/kc/logarithm.kc new file mode 100644 index 000000000..f14bf1a1e --- /dev/null +++ b/src/test/kc/logarithm.kc @@ -0,0 +1,24 @@ +// Natural logarithm calculation by approximating polynomial +// https://stackoverflow.com/questions/9799041/efficient-implementation-of-natural-logarithm-ln-and-exponentiation +// 1.7417939 + (2.8212026 + (-1.4699568 + (0.44717955 - 0.056570851 * x) * x) * x) * x +// Works well for numbers in the range 1.0 - 2.0 +// 0.056570851 463.4284114 463 +// 0.44717955 3663.294874 3663 +// -1.4699568 -12041.88611 -12042 +// 2.8212026 23111.2917 23111 +// -1.7417939 -14268.77563 -14269 + +import "multiply" + +void main() { + + +} + + +// Calculate natural logarithm for a number between 1.0 and 2.0 using an approximating polynomial +// Uses a number format where the range of signed int [-32768;32768[ represents [-4;4[ +void ln_sub(signed int x) { + + +} \ No newline at end of file