
(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 (* s (* (log1p (/ (- 0.25 u) 0.75)) -3.0)))
float code(float s, float u) {
return s * (log1pf(((0.25f - u) / 0.75f)) * -3.0f);
}
function code(s, u) return Float32(s * Float32(log1p(Float32(Float32(Float32(0.25) - u) / Float32(0.75))) * Float32(-3.0))) end
\begin{array}{l}
\\
s \cdot \left(\mathsf{log1p}\left(\frac{0.25 - u}{0.75}\right) \cdot -3\right)
\end{array}
Initial program 95.7%
associate-*l*96.0%
*-commutative96.0%
associate-*l*96.0%
log-rec96.8%
distribute-lft-neg-out96.8%
distribute-rgt-neg-in96.8%
sub-neg96.8%
log1p-def98.5%
distribute-neg-frac98.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
metadata-eval98.5%
unsub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (s u) :precision binary32 (* -3.0 (* s (log (+ 1.3333333333333333 (* u -1.3333333333333333))))))
float code(float s, float u) {
return -3.0f * (s * logf((1.3333333333333333f + (u * -1.3333333333333333f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (-3.0e0) * (s * log((1.3333333333333333e0 + (u * (-1.3333333333333333e0)))))
end function
function code(s, u) return Float32(Float32(-3.0) * Float32(s * log(Float32(Float32(1.3333333333333333) + Float32(u * Float32(-1.3333333333333333)))))) end
function tmp = code(s, u) tmp = single(-3.0) * (s * log((single(1.3333333333333333) + (u * single(-1.3333333333333333))))); end
\begin{array}{l}
\\
-3 \cdot \left(s \cdot \log \left(1.3333333333333333 + u \cdot -1.3333333333333333\right)\right)
\end{array}
Initial program 95.7%
associate-*l*96.0%
*-commutative96.0%
associate-*l*96.0%
log-rec96.8%
distribute-lft-neg-out96.8%
distribute-rgt-neg-in96.8%
sub-neg96.8%
log1p-def98.5%
distribute-neg-frac98.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
metadata-eval98.5%
unsub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in s around 0 96.7%
log1p-def98.2%
Simplified98.2%
Taylor expanded in u around 0 97.1%
Taylor expanded in s around 0 96.4%
Final simplification96.4%
(FPCore (s u) :precision binary32 (* -3.0 (* s (log1p (* (- 0.25 u) 1.3333333333333333)))))
float code(float s, float u) {
return -3.0f * (s * log1pf(((0.25f - u) * 1.3333333333333333f)));
}
function code(s, u) return Float32(Float32(-3.0) * Float32(s * log1p(Float32(Float32(Float32(0.25) - u) * Float32(1.3333333333333333))))) end
\begin{array}{l}
\\
-3 \cdot \left(s \cdot \mathsf{log1p}\left(\left(0.25 - u\right) \cdot 1.3333333333333333\right)\right)
\end{array}
Initial program 95.7%
associate-*l*96.0%
*-commutative96.0%
associate-*l*96.0%
log-rec96.8%
distribute-lft-neg-out96.8%
distribute-rgt-neg-in96.8%
sub-neg96.8%
log1p-def98.5%
distribute-neg-frac98.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
metadata-eval98.5%
unsub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in s around 0 96.7%
log1p-def98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (s u) :precision binary32 (* -3.0 (* s (log1p (* u -1.3333333333333333)))))
float code(float s, float u) {
return -3.0f * (s * log1pf((u * -1.3333333333333333f)));
}
function code(s, u) return Float32(Float32(-3.0) * Float32(s * log1p(Float32(u * Float32(-1.3333333333333333))))) end
\begin{array}{l}
\\
-3 \cdot \left(s \cdot \mathsf{log1p}\left(u \cdot -1.3333333333333333\right)\right)
\end{array}
Initial program 95.7%
associate-*l*96.0%
*-commutative96.0%
associate-*l*96.0%
log-rec96.8%
distribute-lft-neg-out96.8%
distribute-rgt-neg-in96.8%
sub-neg96.8%
log1p-def98.5%
distribute-neg-frac98.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
metadata-eval98.5%
unsub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in s around 0 96.7%
log1p-def98.2%
Simplified98.2%
Taylor expanded in u around inf 19.2%
*-commutative19.2%
Simplified19.2%
Final simplification19.2%
(FPCore (s u) :precision binary32 (* 3.0 (* s (+ u (log 0.75)))))
float code(float s, float u) {
return 3.0f * (s * (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 + log(0.75e0)))
end function
function code(s, u) return Float32(Float32(3.0) * Float32(s * Float32(u + log(Float32(0.75))))) end
function tmp = code(s, u) tmp = single(3.0) * (s * (u + log(single(0.75)))); end
\begin{array}{l}
\\
3 \cdot \left(s \cdot \left(u + \log 0.75\right)\right)
\end{array}
Initial program 95.7%
Taylor expanded in u around 0 25.9%
distribute-lft-out25.9%
distribute-lft-out25.9%
+-commutative25.9%
Simplified25.9%
Final simplification25.9%
(FPCore (s u) :precision binary32 (* (* s 3.0) (+ u (log 0.75))))
float code(float s, float u) {
return (s * 3.0f) * (u + logf(0.75f));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (s * 3.0e0) * (u + log(0.75e0))
end function
function code(s, u) return Float32(Float32(s * Float32(3.0)) * Float32(u + log(Float32(0.75)))) end
function tmp = code(s, u) tmp = (s * single(3.0)) * (u + log(single(0.75))); end
\begin{array}{l}
\\
\left(s \cdot 3\right) \cdot \left(u + \log 0.75\right)
\end{array}
Initial program 95.7%
Taylor expanded in u around 0 25.9%
Final simplification25.9%
(FPCore (s u) :precision binary32 (* s (log 0.421875)))
float code(float s, float u) {
return s * logf(0.421875f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * log(0.421875e0)
end function
function code(s, u) return Float32(s * log(Float32(0.421875))) end
function tmp = code(s, u) tmp = s * log(single(0.421875)); end
\begin{array}{l}
\\
s \cdot \log 0.421875
\end{array}
Initial program 95.7%
Taylor expanded in u around 0 7.1%
expm1-log1p-u6.9%
expm1-udef9.2%
*-commutative9.2%
Applied egg-rr9.2%
expm1-def6.9%
expm1-log1p7.1%
associate-*l*7.1%
Simplified7.1%
Taylor expanded in s around 0 7.1%
*-commutative7.1%
associate-*l*7.1%
*-commutative7.1%
rem-log-exp7.1%
*-commutative7.1%
exp-to-pow7.1%
metadata-eval7.1%
Simplified7.1%
Final simplification7.1%
herbie shell --seed 2023188
(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))))))