I was recently watching a video on Karatsuba's fast multiplication algorithm and the narrator stated something that intrigued me:
$2^{1.6} \approx 3 $
Specifically, I wondered what power $2$ would need to be raised to in order to be equal to $3$:
$2^p = 3$
Since my knowledge in the field of mathematics is rather lacking, I attempted to brute force the answer in the C# programming language:
double p = 1.5;
for (; Math.Pow(2, p) != 3;)
p += 0.00000000000000000000000000000000000000000000000000000000000001;
Console.WriteLine(p);
Note: This snippet is intended for creating a CodeGolf.SE challenge, so please disregard the abuse of the for iterator here. It's abused for the sake of brevity.
However, as the incremental value increases in precision, the time it takes to reach an answer, also increases (likely by orders of magnitude), so this is a very inefficient way to determine the value needed for $p$.
What is the most effective way to determine the exponent needed in order for the following to be a true statement when $x$ and $z$ are known:
$$x^y = z$$
In general for positive reals $a$ and $b$ the value $x$ such that $b^x=a$ is known as $\log_b(a)$ and is called "the logarithm base $b$ of $a$" . In our case we have $b=2,a=3$.
The rule for converting logarithms with a special base to something with normal natural logarithm is $\log_b(a) = \log(a)/\log(b)$.
This is because we need $b^x=a$, and we have $b^x=(e^{\log(b)})^x = e^{\log(b)x}$ so we need $\log(b)x = \log(a)$.
In conclusion $\log_2(3) = \log(3)/\log(2) \approx 1.58496250072$