
(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 7 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 (* (log (/ 1.0 (- 1.0 (/ (- u 0.25) 0.75)))) (* s 3.0)))
float code(float s, float u) {
return logf((1.0f / (1.0f - ((u - 0.25f) / 0.75f)))) * (s * 3.0f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = log((1.0e0 / (1.0e0 - ((u - 0.25e0) / 0.75e0)))) * (s * 3.0e0)
end function
function code(s, u) return Float32(log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75))))) * Float32(s * Float32(3.0))) end
function tmp = code(s, u) tmp = log((single(1.0) / (single(1.0) - ((u - single(0.25)) / single(0.75))))) * (s * single(3.0)); end
\begin{array}{l}
\\
\log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right) \cdot \left(s \cdot 3\right)
\end{array}
Initial program 95.6%
Final simplification95.6%
(FPCore (s u) :precision binary32 (* (log (/ 1.0 (+ 1.0 (* -1.3333333333333333 (- u 0.25))))) (* s 3.0)))
float code(float s, float u) {
return logf((1.0f / (1.0f + (-1.3333333333333333f * (u - 0.25f))))) * (s * 3.0f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = log((1.0e0 / (1.0e0 + ((-1.3333333333333333e0) * (u - 0.25e0))))) * (s * 3.0e0)
end function
function code(s, u) return Float32(log(Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(-1.3333333333333333) * Float32(u - Float32(0.25)))))) * Float32(s * Float32(3.0))) end
function tmp = code(s, u) tmp = log((single(1.0) / (single(1.0) + (single(-1.3333333333333333) * (u - single(0.25)))))) * (s * single(3.0)); end
\begin{array}{l}
\\
\log \left(\frac{1}{1 + -1.3333333333333333 \cdot \left(u - 0.25\right)}\right) \cdot \left(s \cdot 3\right)
\end{array}
Initial program 95.6%
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-eval95.4
Applied rewrites95.4%
Final simplification95.4%
(FPCore (s u) :precision binary32 (* (+ (* (* (+ 1.5 u) u) u) (* (+ (log 0.75) u) 3.0)) s))
float code(float s, float u) {
return ((((1.5f + u) * u) * u) + ((logf(0.75f) + u) * 3.0f)) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((((1.5e0 + u) * u) * u) + ((log(0.75e0) + u) * 3.0e0)) * s
end function
function code(s, u) return Float32(Float32(Float32(Float32(Float32(Float32(1.5) + u) * u) * u) + Float32(Float32(log(Float32(0.75)) + u) * Float32(3.0))) * s) end
function tmp = code(s, u) tmp = ((((single(1.5) + u) * u) * u) + ((log(single(0.75)) + u) * single(3.0))) * s; end
\begin{array}{l}
\\
\left(\left(\left(1.5 + u\right) \cdot u\right) \cdot u + \left(\log 0.75 + u\right) \cdot 3\right) \cdot s
\end{array}
Initial program 95.6%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-log.f327.3
Applied rewrites7.3%
Taylor expanded in u around 0
Applied rewrites14.1%
Applied rewrites36.6%
Final simplification36.6%
(FPCore (s u) :precision binary32 (* -3.0 (* (log1p (+ 0.3333333333333333 (* -1.3333333333333333 u))) s)))
float code(float s, float u) {
return -3.0f * (log1pf((0.3333333333333333f + (-1.3333333333333333f * u))) * s);
}
function code(s, u) return Float32(Float32(-3.0) * Float32(log1p(Float32(Float32(0.3333333333333333) + Float32(Float32(-1.3333333333333333) * u))) * s)) end
\begin{array}{l}
\\
-3 \cdot \left(\mathsf{log1p}\left(0.3333333333333333 + -1.3333333333333333 \cdot u\right) \cdot s\right)
\end{array}
Initial program 95.6%
lift-*.f32N/A
+-lft-identityN/A
metadata-evalN/A
distribute-rgt-inN/A
*-commutativeN/A
lift-*.f32N/A
lower-fma.f32N/A
metadata-eval7.5
lift-*.f32N/A
*-commutativeN/A
lower-*.f327.5
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites34.1%
lift-fma.f32N/A
mul0-lftN/A
+-lft-identity9.3
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f3234.7
lift-*.f32N/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f32N/A
metadata-eval7.4
Applied rewrites7.3%
lift-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-+.f3234.7
*-lft-identityN/A
lift-+.f32N/A
distribute-lft-inN/A
metadata-evalN/A
lower-+.f32N/A
lower-*.f3234.7
lift-*.f32N/A
*-commutativeN/A
lower-*.f3234.7
Applied rewrites34.7%
Final simplification34.7%
(FPCore (s u) :precision binary32 (* (* (* (* u u) 0.5) s) 3.0))
float code(float s, float u) {
return (((u * u) * 0.5f) * s) * 3.0f;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (((u * u) * 0.5e0) * s) * 3.0e0
end function
function code(s, u) return Float32(Float32(Float32(Float32(u * u) * Float32(0.5)) * s) * Float32(3.0)) end
function tmp = code(s, u) tmp = (((u * u) * single(0.5)) * s) * single(3.0); end
\begin{array}{l}
\\
\left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot s\right) \cdot 3
\end{array}
Initial program 95.6%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-log.f3210.8
Applied rewrites10.8%
Taylor expanded in u around inf
Applied rewrites26.5%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f3226.5
Applied rewrites26.5%
(FPCore (s u) :precision binary32 (* (* (* (* u u) 0.5) 3.0) s))
float code(float s, float u) {
return (((u * u) * 0.5f) * 3.0f) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (((u * u) * 0.5e0) * 3.0e0) * s
end function
function code(s, u) return Float32(Float32(Float32(Float32(u * u) * Float32(0.5)) * Float32(3.0)) * s) end
function tmp = code(s, u) tmp = (((u * u) * single(0.5)) * single(3.0)) * s; end
\begin{array}{l}
\\
\left(\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot 3\right) \cdot s
\end{array}
Initial program 95.6%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-log.f3210.8
Applied rewrites10.8%
Taylor expanded in u around inf
Applied rewrites26.5%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3226.5
Applied rewrites26.5%
(FPCore (s u) :precision binary32 (* (* (* u u) 0.5) (* s 3.0)))
float code(float s, float u) {
return ((u * u) * 0.5f) * (s * 3.0f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((u * u) * 0.5e0) * (s * 3.0e0)
end function
function code(s, u) return Float32(Float32(Float32(u * u) * Float32(0.5)) * Float32(s * Float32(3.0))) end
function tmp = code(s, u) tmp = ((u * u) * single(0.5)) * (s * single(3.0)); end
\begin{array}{l}
\\
\left(\left(u \cdot u\right) \cdot 0.5\right) \cdot \left(s \cdot 3\right)
\end{array}
Initial program 95.6%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-log.f3210.8
Applied rewrites10.8%
Taylor expanded in u around inf
Applied rewrites26.5%
Final simplification26.5%
herbie shell --seed 2024244
(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))))))