Essentially the same question as Creating a log function with a custom base : how to compute log_b(a)
, but a method that computes a reasonably accurate answer also when b
is a computed value close to 1
.
The problem with the accepted answer is that the relative error |log(b(1 + delta)) - log(b)| / |log(b)| ≈ delta / log(b)
is large for b ≈ 1
.
There is no answer as the problem is ill-conditioned.
We have relative error
|log_(b(1 + delta))(a) - log_b(a)| / |log_b(a)| = |log(b) / (log(b) + log(1 + delta)) - 1|
.
By Taylor expansion log(1 + delta) ≈ delta
, so the relative error is
|log(b) / (log(b) + delta) - 1| = |delta / (log(b) + delta)|
. For b ≈ 1
, the relative error is approximately 1
as well.