
(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 8 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) (- (log1p (fma 1.3333333333333333 u -0.3333333333333333)) (log1p (* (pow (+ u -0.25) 2.0) -1.7777777777777777)))))
float code(float s, float u) {
return (3.0f * s) * (log1pf(fmaf(1.3333333333333333f, u, -0.3333333333333333f)) - log1pf((powf((u + -0.25f), 2.0f) * -1.7777777777777777f)));
}
function code(s, u) return Float32(Float32(Float32(3.0) * s) * Float32(log1p(fma(Float32(1.3333333333333333), u, Float32(-0.3333333333333333))) - log1p(Float32((Float32(u + Float32(-0.25)) ^ Float32(2.0)) * Float32(-1.7777777777777777))))) end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \left(\mathsf{log1p}\left(\mathsf{fma}\left(1.3333333333333333, u, -0.3333333333333333\right)\right) - \mathsf{log1p}\left({\left(u + -0.25\right)}^{2} \cdot -1.7777777777777777\right)\right)
\end{array}
Initial program 96.0%
log-rec96.9%
sub-neg96.9%
log1p-def98.2%
distribute-neg-frac98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
log1p-udef96.9%
metadata-eval96.9%
sub-neg96.9%
distribute-frac-neg96.9%
sub-neg96.9%
flip--96.2%
log-div96.1%
Applied egg-rr97.2%
sub-neg97.2%
log1p-def97.8%
distribute-rgt-neg-in97.8%
metadata-eval97.8%
*-commutative97.8%
fma-def98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (s u) :precision binary32 (* (log1p (/ (- (- u) -0.25) 0.75)) (* 3.0 (- s))))
float code(float s, float u) {
return log1pf(((-u - -0.25f) / 0.75f)) * (3.0f * -s);
}
function code(s, u) return Float32(log1p(Float32(Float32(Float32(-u) - Float32(-0.25)) / Float32(0.75))) * Float32(Float32(3.0) * Float32(-s))) end
\begin{array}{l}
\\
\mathsf{log1p}\left(\frac{\left(-u\right) - -0.25}{0.75}\right) \cdot \left(3 \cdot \left(-s\right)\right)
\end{array}
Initial program 96.0%
log-rec96.9%
sub-neg96.9%
log1p-def98.2%
distribute-neg-frac98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Final simplification98.2%
(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 96.0%
associate-*l*95.9%
log-rec96.7%
sub-neg96.7%
metadata-eval96.7%
Simplified96.7%
Taylor expanded in s around 0 96.6%
Taylor expanded in u around 0 96.2%
Final simplification96.2%
(FPCore (s u) :precision binary32 (* -3.0 (* s (log1p (* 1.3333333333333333 (- 0.25 u))))))
float code(float s, float u) {
return -3.0f * (s * log1pf((1.3333333333333333f * (0.25f - u))));
}
function code(s, u) return Float32(Float32(-3.0) * Float32(s * log1p(Float32(Float32(1.3333333333333333) * Float32(Float32(0.25) - u))))) end
\begin{array}{l}
\\
-3 \cdot \left(s \cdot \mathsf{log1p}\left(1.3333333333333333 \cdot \left(0.25 - u\right)\right)\right)
\end{array}
Initial program 96.0%
log-rec96.9%
sub-neg96.9%
log1p-def98.2%
distribute-neg-frac98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in s around 0 96.6%
associate-*r*96.6%
log1p-def97.8%
Simplified97.8%
Taylor expanded in s around 0 96.6%
log1p-def97.7%
Simplified97.7%
Final simplification97.7%
(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 96.0%
associate-*l*95.9%
*-commutative95.9%
associate-*l*96.0%
log-rec96.9%
distribute-lft-neg-out96.9%
distribute-rgt-neg-in96.9%
sub-neg96.9%
log1p-def98.1%
distribute-neg-frac98.1%
sub-neg98.1%
+-commutative98.1%
distribute-neg-in98.1%
metadata-eval98.1%
metadata-eval98.1%
unsub-neg98.1%
metadata-eval98.1%
Simplified98.1%
Final simplification98.1%
(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 96.0%
Taylor expanded in u around 0 26.6%
distribute-lft-out26.6%
distribute-lft-out26.6%
+-commutative26.6%
Simplified26.6%
Final simplification26.6%
(FPCore (s u) :precision binary32 (* s (+ (* 3.0 u) (log 0.421875))))
float code(float s, float u) {
return s * ((3.0f * u) + logf(0.421875f));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((3.0e0 * u) + log(0.421875e0))
end function
function code(s, u) return Float32(s * Float32(Float32(Float32(3.0) * u) + log(Float32(0.421875)))) end
function tmp = code(s, u) tmp = s * ((single(3.0) * u) + log(single(0.421875))); end
\begin{array}{l}
\\
s \cdot \left(3 \cdot u + \log 0.421875\right)
\end{array}
Initial program 96.0%
associate-*l*95.9%
*-commutative95.9%
associate-*l*96.0%
log-rec96.9%
distribute-lft-neg-out96.9%
distribute-rgt-neg-in96.9%
div-sub95.9%
associate--r-95.8%
sub-neg95.8%
+-commutative95.8%
associate-+l+94.7%
distribute-neg-frac94.7%
neg-mul-194.7%
associate-/l*94.5%
associate-/r/96.3%
metadata-eval96.3%
metadata-eval96.3%
metadata-eval96.3%
metadata-eval96.3%
Simplified96.3%
add-log-exp96.1%
exp-to-pow96.2%
*-commutative96.2%
fma-def96.9%
Applied egg-rr96.9%
Taylor expanded in u around 0 26.6%
Final simplification26.6%
(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 96.0%
Taylor expanded in u around 0 11.6%
pow111.6%
Applied egg-rr11.6%
unpow111.6%
associate-*r*11.6%
*-commutative11.6%
associate-*l*11.6%
Simplified11.6%
Taylor expanded in s around 0 11.6%
associate-*r*11.6%
*-commutative11.6%
associate-*r*11.6%
rem-log-exp11.6%
*-commutative11.6%
exp-to-pow11.6%
metadata-eval11.6%
Simplified11.6%
Final simplification11.6%
herbie shell --seed 2023278
(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))))))