fastlog2
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
// @description Returns the approximation of Log2 with the maximal error of: 0.000061011436
// Reference:
//		https://www.anycodings.com/1questions/2553538/efficient-implementation-of-natural-logarithm-ln-and-exponentiation
library("fastlog2")

// @function Returns the approximation of Log2 with the maximal error of: 0.000061011436
// @param x float
// @returns float, log2 of x
export fastlog2(float x)=>
    float fastlog2 = -1.7417939 + (2.8212026 + (-1.4699568 + (0.44717955 - 0.056570851 * x) * x) * x) * x
    fastlog2

//example usage
out = fastlog2(close/close[1])
plot(out)