I was working on a project, got distracted, and somehow ended up making a
tutorial on how to implement logBASE in pure nim. (The link is
[here](https://logarithm-implementation-in-nim.pages.dev/release/))
The end result is this:
from std/math import pow, almostEqual, E
proc ln(n: float64): float64 =
var next: float64 = 1.0
while not almostEqual(result, next, 1):
result = next
next = result - ((pow(E, result) - n) / pow(E, result))
echo ln(5)
proc log(n, base: float64): float64 =
var next: float64 = 1.0
while not almostEqual(result, next, 1):
result = next
let top = pow(base, result) - n
let bottom = pow(base, result) * ln(base)
next = result - (top / bottom)
echo log(5, 10)
Run
I was creating this while trying to create logarithm functions using other
kinds of decimals/fractions other than floats, and realized that `std/math`
just uses c bindings.
I hope this helps someone in some way :)