
(FPCore (s u) :precision binary32 (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / (1.0f - ((u - 0.25f) / 0.75f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * log((1.0e0 / (1.0e0 - ((u - 0.25e0) / 0.75e0))))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75)))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / (single(1.0) - ((u - single(0.25)) / single(0.75))))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (s u) :precision binary32 (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / (1.0f - ((u - 0.25f) / 0.75f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * log((1.0e0 / (1.0e0 - ((u - 0.25e0) / 0.75e0))))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75)))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / (single(1.0) - ((u - single(0.25)) / single(0.75))))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
\end{array}
(FPCore (s u) :precision binary32 (* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / (1.0f - ((u - 0.25f) / 0.75f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * log((1.0e0 / (1.0e0 - ((u - 0.25e0) / 0.75e0))))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75)))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / (single(1.0) - ((u - single(0.25)) / single(0.75))))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
\end{array}
Initial program 96.3%
(FPCore (s u) :precision binary32 (* (* 3.0 s) (log (/ 1.0 (+ (* -1.3333333333333333 (- u 0.25)) 1.0)))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / ((-1.3333333333333333f * (u - 0.25f)) + 1.0f)));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * log((1.0e0 / (((-1.3333333333333333e0) * (u - 0.25e0)) + 1.0e0)))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(Float32(-1.3333333333333333) * Float32(u - Float32(0.25))) + Float32(1.0))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / ((single(-1.3333333333333333) * (u - single(0.25))) + single(1.0)))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{-1.3333333333333333 \cdot \left(u - 0.25\right) + 1}\right)
\end{array}
Initial program 96.3%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lower-+.f32N/A
lift-/.f32N/A
distribute-neg-frac2N/A
div-invN/A
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
metadata-eval96.1
Applied rewrites96.1%
(FPCore (s u) :precision binary32 (* (* 3.0 s) (log (/ 1.0 (- 1.3333333333333333 (* 1.3333333333333333 u))))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / (1.3333333333333333f - (1.3333333333333333f * u))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * log((1.0e0 / (1.3333333333333333e0 - (1.3333333333333333e0 * u))))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(1.3333333333333333) - Float32(Float32(1.3333333333333333) * u))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / (single(1.3333333333333333) - (single(1.3333333333333333) * u)))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1.3333333333333333 - 1.3333333333333333 \cdot u}\right)
\end{array}
Initial program 96.3%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lower-+.f32N/A
lift-/.f32N/A
distribute-neg-frac2N/A
div-invN/A
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
metadata-eval96.1
Applied rewrites96.1%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
div-invN/A
lift--.f32N/A
sub-negN/A
div-subN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
sub-negN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
lower--.f32N/A
lower-*.f3295.7
Applied rewrites95.7%
(FPCore (s u) :precision binary32 (* (* -3.0 (log 0.6666666666666666)) s))
float code(float s, float u) {
return (-3.0f * logf(0.6666666666666666f)) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((-3.0e0) * log(0.6666666666666666e0)) * s
end function
function code(s, u) return Float32(Float32(Float32(-3.0) * log(Float32(0.6666666666666666))) * s) end
function tmp = code(s, u) tmp = (single(-3.0) * log(single(0.6666666666666666))) * s; end
\begin{array}{l}
\\
\left(-3 \cdot \log 0.6666666666666666\right) \cdot s
\end{array}
Initial program 96.3%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lower-+.f32N/A
lift-/.f32N/A
distribute-neg-frac2N/A
div-invN/A
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
metadata-eval96.1
Applied rewrites96.1%
Applied rewrites10.7%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-log.f3228.5
Applied rewrites28.5%
Applied rewrites28.5%
(FPCore (s u) :precision binary32 (* (* -3.0 s) (log 0.6666666666666666)))
float code(float s, float u) {
return (-3.0f * s) * logf(0.6666666666666666f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((-3.0e0) * s) * log(0.6666666666666666e0)
end function
function code(s, u) return Float32(Float32(Float32(-3.0) * s) * log(Float32(0.6666666666666666))) end
function tmp = code(s, u) tmp = (single(-3.0) * s) * log(single(0.6666666666666666)); end
\begin{array}{l}
\\
\left(-3 \cdot s\right) \cdot \log 0.6666666666666666
\end{array}
Initial program 96.3%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lower-+.f32N/A
lift-/.f32N/A
distribute-neg-frac2N/A
div-invN/A
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
metadata-eval96.1
Applied rewrites96.1%
Applied rewrites10.7%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-log.f3228.5
Applied rewrites28.5%
Applied rewrites28.5%
(FPCore (s u) :precision binary32 (* (* (log 0.75) s) 3.0))
float code(float s, float u) {
return (logf(0.75f) * s) * 3.0f;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (log(0.75e0) * s) * 3.0e0
end function
function code(s, u) return Float32(Float32(log(Float32(0.75)) * s) * Float32(3.0)) end
function tmp = code(s, u) tmp = (log(single(0.75)) * s) * single(3.0); end
\begin{array}{l}
\\
\left(\log 0.75 \cdot s\right) \cdot 3
\end{array}
Initial program 96.3%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-log.f327.5
Applied rewrites7.5%
herbie shell --seed 2024322
(FPCore (s u)
:name "Disney BSSRDF, sample scattering profile, upper"
:precision binary32
:pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0)))
(* (* 3.0 s) (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75))))))