
(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 5 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 (log (- 1.0 (/ (- u 0.25) 0.75)))) s))
float code(float s, float u) {
return (-3.0f * logf((1.0f - ((u - 0.25f) / 0.75f)))) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((-3.0e0) * log((1.0e0 - ((u - 0.25e0) / 0.75e0)))) * s
end function
function code(s, u) return Float32(Float32(Float32(-3.0) * log(Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75))))) * s) end
function tmp = code(s, u) tmp = (single(-3.0) * log((single(1.0) - ((u - single(0.25)) / single(0.75))))) * s; end
\begin{array}{l}
\\
\left(-3 \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)\right) \cdot s
\end{array}
Initial program 95.8%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites32.5%
lift-log1p.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-fma.f32N/A
lower-log.f3210.3
lift-fma.f32N/A
lift-*.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
div-invN/A
lift--.f32N/A
sub-negN/A
lower--.f32N/A
div-subN/A
sub-negN/A
div-invN/A
lower-fma.f32N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval8.8
Applied rewrites8.8%
lift-fma.f32N/A
metadata-evalN/A
metadata-evalN/A
sub-negN/A
metadata-evalN/A
div-invN/A
div-subN/A
lift--.f32N/A
lower-/.f3296.8
Applied rewrites96.8%
(FPCore (s u) :precision binary32 (* (* -3.0 (log (- 1.0 (* (- u 0.25) 1.3333333333333333)))) s))
float code(float s, float u) {
return (-3.0f * logf((1.0f - ((u - 0.25f) * 1.3333333333333333f)))) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((-3.0e0) * log((1.0e0 - ((u - 0.25e0) * 1.3333333333333333e0)))) * s
end function
function code(s, u) return Float32(Float32(Float32(-3.0) * log(Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) * Float32(1.3333333333333333))))) * s) end
function tmp = code(s, u) tmp = (single(-3.0) * log((single(1.0) - ((u - single(0.25)) * single(1.3333333333333333))))) * s; end
\begin{array}{l}
\\
\left(-3 \cdot \log \left(1 - \left(u - 0.25\right) \cdot 1.3333333333333333\right)\right) \cdot s
\end{array}
Initial program 95.8%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites34.1%
lift-log1p.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-fma.f32N/A
lower-log.f3210.3
lift-fma.f32N/A
lift-*.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
div-invN/A
lift--.f32N/A
sub-negN/A
lower--.f32N/A
div-subN/A
sub-negN/A
div-invN/A
lower-fma.f32N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval8.8
Applied rewrites8.8%
lift-fma.f32N/A
metadata-evalN/A
metadata-evalN/A
sub-negN/A
metadata-evalN/A
div-invN/A
div-subN/A
lift--.f32N/A
div-invN/A
metadata-evalN/A
lower-*.f3296.4
Applied rewrites96.4%
(FPCore (s u) :precision binary32 (* (* -3.0 (log (- 1.3333333333333333 (* 1.3333333333333333 u)))) s))
float code(float s, float u) {
return (-3.0f * logf((1.3333333333333333f - (1.3333333333333333f * u)))) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((-3.0e0) * log((1.3333333333333333e0 - (1.3333333333333333e0 * u)))) * s
end function
function code(s, u) return Float32(Float32(Float32(-3.0) * log(Float32(Float32(1.3333333333333333) - Float32(Float32(1.3333333333333333) * u)))) * s) end
function tmp = code(s, u) tmp = (single(-3.0) * log((single(1.3333333333333333) - (single(1.3333333333333333) * u)))) * s; end
\begin{array}{l}
\\
\left(-3 \cdot \log \left(1.3333333333333333 - 1.3333333333333333 \cdot u\right)\right) \cdot s
\end{array}
Initial program 95.8%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites33.3%
lift-log1p.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-fma.f32N/A
lower-log.f3210.3
lift-fma.f32N/A
lift-*.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
div-invN/A
lift--.f32N/A
sub-negN/A
lower--.f32N/A
div-subN/A
sub-negN/A
div-invN/A
lower-fma.f32N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval8.8
Applied rewrites8.7%
lift--.f32N/A
lift-fma.f32N/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f3296.3
Applied rewrites96.3%
(FPCore (s u) :precision binary32 (* s (+ (* 3.0 u) (* (* (+ 1.5 u) u) u))))
float code(float s, float u) {
return s * ((3.0f * u) + (((1.5f + u) * u) * u));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((3.0e0 * u) + (((1.5e0 + u) * u) * u))
end function
function code(s, u) return Float32(s * Float32(Float32(Float32(3.0) * u) + Float32(Float32(Float32(Float32(1.5) + u) * u) * u))) end
function tmp = code(s, u) tmp = s * ((single(3.0) * u) + (((single(1.5) + u) * u) * u)); end
\begin{array}{l}
\\
s \cdot \left(3 \cdot u + \left(\left(1.5 + u\right) \cdot u\right) \cdot u\right)
\end{array}
Initial program 95.8%
Taylor expanded in u around 0
distribute-rgt-inN/A
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
distribute-lft-outN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
unpow2N/A
associate-*l*N/A
distribute-lft-outN/A
Applied rewrites14.8%
Applied rewrites36.5%
Taylor expanded in u around inf
Applied rewrites30.4%
(FPCore (s u) :precision binary32 (* s (* (* u u) u)))
float code(float s, float u) {
return s * ((u * u) * u);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((u * u) * u)
end function
function code(s, u) return Float32(s * Float32(Float32(u * u) * u)) end
function tmp = code(s, u) tmp = s * ((u * u) * u); end
\begin{array}{l}
\\
s \cdot \left(\left(u \cdot u\right) \cdot u\right)
\end{array}
Initial program 95.8%
Taylor expanded in u around 0
distribute-rgt-inN/A
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
distribute-lft-outN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
unpow2N/A
associate-*l*N/A
distribute-lft-outN/A
Applied rewrites14.8%
Taylor expanded in u around inf
Applied rewrites23.3%
Applied rewrites23.3%
herbie shell --seed 2024325
(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))))))