
(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 11 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
(let* ((t_0 (/ (- u 0.25) 0.75)))
(*
(* 3.0 s)
(*
-0.5
(log
(/
(* (+ 1.0 (/ (* (- u 0.25) (- u 0.25)) -0.5625)) (- 1.0 t_0))
(+ t_0 1.0)))))))
float code(float s, float u) {
float t_0 = (u - 0.25f) / 0.75f;
return (3.0f * s) * (-0.5f * logf((((1.0f + (((u - 0.25f) * (u - 0.25f)) / -0.5625f)) * (1.0f - t_0)) / (t_0 + 1.0f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
real(4) :: t_0
t_0 = (u - 0.25e0) / 0.75e0
code = (3.0e0 * s) * ((-0.5e0) * log((((1.0e0 + (((u - 0.25e0) * (u - 0.25e0)) / (-0.5625e0))) * (1.0e0 - t_0)) / (t_0 + 1.0e0))))
end function
function code(s, u) t_0 = Float32(Float32(u - Float32(0.25)) / Float32(0.75)) return Float32(Float32(Float32(3.0) * s) * Float32(Float32(-0.5) * log(Float32(Float32(Float32(Float32(1.0) + Float32(Float32(Float32(u - Float32(0.25)) * Float32(u - Float32(0.25))) / Float32(-0.5625))) * Float32(Float32(1.0) - t_0)) / Float32(t_0 + Float32(1.0)))))) end
function tmp = code(s, u) t_0 = (u - single(0.25)) / single(0.75); tmp = (single(3.0) * s) * (single(-0.5) * log((((single(1.0) + (((u - single(0.25)) * (u - single(0.25))) / single(-0.5625))) * (single(1.0) - t_0)) / (t_0 + single(1.0))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{u - 0.25}{0.75}\\
\left(3 \cdot s\right) \cdot \left(-0.5 \cdot \log \left(\frac{\left(1 + \frac{\left(u - 0.25\right) \cdot \left(u - 0.25\right)}{-0.5625}\right) \cdot \left(1 - t\_0\right)}{t\_0 + 1}\right)\right)
\end{array}
\end{array}
Initial program 95.7%
lift-log.f32N/A
lift-/.f32N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
log-powN/A
lower-*.f32N/A
metadata-evalN/A
lower-log.f32N/A
pow2N/A
lower-pow.f3296.4
Applied rewrites96.4%
lift-pow.f32N/A
unpow2N/A
lift--.f32N/A
flip--N/A
metadata-evalN/A
unpow2N/A
lift-pow.f32N/A
lift--.f32N/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites96.6%
lift-pow.f32N/A
unpow2N/A
lift-/.f32N/A
lift-/.f32N/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f32N/A
lower-*.f32N/A
lower-neg.f32N/A
metadata-eval96.9
Applied rewrites96.9%
Final simplification96.9%
(FPCore (s u)
:precision binary32
(*
(* 3.0 s)
(*
-0.5
(log
(/
(*
(+ 1.0 (/ (* (- u 0.25) (- u 0.25)) -0.5625))
(- 1.0 (/ (- u 0.25) 0.75)))
(- (/ u 0.75) -0.6666666666666666))))))
float code(float s, float u) {
return (3.0f * s) * (-0.5f * logf((((1.0f + (((u - 0.25f) * (u - 0.25f)) / -0.5625f)) * (1.0f - ((u - 0.25f) / 0.75f))) / ((u / 0.75f) - -0.6666666666666666f))));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * ((-0.5e0) * log((((1.0e0 + (((u - 0.25e0) * (u - 0.25e0)) / (-0.5625e0))) * (1.0e0 - ((u - 0.25e0) / 0.75e0))) / ((u / 0.75e0) - (-0.6666666666666666e0)))))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * Float32(Float32(-0.5) * log(Float32(Float32(Float32(Float32(1.0) + Float32(Float32(Float32(u - Float32(0.25)) * Float32(u - Float32(0.25))) / Float32(-0.5625))) * Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75)))) / Float32(Float32(u / Float32(0.75)) - Float32(-0.6666666666666666)))))) end
function tmp = code(s, u) tmp = (single(3.0) * s) * (single(-0.5) * log((((single(1.0) + (((u - single(0.25)) * (u - single(0.25))) / single(-0.5625))) * (single(1.0) - ((u - single(0.25)) / single(0.75)))) / ((u / single(0.75)) - single(-0.6666666666666666))))); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \left(-0.5 \cdot \log \left(\frac{\left(1 + \frac{\left(u - 0.25\right) \cdot \left(u - 0.25\right)}{-0.5625}\right) \cdot \left(1 - \frac{u - 0.25}{0.75}\right)}{\frac{u}{0.75} - -0.6666666666666666}\right)\right)
\end{array}
Initial program 95.7%
lift-log.f32N/A
lift-/.f32N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
log-powN/A
lower-*.f32N/A
metadata-evalN/A
lower-log.f32N/A
pow2N/A
lower-pow.f3296.4
Applied rewrites96.4%
lift-pow.f32N/A
unpow2N/A
lift--.f32N/A
flip--N/A
metadata-evalN/A
unpow2N/A
lift-pow.f32N/A
lift--.f32N/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites96.6%
lift-pow.f32N/A
unpow2N/A
lift-/.f32N/A
lift-/.f32N/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f32N/A
lower-*.f32N/A
lower-neg.f32N/A
metadata-eval96.9
Applied rewrites96.9%
lift-+.f32N/A
lift-/.f32N/A
lift--.f32N/A
div-subN/A
lift-/.f32N/A
associate-+l-N/A
metadata-evalN/A
metadata-evalN/A
lift--.f3296.7
Applied rewrites96.7%
Final simplification96.7%
(FPCore (s u) :precision binary32 (* (* (log (- 1.0 (/ (- u 0.25) 0.75))) 3.0) (- s)))
float code(float s, float u) {
return (logf((1.0f - ((u - 0.25f) / 0.75f))) * 3.0f) * -s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (log((1.0e0 - ((u - 0.25e0) / 0.75e0))) * 3.0e0) * -s
end function
function code(s, u) return Float32(Float32(log(Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75)))) * Float32(3.0)) * Float32(-s)) end
function tmp = code(s, u) tmp = (log((single(1.0) - ((u - single(0.25)) / single(0.75)))) * single(3.0)) * -s; end
\begin{array}{l}
\\
\left(\log \left(1 - \frac{u - 0.25}{0.75}\right) \cdot 3\right) \cdot \left(-s\right)
\end{array}
Initial program 95.7%
lift-log.f32N/A
lift-/.f32N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
log-powN/A
lower-*.f32N/A
metadata-evalN/A
lower-log.f32N/A
pow2N/A
lower-pow.f3296.4
Applied rewrites96.4%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites96.5%
Final simplification96.5%
(FPCore (s u) :precision binary32 (* (* (- s) 3.0) (log (- 1.0 (/ (- u 0.25) 0.75)))))
float code(float s, float u) {
return (-s * 3.0f) * logf((1.0f - ((u - 0.25f) / 0.75f)));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (-s * 3.0e0) * log((1.0e0 - ((u - 0.25e0) / 0.75e0)))
end function
function code(s, u) return Float32(Float32(Float32(-s) * Float32(3.0)) * log(Float32(Float32(1.0) - Float32(Float32(u - Float32(0.25)) / Float32(0.75))))) end
function tmp = code(s, u) tmp = (-s * single(3.0)) * log((single(1.0) - ((u - single(0.25)) / single(0.75)))); end
\begin{array}{l}
\\
\left(\left(-s\right) \cdot 3\right) \cdot \log \left(1 - \frac{u - 0.25}{0.75}\right)
\end{array}
Initial program 95.7%
lift-log.f32N/A
lift-/.f32N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
log-powN/A
lower-*.f32N/A
metadata-evalN/A
lower-log.f32N/A
pow2N/A
lower-pow.f3296.4
Applied rewrites96.4%
lift-*.f32N/A
*-commutativeN/A
lower-*.f3296.4
lift-*.f32N/A
lift-log.f32N/A
log-pow-revN/A
lift-pow.f32N/A
pow-powN/A
metadata-evalN/A
inv-powN/A
log-recN/A
lower-neg.f32N/A
lower-log.f3296.4
Applied rewrites96.4%
Final simplification96.4%
(FPCore (s u) :precision binary32 (* (* (- s) (log (- (/ u -0.75) -1.3333333333333333))) 3.0))
float code(float s, float u) {
return (-s * logf(((u / -0.75f) - -1.3333333333333333f))) * 3.0f;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (-s * log(((u / (-0.75e0)) - (-1.3333333333333333e0)))) * 3.0e0
end function
function code(s, u) return Float32(Float32(Float32(-s) * log(Float32(Float32(u / Float32(-0.75)) - Float32(-1.3333333333333333)))) * Float32(3.0)) end
function tmp = code(s, u) tmp = (-s * log(((u / single(-0.75)) - single(-1.3333333333333333)))) * single(3.0); end
\begin{array}{l}
\\
\left(\left(-s\right) \cdot \log \left(\frac{u}{-0.75} - -1.3333333333333333\right)\right) \cdot 3
\end{array}
Initial program 95.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites32.7%
lift-log1p.f32N/A
lower-log.f32N/A
+-commutativeN/A
lift-/.f32N/A
lift--.f32N/A
div-subN/A
associate-+l-N/A
lower--.f32N/A
lower-/.f32N/A
metadata-evalN/A
metadata-eval94.7
Applied rewrites94.7%
(FPCore (s u) :precision binary32 (* (* 3.0 (- s)) (log (- (/ u -0.75) -1.3333333333333333))))
float code(float s, float u) {
return (3.0f * -s) * logf(((u / -0.75f) - -1.3333333333333333f));
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * -s) * log(((u / (-0.75e0)) - (-1.3333333333333333e0)))
end function
function code(s, u) return Float32(Float32(Float32(3.0) * Float32(-s)) * log(Float32(Float32(u / Float32(-0.75)) - Float32(-1.3333333333333333)))) end
function tmp = code(s, u) tmp = (single(3.0) * -s) * log(((u / single(-0.75)) - single(-1.3333333333333333))); end
\begin{array}{l}
\\
\left(3 \cdot \left(-s\right)\right) \cdot \log \left(\frac{u}{-0.75} - -1.3333333333333333\right)
\end{array}
Initial program 95.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites31.8%
lift-log1p.f32N/A
lower-log.f32N/A
+-commutativeN/A
lift-/.f32N/A
lift--.f32N/A
div-subN/A
associate-+l-N/A
lower--.f32N/A
lower-/.f32N/A
metadata-evalN/A
metadata-eval94.7
Applied rewrites94.7%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3294.7
Applied rewrites94.7%
(FPCore (s u) :precision binary32 (* s (* (log (- (/ u -0.75) -1.3333333333333333)) (- 3.0))))
float code(float s, float u) {
return s * (logf(((u / -0.75f) - -1.3333333333333333f)) * -3.0f);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * (log(((u / (-0.75e0)) - (-1.3333333333333333e0))) * -3.0e0)
end function
function code(s, u) return Float32(s * Float32(log(Float32(Float32(u / Float32(-0.75)) - Float32(-1.3333333333333333))) * Float32(-Float32(3.0)))) end
function tmp = code(s, u) tmp = s * (log(((u / single(-0.75)) - single(-1.3333333333333333))) * -single(3.0)); end
\begin{array}{l}
\\
s \cdot \left(\log \left(\frac{u}{-0.75} - -1.3333333333333333\right) \cdot \left(-3\right)\right)
\end{array}
Initial program 95.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites32.4%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
*-commutativeN/A
lift-log1p.f32N/A
log-pow-revN/A
lower-log.f32N/A
lower-pow.f32N/A
+-commutativeN/A
lift-/.f32N/A
lift--.f32N/A
div-subN/A
associate-+l-N/A
lower--.f32N/A
lower-/.f32N/A
metadata-evalN/A
metadata-eval94.4
Applied rewrites94.4%
lift-log.f32N/A
lift-pow.f32N/A
pow-to-expN/A
rem-log-expN/A
lower-*.f32N/A
lower-log.f3294.6
Applied rewrites94.6%
Final simplification94.6%
(FPCore (s u) :precision binary32 (* (* 3.0 s) (+ (log 0.75) u)))
float code(float s, float u) {
return (3.0f * s) * (logf(0.75f) + u);
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (3.0e0 * s) * (log(0.75e0) + u)
end function
function code(s, u) return Float32(Float32(Float32(3.0) * s) * Float32(log(Float32(0.75)) + u)) end
function tmp = code(s, u) tmp = (single(3.0) * s) * (log(single(0.75)) + u); end
\begin{array}{l}
\\
\left(3 \cdot s\right) \cdot \left(\log 0.75 + u\right)
\end{array}
Initial program 95.7%
Taylor expanded in u around 0
+-commutativeN/A
lower-+.f32N/A
lower-log.f3225.2
Applied rewrites25.2%
(FPCore (s u) :precision binary32 (* (* (+ (log 0.75) u) s) 3.0))
float code(float s, float u) {
return ((logf(0.75f) + u) * s) * 3.0f;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = ((log(0.75e0) + u) * s) * 3.0e0
end function
function code(s, u) return Float32(Float32(Float32(log(Float32(0.75)) + u) * s) * Float32(3.0)) end
function tmp = code(s, u) tmp = ((log(single(0.75)) + u) * s) * single(3.0); end
\begin{array}{l}
\\
\left(\left(\log 0.75 + u\right) \cdot s\right) \cdot 3
\end{array}
Initial program 95.7%
Taylor expanded in u around 0
distribute-lft-outN/A
*-commutativeN/A
lower-*.f32N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-log.f3225.2
Applied rewrites25.2%
(FPCore (s u) :precision binary32 (* s (fma 3.0 u (log 0.421875))))
float code(float s, float u) {
return s * fmaf(3.0f, u, logf(0.421875f));
}
function code(s, u) return Float32(s * fma(Float32(3.0), u, log(Float32(0.421875)))) end
\begin{array}{l}
\\
s \cdot \mathsf{fma}\left(3, u, \log 0.421875\right)
\end{array}
Initial program 95.7%
lift-log.f32N/A
lift-/.f32N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
log-powN/A
lower-*.f32N/A
metadata-evalN/A
lower-log.f32N/A
pow2N/A
lower-pow.f3296.4
Applied rewrites96.4%
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f32N/A
lift-*.f32N/A
lift-log.f32N/A
log-pow-revN/A
log-pow-revN/A
lower-log.f32N/A
lift-pow.f32N/A
pow-powN/A
metadata-evalN/A
pow-powN/A
lower-pow.f32N/A
metadata-eval96.3
Applied rewrites96.3%
Taylor expanded in u around 0
+-commutativeN/A
lower-fma.f32N/A
lower-log.f323.4
Applied rewrites3.4%
(FPCore (s u) :precision binary32 (* (log 0.421875) s))
float code(float s, float u) {
return logf(0.421875f) * s;
}
real(4) function code(s, u)
real(4), intent (in) :: s
real(4), intent (in) :: u
code = log(0.421875e0) * s
end function
function code(s, u) return Float32(log(Float32(0.421875)) * s) end
function tmp = code(s, u) tmp = log(single(0.421875)) * s; end
\begin{array}{l}
\\
\log 0.421875 \cdot s
\end{array}
Initial program 95.7%
Taylor expanded in u around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-log.f327.4
Applied rewrites7.4%
Applied rewrites7.4%
herbie shell --seed 2024337
(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))))))