
(FPCore (s u) :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))))))
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)
use fmin_fmax_functions
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
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (s u) :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))))))
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)
use fmin_fmax_functions
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
\left(3 \cdot s\right) \cdot \log \left(\frac{1}{1 - \frac{u - 0.25}{0.75}}\right)
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* s (* -3.0 (log1p (fma u -1.3333333333333333 0.3333333333333333)))))
float code(float s, float u) {
return s * (-3.0f * log1pf(fmaf(u, -1.3333333333333333f, 0.3333333333333333f)));
}
function code(s, u) return Float32(s * Float32(Float32(-3.0) * log1p(fma(u, Float32(-1.3333333333333333), Float32(0.3333333333333333))))) end
s \cdot \left(-3 \cdot \mathsf{log1p}\left(\mathsf{fma}\left(u, -1.3333333333333333, 0.3333333333333333\right)\right)\right)
Initial program 95.8%
Applied rewrites96.2%
Applied rewrites95.4%
Applied rewrites95.6%
Applied rewrites97.9%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* -3.0 (* (log (fma u -1.3333333333333333 1.3333333333333333)) s)))
float code(float s, float u) {
return -3.0f * (logf(fmaf(u, -1.3333333333333333f, 1.3333333333333333f)) * s);
}
function code(s, u) return Float32(Float32(-3.0) * Float32(log(fma(u, Float32(-1.3333333333333333), Float32(1.3333333333333333))) * s)) end
-3 \cdot \left(\log \left(\mathsf{fma}\left(u, -1.3333333333333333, 1.3333333333333333\right)\right) \cdot s\right)
Initial program 95.8%
Applied rewrites96.2%
Applied rewrites96.7%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* s (- (* u (+ 3.0 (* u (+ 1.5 u)))) 0.8630462288856506)))
float code(float s, float u) {
return s * ((u * (3.0f + (u * (1.5f + u)))) - 0.8630462288856506f);
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((u * (3.0e0 + (u * (1.5e0 + u)))) - 0.8630462288856506e0)
end function
function code(s, u) return Float32(s * Float32(Float32(u * Float32(Float32(3.0) + Float32(u * Float32(Float32(1.5) + u)))) - Float32(0.8630462288856506))) end
function tmp = code(s, u) tmp = s * ((u * (single(3.0) + (u * (single(1.5) + u)))) - single(0.8630462288856506)); end
s \cdot \left(u \cdot \left(3 + u \cdot \left(1.5 + u\right)\right) - 0.8630462288856506\right)
Initial program 95.8%
Applied rewrites96.2%
Applied rewrites95.5%
Evaluated real constant96.7%
Taylor expanded in u around 0
Applied rewrites36.6%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* s (- (* u (+ 3.0 (* 1.5 u))) 0.8630462288856506)))
float code(float s, float u) {
return s * ((u * (3.0f + (1.5f * u))) - 0.8630462288856506f);
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((u * (3.0e0 + (1.5e0 * u))) - 0.8630462288856506e0)
end function
function code(s, u) return Float32(s * Float32(Float32(u * Float32(Float32(3.0) + Float32(Float32(1.5) * u))) - Float32(0.8630462288856506))) end
function tmp = code(s, u) tmp = s * ((u * (single(3.0) + (single(1.5) * u))) - single(0.8630462288856506)); end
s \cdot \left(u \cdot \left(3 + 1.5 \cdot u\right) - 0.8630462288856506\right)
Initial program 95.8%
Applied rewrites96.2%
Applied rewrites95.5%
Evaluated real constant96.7%
Taylor expanded in u around 0
Applied rewrites32.0%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* s (- (* 3.0 u) 0.8630462288856506)))
float code(float s, float u) {
return s * ((3.0f * u) - 0.8630462288856506f);
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * ((3.0e0 * u) - 0.8630462288856506e0)
end function
function code(s, u) return Float32(s * Float32(Float32(Float32(3.0) * u) - Float32(0.8630462288856506))) end
function tmp = code(s, u) tmp = s * ((single(3.0) * u) - single(0.8630462288856506)); end
s \cdot \left(3 \cdot u - 0.8630462288856506\right)
Initial program 95.8%
Applied rewrites96.2%
Applied rewrites95.5%
Evaluated real constant96.7%
Taylor expanded in u around 0
Applied rewrites25.6%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* 3.0 (* s (+ u -0.28768208622932434))))
float code(float s, float u) {
return 3.0f * (s * (u + -0.28768208622932434f));
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = 3.0e0 * (s * (u + (-0.28768208622932434e0)))
end function
function code(s, u) return Float32(Float32(3.0) * Float32(s * Float32(u + Float32(-0.28768208622932434)))) end
function tmp = code(s, u) tmp = single(3.0) * (s * (u + single(-0.28768208622932434))); end
3 \cdot \left(s \cdot \left(u + -0.28768208622932434\right)\right)
Initial program 95.8%
Taylor expanded in s around 0
Applied rewrites95.6%
Taylor expanded in u around 0
Applied rewrites25.6%
Evaluated real constant25.6%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* 0.0 (* s -0.28768208622932434)))
float code(float s, float u) {
return 0.0f * (s * -0.28768208622932434f);
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = 0.0e0 * (s * (-0.28768208622932434e0))
end function
function code(s, u) return Float32(Float32(0.0) * Float32(s * Float32(-0.28768208622932434))) end
function tmp = code(s, u) tmp = single(0.0) * (s * single(-0.28768208622932434)); end
0 \cdot \left(s \cdot -0.28768208622932434\right)
Initial program 95.8%
Taylor expanded in u around 0
Applied rewrites7.5%
Evaluated real constant7.5%
Taylor expanded in undef-var around zero
Applied rewrites10.6%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* s -0.8630462288856506))
float code(float s, float u) {
return s * -0.8630462288856506f;
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = s * (-0.8630462288856506e0)
end function
function code(s, u) return Float32(s * Float32(-0.8630462288856506)) end
function tmp = code(s, u) tmp = s * single(-0.8630462288856506); end
s \cdot -0.8630462288856506
Initial program 95.8%
Applied rewrites96.2%
Applied rewrites95.5%
Evaluated real constant96.7%
Taylor expanded in u around 0
Applied rewrites7.5%
(FPCore (s u) :precision binary32 :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 0.25 u) (<= u 1.0))) (* -0.863046258687973 s))
float code(float s, float u) {
return -0.863046258687973f * s;
}
real(4) function code(s, u)
use fmin_fmax_functions
real(4), intent (in) :: s
real(4), intent (in) :: u
code = (-0.863046258687973e0) * s
end function
function code(s, u) return Float32(Float32(-0.863046258687973) * s) end
function tmp = code(s, u) tmp = single(-0.863046258687973) * s; end
-0.863046258687973 \cdot s
Initial program 95.8%
Taylor expanded in u around 0
Applied rewrites7.5%
Evaluated real constant7.5%
Applied rewrites7.5%
herbie shell --seed 2026089 +o generate:egglog
(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))))))