From 3e3dbdbef5d730df33eaa993d47f64367a5d751e Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 8 Feb 2025 18:22:28 -0800 Subject: [PATCH] edits --- .../Fast Inverse Root/parts/7 quake.tex | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Advanced/Fast Inverse Root/parts/7 quake.tex b/src/Advanced/Fast Inverse Root/parts/7 quake.tex index 2cdbbae..bb82045 100644 --- a/src/Advanced/Fast Inverse Root/parts/7 quake.tex +++ b/src/Advanced/Fast Inverse Root/parts/7 quake.tex @@ -14,23 +14,25 @@ float Q_rsqrt( float number ) { } \end{lstlisting} -This code defines -a function \texttt{Q\_rsqrt} that consumes a float named +This code defines a function \texttt{Q\_rsqrt} that consumes a float named \texttt{number} and approximates its inverse square root (in other words, \texttt{Q\_rsqrt} computes $1/\sqrt{\texttt{number}}$). \vspace{2mm} -If we rewrite this using the notation we're familiar with, we get the following: +If we rewrite this using notation we're familiar with, we get the following: \begin{equation*} - \texttt{Q\_sqrt}(n_i) = 6240089 - (n_i \div 2) \approx \frac{1}{\sqrt{n_f}} + \texttt{Q\_sqrt}(n_f) = 6240089 - (n_i \div 2) \approx \frac{1}{\sqrt{n_f}} \end{equation*} -$6240089$ is the decimal value of hex \texttt{0x5f3759df}. \par -It is a magic number hard-coded into the function. + +\note{ + \texttt{0x5f3759df} is $6240089$ in hexadecimal. \par + It is a magic number hard-coded into \texttt{Q\_sqrt}. +} \vspace{2mm} -Our goal in this section is to understand why this works. \par -How are we able to approximate $\frac{1}{\sqrt{x}}$ by only subtracting and dividing by two?? +Our goal in this section is to understand why this works: \par +How does Quake approximate $\frac{1}{\sqrt{x}}$ by simply subtracting and dividing by two?? \problem{} Using basic log rules, rewrite $\log_2(1 / \sqrt{x})$ in terms of $\log_2(x)$.