
(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 (/ (- 0.25 u) 0.75))))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / (1.0f + ((0.25f - u) / 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 + ((0.25e0 - u) / 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(Float32(0.25) - u) / Float32(0.75)))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / (single(1.0) + ((single(0.25) - u) / single(0.75))))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 + \frac{0.25 - u}{0.75}}\right)
\end{array}
Initial program 95.5%
Final simplification95.5%
(FPCore (s u) :precision binary32 (* (* 3.0 s) (log (/ 1.0 (+ (* u -1.3333333333333333) 1.3333333333333333)))))
float code(float s, float u) {
return (3.0f * s) * logf((1.0f / ((u * -1.3333333333333333f) + 1.3333333333333333f)));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * log((1.0e0 / ((u * (-1.3333333333333333e0)) + 1.3333333333333333e0)))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * log(Float32(Float32(1.0) / Float32(Float32(u * Float32(-1.3333333333333333)) + Float32(1.3333333333333333))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * log((single(1.0) / ((u * single(-1.3333333333333333)) + single(1.3333333333333333)))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{u \cdot -1.3333333333333333 + 1.3333333333333333}\right)
\end{array}
Initial program 95.5%
div-subN/A
sub-negN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
div-invN/A
lower-*.f32N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval94.8
Applied rewrites94.8%
lift-*.f32N/A
lift--.f32N/A
sub-negN/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
associate-+r+N/A
lift-fma.f32N/A
+-commutativeN/A
lift-fma.f32N/A
associate-+l+N/A
metadata-evalN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f3295.1
Applied rewrites95.1%
(FPCore (s u) :precision binary32 (* (* 3.0 s) (+ u (+ (log 0.75) (* u (* u 0.5))))))
float code(float s, float u) {
return (3.0f * s) * (u + (logf(0.75f) + (u * (u * 0.5f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * (u + (log(0.75e0) + (u * (u * 0.5e0))))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * Float32(u + Float32(log(Float32(0.75)) + Float32(u * Float32(u * Float32(0.5)))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * (u + (log(single(0.75)) + (u * (u * single(0.5))))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \left(u + \left(\log 0.75 + u \cdot \left(u \cdot 0.5\right)\right)\right)
\end{array}
Initial program 95.5%
Taylor expanded in u around 0
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-log.f3210.9
Applied rewrites10.9%
lift-fma.f32N/A
lift-log.f32N/A
+-commutativeN/A
lift-fma.f32N/A
distribute-rgt-inN/A
*-lft-identityN/A
associate-+r+N/A
lower-+.f32N/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f3232.0
Applied rewrites32.0%
Final simplification32.0%
(FPCore (s u) :precision binary32 (* (* 3.0 s) (+ (* u (* u 0.5)) (+ u (log 0.75)))))
float code(float s, float u) {
return (3.0f * s) * ((u * (u * 0.5f)) + (u + logf(0.75f)));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * ((u * (u * 0.5e0)) + (u + log(0.75e0)))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * Float32(Float32(u * Float32(u * Float32(0.5))) + Float32(u + log(Float32(0.75))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * ((u * (u * single(0.5))) + (u + log(single(0.75)))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \left(u \cdot \left(u \cdot 0.5\right) + \left(u + \log 0.75\right)\right)
\end{array}
Initial program 95.5%
Taylor expanded in u around 0
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-log.f3210.9
Applied rewrites10.9%
lift-fma.f32N/A
lift-log.f32N/A
lift-fma.f32N/A
distribute-rgt-inN/A
*-lft-identityN/A
associate-+l+N/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower-+.f3232.0
Applied rewrites32.0%
(FPCore (s u) :precision binary32 (* (* u -1.3333333333333333) (* s -3.0)))
float code(float s, float u) {
return (u * -1.3333333333333333f) * (s * -3.0f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (u * (-1.3333333333333333e0)) * (s * (-3.0e0))
end function
function code(s, u) return Float32(Float32(u * Float32(-1.3333333333333333)) * Float32(s * Float32(-3.0))) end
function tmp = code(s, u) tmp = (u * single(-1.3333333333333333)) * (s * single(-3.0)); end
\begin{array}{l}
\\
\left(u \cdot -1.3333333333333333\right) \cdot \left(s \cdot -3\right)
\end{array}
Initial program 95.5%
Taylor expanded in s around 0
associate-*r*N/A
log-recN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
sub-negN/A
lower-log1p.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
sub-negN/A
distribute-lft-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f327.8
Applied rewrites7.8%
lower-+.f32N/A
*-commutativeN/A
lower-*.f329.5
Applied rewrites9.5%
Taylor expanded in u around inf
*-commutativeN/A
lower-*.f3229.7
Applied rewrites29.7%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f3229.7
Applied rewrites29.7%
Final simplification29.7%
(FPCore (s u) :precision binary32 (* s (* u 4.0)))
float code(float s, float u) {
return s * (u * 4.0f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * (u * 4.0e0)
end function
function code(s, u) return Float32(s * Float32(u * Float32(4.0))) end
function tmp = code(s, u) tmp = s * (u * single(4.0)); end
\begin{array}{l}
\\
s \cdot \left(u \cdot 4\right)
\end{array}
Initial program 95.5%
Taylor expanded in s around 0
associate-*r*N/A
log-recN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
sub-negN/A
lower-log1p.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
sub-negN/A
distribute-lft-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f327.8
Applied rewrites7.8%
lower-+.f32N/A
*-commutativeN/A
lower-*.f329.5
Applied rewrites9.5%
Taylor expanded in u around inf
*-commutativeN/A
lower-*.f3229.7
Applied rewrites29.7%
Taylor expanded in u around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3229.7
Applied rewrites29.7%
herbie shell --seed 2024216
(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))))))