
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(exp
(+
(+
(-
(- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v))
(/ 1.0 v))
0.6931)
(log (/ 1.0 (* 2.0 v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0f / v)) + 0.6931f) + logf((1.0f / (2.0f * v)))));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = exp(((((((costheta_i * costheta_o) / v) - ((sintheta_i * sintheta_o) / v)) - (1.0e0 / v)) + 0.6931e0) + log((1.0e0 / (2.0e0 * v)))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(Float32(Float32(Float32(Float32(Float32(cosTheta_i * cosTheta_O) / v) - Float32(Float32(sinTheta_i * sinTheta_O) / v)) - Float32(Float32(1.0) / v)) + Float32(0.6931)) + log(Float32(Float32(1.0) / Float32(Float32(2.0) * v))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (single(1.0) / v)) + single(0.6931)) + log((single(1.0) / (single(2.0) * v))))); end
\begin{array}{l}
\\
e^{\left(\left(\left(\frac{cosTheta\_i \cdot cosTheta\_O}{v} - \frac{sinTheta\_i \cdot sinTheta\_O}{v}\right) - \frac{1}{v}\right) + 0.6931\right) + \log \left(\frac{1}{2 \cdot v}\right)}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(exp
(+
(+
(-
(- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v))
(/ 1.0 v))
0.6931)
(log (/ 1.0 (* 2.0 v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0f / v)) + 0.6931f) + logf((1.0f / (2.0f * v)))));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = exp(((((((costheta_i * costheta_o) / v) - ((sintheta_i * sintheta_o) / v)) - (1.0e0 / v)) + 0.6931e0) + log((1.0e0 / (2.0e0 * v)))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(Float32(Float32(Float32(Float32(Float32(cosTheta_i * cosTheta_O) / v) - Float32(Float32(sinTheta_i * sinTheta_O) / v)) - Float32(Float32(1.0) / v)) + Float32(0.6931)) + log(Float32(Float32(1.0) / Float32(Float32(2.0) * v))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (single(1.0) / v)) + single(0.6931)) + log((single(1.0) / (single(2.0) * v))))); end
\begin{array}{l}
\\
e^{\left(\left(\left(\frac{cosTheta\_i \cdot cosTheta\_O}{v} - \frac{sinTheta\_i \cdot sinTheta\_O}{v}\right) - \frac{1}{v}\right) + 0.6931\right) + \log \left(\frac{1}{2 \cdot v}\right)}
\end{array}
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(/
(exp
(fma
(fma (* cosTheta_i cosTheta_O) v (- v))
(/ 1.0 (* v v))
(- 0.6931 (log v))))
(exp (log 2.0))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf(fmaf(fmaf((cosTheta_i * cosTheta_O), v, -v), (1.0f / (v * v)), (0.6931f - logf(v)))) / expf(logf(2.0f));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(exp(fma(fma(Float32(cosTheta_i * cosTheta_O), v, Float32(-v)), Float32(Float32(1.0) / Float32(v * v)), Float32(Float32(0.6931) - log(v)))) / exp(log(Float32(2.0)))) end
\begin{array}{l}
\\
\frac{e^{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta\_i \cdot cosTheta\_O, v, -v\right), \frac{1}{v \cdot v}, 0.6931 - \log v\right)}}{e^{\log 2}}
\end{array}
Initial program 99.7%
lift-+.f32N/A
lift-+.f32N/A
associate-+l+N/A
lift--.f32N/A
lift--.f32N/A
lift-/.f32N/A
lift-/.f32N/A
sub-divN/A
lift-/.f32N/A
frac-subN/A
div-invN/A
metadata-evalN/A
frac-timesN/A
lift-/.f32N/A
lift-/.f32N/A
Applied rewrites99.7%
Taylor expanded in cosTheta_i around inf
lower-*.f3299.7
Applied rewrites99.7%
lift-exp.f32N/A
lift-fma.f32N/A
lift--.f32N/A
associate-+r-N/A
lift-log.f32N/A
lift-*.f32N/A
log-prodN/A
associate--r+N/A
exp-diffN/A
Applied rewrites99.7%
lift--.f32N/A
lift-+.f32N/A
+-commutativeN/A
associate--l+N/A
lift-/.f32N/A
div-invN/A
lift-/.f32N/A
lower-fma.f32N/A
lower--.f3299.8
Applied rewrites99.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* 0.5 (exp (+ (fma cosTheta_O (/ cosTheta_i v) 0.6931) (- (/ -1.0 v) (log v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 0.5f * expf((fmaf(cosTheta_O, (cosTheta_i / v), 0.6931f) + ((-1.0f / v) - logf(v))));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(0.5) * exp(Float32(fma(cosTheta_O, Float32(cosTheta_i / v), Float32(0.6931)) + Float32(Float32(Float32(-1.0) / v) - log(v))))) end
\begin{array}{l}
\\
0.5 \cdot e^{\mathsf{fma}\left(cosTheta\_O, \frac{cosTheta\_i}{v}, 0.6931\right) + \left(\frac{-1}{v} - \log v\right)}
\end{array}
Initial program 99.7%
lift-+.f32N/A
lift-+.f32N/A
associate-+l+N/A
lift--.f32N/A
lift--.f32N/A
lift-/.f32N/A
lift-/.f32N/A
sub-divN/A
lift-/.f32N/A
frac-subN/A
div-invN/A
metadata-evalN/A
frac-timesN/A
lift-/.f32N/A
lift-/.f32N/A
Applied rewrites99.7%
Taylor expanded in cosTheta_i around inf
lower-*.f3299.7
Applied rewrites99.7%
lift-exp.f32N/A
lift-fma.f32N/A
lift--.f32N/A
associate-+r-N/A
lift-log.f32N/A
lift-*.f32N/A
log-prodN/A
associate--r+N/A
exp-diffN/A
Applied rewrites99.7%
Taylor expanded in sinTheta_i around 0
lower-*.f32N/A
lower-exp.f32N/A
lower--.f32N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower-log.f32N/A
lower-/.f3299.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(let* ((t_0 (/ (* cosTheta_i cosTheta_O) v)))
(if (<= (* cosTheta_i cosTheta_O) -4.000000072010038e-35)
(exp t_0)
(if (<= (* cosTheta_i cosTheta_O) 3.0000000565330046e-31)
(exp (- (/ (* sinTheta_i sinTheta_O) v)))
(exp (- t_0))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float t_0 = (cosTheta_i * cosTheta_O) / v;
float tmp;
if ((cosTheta_i * cosTheta_O) <= -4.000000072010038e-35f) {
tmp = expf(t_0);
} else if ((cosTheta_i * cosTheta_O) <= 3.0000000565330046e-31f) {
tmp = expf(-((sinTheta_i * sinTheta_O) / v));
} else {
tmp = expf(-t_0);
}
return tmp;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
real(4) :: t_0
real(4) :: tmp
t_0 = (costheta_i * costheta_o) / v
if ((costheta_i * costheta_o) <= (-4.000000072010038e-35)) then
tmp = exp(t_0)
else if ((costheta_i * costheta_o) <= 3.0000000565330046e-31) then
tmp = exp(-((sintheta_i * sintheta_o) / v))
else
tmp = exp(-t_0)
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = Float32(Float32(cosTheta_i * cosTheta_O) / v) tmp = Float32(0.0) if (Float32(cosTheta_i * cosTheta_O) <= Float32(-4.000000072010038e-35)) tmp = exp(t_0); elseif (Float32(cosTheta_i * cosTheta_O) <= Float32(3.0000000565330046e-31)) tmp = exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))); else tmp = exp(Float32(-t_0)); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = (cosTheta_i * cosTheta_O) / v; tmp = single(0.0); if ((cosTheta_i * cosTheta_O) <= single(-4.000000072010038e-35)) tmp = exp(t_0); elseif ((cosTheta_i * cosTheta_O) <= single(3.0000000565330046e-31)) tmp = exp(-((sinTheta_i * sinTheta_O) / v)); else tmp = exp(-t_0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{cosTheta\_i \cdot cosTheta\_O}{v}\\
\mathbf{if}\;cosTheta\_i \cdot cosTheta\_O \leq -4.000000072010038 \cdot 10^{-35}:\\
\;\;\;\;e^{t\_0}\\
\mathbf{elif}\;cosTheta\_i \cdot cosTheta\_O \leq 3.0000000565330046 \cdot 10^{-31}:\\
\;\;\;\;e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}\\
\mathbf{else}:\\
\;\;\;\;e^{-t\_0}\\
\end{array}
\end{array}
if (*.f32 cosTheta_i cosTheta_O) < -4.00000007e-35Initial program 99.9%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3244.1
Applied rewrites44.1%
Applied rewrites44.1%
if -4.00000007e-35 < (*.f32 cosTheta_i cosTheta_O) < 3.00000006e-31Initial program 99.7%
Taylor expanded in sinTheta_i around inf
mul-1-negN/A
lower-neg.f32N/A
lower-/.f32N/A
lower-*.f3218.3
Applied rewrites18.3%
if 3.00000006e-31 < (*.f32 cosTheta_i cosTheta_O) Initial program 99.7%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f324.5
Applied rewrites4.5%
Applied rewrites60.0%
Final simplification32.1%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= (* sinTheta_i sinTheta_O) -2.0000000063421537e-30)
(exp (* sinTheta_i (/ sinTheta_O v)))
(if (<= (* sinTheta_i sinTheta_O) 4.999999898305949e-32)
(exp (/ (* cosTheta_i cosTheta_O) v))
(exp (* (- sinTheta_i) (/ sinTheta_O v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((sinTheta_i * sinTheta_O) <= -2.0000000063421537e-30f) {
tmp = expf((sinTheta_i * (sinTheta_O / v)));
} else if ((sinTheta_i * sinTheta_O) <= 4.999999898305949e-32f) {
tmp = expf(((cosTheta_i * cosTheta_O) / v));
} else {
tmp = expf((-sinTheta_i * (sinTheta_O / v)));
}
return tmp;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
real(4) :: tmp
if ((sintheta_i * sintheta_o) <= (-2.0000000063421537e-30)) then
tmp = exp((sintheta_i * (sintheta_o / v)))
else if ((sintheta_i * sintheta_o) <= 4.999999898305949e-32) then
tmp = exp(((costheta_i * costheta_o) / v))
else
tmp = exp((-sintheta_i * (sintheta_o / v)))
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = Float32(0.0) if (Float32(sinTheta_i * sinTheta_O) <= Float32(-2.0000000063421537e-30)) tmp = exp(Float32(sinTheta_i * Float32(sinTheta_O / v))); elseif (Float32(sinTheta_i * sinTheta_O) <= Float32(4.999999898305949e-32)) tmp = exp(Float32(Float32(cosTheta_i * cosTheta_O) / v)); else tmp = exp(Float32(Float32(-sinTheta_i) * Float32(sinTheta_O / v))); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((sinTheta_i * sinTheta_O) <= single(-2.0000000063421537e-30)) tmp = exp((sinTheta_i * (sinTheta_O / v))); elseif ((sinTheta_i * sinTheta_O) <= single(4.999999898305949e-32)) tmp = exp(((cosTheta_i * cosTheta_O) / v)); else tmp = exp((-sinTheta_i * (sinTheta_O / v))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \cdot sinTheta\_O \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;e^{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\\
\mathbf{elif}\;sinTheta\_i \cdot sinTheta\_O \leq 4.999999898305949 \cdot 10^{-32}:\\
\;\;\;\;e^{\frac{cosTheta\_i \cdot cosTheta\_O}{v}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-sinTheta\_i\right) \cdot \frac{sinTheta\_O}{v}}\\
\end{array}
\end{array}
if (*.f32 sinTheta_i sinTheta_O) < -2e-30Initial program 100.0%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3218.5
Applied rewrites18.5%
Taylor expanded in sinTheta_i around inf
associate-*r/N/A
lower-/.f32N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f32N/A
mul-1-negN/A
lower-neg.f324.3
Applied rewrites4.3%
Applied rewrites65.6%
if -2e-30 < (*.f32 sinTheta_i sinTheta_O) < 4.9999999e-32Initial program 99.6%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3214.2
Applied rewrites14.2%
Applied rewrites14.2%
if 4.9999999e-32 < (*.f32 sinTheta_i sinTheta_O) Initial program 99.8%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3214.0
Applied rewrites14.0%
Taylor expanded in sinTheta_i around inf
associate-*r/N/A
lower-/.f32N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f32N/A
mul-1-negN/A
lower-neg.f3257.4
Applied rewrites57.4%
Applied rewrites57.4%
Final simplification28.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= (* sinTheta_i sinTheta_O) -2.0000000063421537e-30)
(exp (* sinTheta_i (/ sinTheta_O v)))
(if (<= (* sinTheta_i sinTheta_O) 4.999999898305949e-32)
(exp (/ (* cosTheta_i cosTheta_O) v))
(exp (- (/ (* sinTheta_i sinTheta_O) v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((sinTheta_i * sinTheta_O) <= -2.0000000063421537e-30f) {
tmp = expf((sinTheta_i * (sinTheta_O / v)));
} else if ((sinTheta_i * sinTheta_O) <= 4.999999898305949e-32f) {
tmp = expf(((cosTheta_i * cosTheta_O) / v));
} else {
tmp = expf(-((sinTheta_i * sinTheta_O) / v));
}
return tmp;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
real(4) :: tmp
if ((sintheta_i * sintheta_o) <= (-2.0000000063421537e-30)) then
tmp = exp((sintheta_i * (sintheta_o / v)))
else if ((sintheta_i * sintheta_o) <= 4.999999898305949e-32) then
tmp = exp(((costheta_i * costheta_o) / v))
else
tmp = exp(-((sintheta_i * sintheta_o) / v))
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = Float32(0.0) if (Float32(sinTheta_i * sinTheta_O) <= Float32(-2.0000000063421537e-30)) tmp = exp(Float32(sinTheta_i * Float32(sinTheta_O / v))); elseif (Float32(sinTheta_i * sinTheta_O) <= Float32(4.999999898305949e-32)) tmp = exp(Float32(Float32(cosTheta_i * cosTheta_O) / v)); else tmp = exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((sinTheta_i * sinTheta_O) <= single(-2.0000000063421537e-30)) tmp = exp((sinTheta_i * (sinTheta_O / v))); elseif ((sinTheta_i * sinTheta_O) <= single(4.999999898305949e-32)) tmp = exp(((cosTheta_i * cosTheta_O) / v)); else tmp = exp(-((sinTheta_i * sinTheta_O) / v)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \cdot sinTheta\_O \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;e^{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\\
\mathbf{elif}\;sinTheta\_i \cdot sinTheta\_O \leq 4.999999898305949 \cdot 10^{-32}:\\
\;\;\;\;e^{\frac{cosTheta\_i \cdot cosTheta\_O}{v}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}\\
\end{array}
\end{array}
if (*.f32 sinTheta_i sinTheta_O) < -2e-30Initial program 100.0%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3218.5
Applied rewrites18.5%
Taylor expanded in sinTheta_i around inf
associate-*r/N/A
lower-/.f32N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f32N/A
mul-1-negN/A
lower-neg.f324.3
Applied rewrites4.3%
Applied rewrites65.6%
if -2e-30 < (*.f32 sinTheta_i sinTheta_O) < 4.9999999e-32Initial program 99.6%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3214.2
Applied rewrites14.2%
Applied rewrites14.2%
if 4.9999999e-32 < (*.f32 sinTheta_i sinTheta_O) Initial program 99.8%
Taylor expanded in sinTheta_i around inf
mul-1-negN/A
lower-neg.f32N/A
lower-/.f32N/A
lower-*.f3257.4
Applied rewrites57.4%
Final simplification28.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ 0.5 v) (exp (+ 0.6931 (/ -1.0 v)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (0.5f / v) * expf((0.6931f + (-1.0f / v)));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (0.5e0 / v) * exp((0.6931e0 + ((-1.0e0) / v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(0.5) / v) * exp(Float32(Float32(0.6931) + Float32(Float32(-1.0) / v)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (single(0.5) / v) * exp((single(0.6931) + (single(-1.0) / v))); end
\begin{array}{l}
\\
\frac{0.5}{v} \cdot e^{0.6931 + \frac{-1}{v}}
\end{array}
Initial program 99.7%
Taylor expanded in cosTheta_i around 0
+-commutativeN/A
associate--l+N/A
exp-sumN/A
lower-*.f32N/A
rem-exp-logN/A
lower-/.f32N/A
lower-exp.f32N/A
sub-negN/A
lower-+.f32N/A
distribute-neg-inN/A
mul-1-negN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
distribute-neg-fracN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f32N/A
Applied rewrites99.7%
Taylor expanded in sinTheta_O around 0
Applied rewrites99.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (if (<= (* sinTheta_i sinTheta_O) -2.0000000063421537e-30) (exp (* sinTheta_i (/ sinTheta_O v))) (exp (/ (* cosTheta_i cosTheta_O) v))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((sinTheta_i * sinTheta_O) <= -2.0000000063421537e-30f) {
tmp = expf((sinTheta_i * (sinTheta_O / v)));
} else {
tmp = expf(((cosTheta_i * cosTheta_O) / v));
}
return tmp;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
real(4) :: tmp
if ((sintheta_i * sintheta_o) <= (-2.0000000063421537e-30)) then
tmp = exp((sintheta_i * (sintheta_o / v)))
else
tmp = exp(((costheta_i * costheta_o) / v))
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = Float32(0.0) if (Float32(sinTheta_i * sinTheta_O) <= Float32(-2.0000000063421537e-30)) tmp = exp(Float32(sinTheta_i * Float32(sinTheta_O / v))); else tmp = exp(Float32(Float32(cosTheta_i * cosTheta_O) / v)); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((sinTheta_i * sinTheta_O) <= single(-2.0000000063421537e-30)) tmp = exp((sinTheta_i * (sinTheta_O / v))); else tmp = exp(((cosTheta_i * cosTheta_O) / v)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \cdot sinTheta\_O \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;e^{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{cosTheta\_i \cdot cosTheta\_O}{v}}\\
\end{array}
\end{array}
if (*.f32 sinTheta_i sinTheta_O) < -2e-30Initial program 100.0%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3218.5
Applied rewrites18.5%
Taylor expanded in sinTheta_i around inf
associate-*r/N/A
lower-/.f32N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f32N/A
mul-1-negN/A
lower-neg.f324.3
Applied rewrites4.3%
Applied rewrites65.6%
if -2e-30 < (*.f32 sinTheta_i sinTheta_O) Initial program 99.7%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3214.1
Applied rewrites14.1%
Applied rewrites14.1%
Final simplification20.2%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (if (<= (* sinTheta_i sinTheta_O) -2.0000000063421537e-30) (exp (* sinTheta_i (/ sinTheta_O v))) (exp (* cosTheta_O (/ cosTheta_i v)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((sinTheta_i * sinTheta_O) <= -2.0000000063421537e-30f) {
tmp = expf((sinTheta_i * (sinTheta_O / v)));
} else {
tmp = expf((cosTheta_O * (cosTheta_i / v)));
}
return tmp;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
real(4) :: tmp
if ((sintheta_i * sintheta_o) <= (-2.0000000063421537e-30)) then
tmp = exp((sintheta_i * (sintheta_o / v)))
else
tmp = exp((costheta_o * (costheta_i / v)))
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = Float32(0.0) if (Float32(sinTheta_i * sinTheta_O) <= Float32(-2.0000000063421537e-30)) tmp = exp(Float32(sinTheta_i * Float32(sinTheta_O / v))); else tmp = exp(Float32(cosTheta_O * Float32(cosTheta_i / v))); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((sinTheta_i * sinTheta_O) <= single(-2.0000000063421537e-30)) tmp = exp((sinTheta_i * (sinTheta_O / v))); else tmp = exp((cosTheta_O * (cosTheta_i / v))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \cdot sinTheta\_O \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;e^{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\\
\mathbf{else}:\\
\;\;\;\;e^{cosTheta\_O \cdot \frac{cosTheta\_i}{v}}\\
\end{array}
\end{array}
if (*.f32 sinTheta_i sinTheta_O) < -2e-30Initial program 100.0%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3218.5
Applied rewrites18.5%
Taylor expanded in sinTheta_i around inf
associate-*r/N/A
lower-/.f32N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f32N/A
mul-1-negN/A
lower-neg.f324.3
Applied rewrites4.3%
Applied rewrites65.6%
if -2e-30 < (*.f32 sinTheta_i sinTheta_O) Initial program 99.7%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3214.1
Applied rewrites14.1%
Taylor expanded in cosTheta_i around inf
associate-/l*N/A
lower-*.f32N/A
lower-/.f3214.1
Applied rewrites14.1%
Final simplification20.2%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (exp (/ (fma cosTheta_O cosTheta_i (fma sinTheta_O (- sinTheta_i) -1.0)) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf((fmaf(cosTheta_O, cosTheta_i, fmaf(sinTheta_O, -sinTheta_i, -1.0f)) / v));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(fma(cosTheta_O, cosTheta_i, fma(sinTheta_O, Float32(-sinTheta_i), Float32(-1.0))) / v)) end
\begin{array}{l}
\\
e^{\frac{\mathsf{fma}\left(cosTheta\_O, cosTheta\_i, \mathsf{fma}\left(sinTheta\_O, -sinTheta\_i, -1\right)\right)}{v}}
\end{array}
Initial program 99.7%
Taylor expanded in v around 0
lower-/.f32N/A
sub-negN/A
lower-fma.f32N/A
+-commutativeN/A
distribute-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
metadata-evalN/A
lower-fma.f32N/A
mul-1-negN/A
lower-neg.f3297.8
Applied rewrites97.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (exp (* cosTheta_O (/ cosTheta_i v))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf((cosTheta_O * (cosTheta_i / v)));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = exp((costheta_o * (costheta_i / v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(cosTheta_O * Float32(cosTheta_i / v))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp((cosTheta_O * (cosTheta_i / v))); end
\begin{array}{l}
\\
e^{cosTheta\_O \cdot \frac{cosTheta\_i}{v}}
\end{array}
Initial program 99.7%
Taylor expanded in cosTheta_i around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f32N/A
lower-/.f3214.6
Applied rewrites14.6%
Taylor expanded in cosTheta_i around inf
associate-/l*N/A
lower-*.f32N/A
lower-/.f3214.6
Applied rewrites14.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 1.0)
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 1.0f;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = 1.0e0
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(1.0) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 99.7%
Applied rewrites97.7%
Taylor expanded in cosTheta_i around inf
Applied rewrites6.5%
herbie shell --seed 2024227
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:name "HairBSDF, Mp, lower"
:precision binary32
:pre (and (and (and (and (and (<= -1.0 cosTheta_i) (<= cosTheta_i 1.0)) (and (<= -1.0 cosTheta_O) (<= cosTheta_O 1.0))) (and (<= -1.0 sinTheta_i) (<= sinTheta_i 1.0))) (and (<= -1.0 sinTheta_O) (<= sinTheta_O 1.0))) (and (<= -1.5707964 v) (<= v 0.1)))
(exp (+ (+ (- (- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v)) (/ 1.0 v)) 0.6931) (log (/ 1.0 (* 2.0 v))))))