
(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 13 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
(*
(/ 0.5 v)
(pow
(pow
(cbrt
(cbrt
(exp
(+
(/ (+ (fma cosTheta_i cosTheta_O (* sinTheta_i sinTheta_O)) -1.0) v)
0.6931))))
3.0)
3.0)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (0.5f / v) * powf(powf(cbrtf(cbrtf(expf((((fmaf(cosTheta_i, cosTheta_O, (sinTheta_i * sinTheta_O)) + -1.0f) / v) + 0.6931f)))), 3.0f), 3.0f);
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(0.5) / v) * ((cbrt(cbrt(exp(Float32(Float32(Float32(fma(cosTheta_i, cosTheta_O, Float32(sinTheta_i * sinTheta_O)) + Float32(-1.0)) / v) + Float32(0.6931))))) ^ Float32(3.0)) ^ Float32(3.0))) end
\begin{array}{l}
\\
\frac{0.5}{v} \cdot {\left({\left(\sqrt[3]{\sqrt[3]{e^{\frac{\mathsf{fma}\left(cosTheta\_i, cosTheta\_O, sinTheta\_i \cdot sinTheta\_O\right) + -1}{v} + 0.6931}}}\right)}^{3}\right)}^{3}
\end{array}
Initial program 99.7%
+-commutative99.7%
exp-sum99.8%
rem-exp-log99.8%
associate-/r*99.8%
metadata-eval99.8%
+-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
+-rgt-identity99.8%
+-commutative99.8%
associate--l-99.8%
associate-+r-99.8%
Simplified99.8%
add-cube-cbrt99.8%
pow399.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
associate--r+99.8%
associate-*r/99.8%
associate-*r/99.8%
sub-div99.8%
Applied egg-rr99.8%
add-cube-cbrt99.8%
pow399.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ 0.5 v) (pow (cbrt (* (exp (/ (+ -1.0 (* sinTheta_i sinTheta_O)) v)) (exp 0.6931))) 3.0)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (0.5f / v) * powf(cbrtf((expf(((-1.0f + (sinTheta_i * sinTheta_O)) / v)) * expf(0.6931f))), 3.0f);
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(0.5) / v) * (cbrt(Float32(exp(Float32(Float32(Float32(-1.0) + Float32(sinTheta_i * sinTheta_O)) / v)) * exp(Float32(0.6931)))) ^ Float32(3.0))) end
\begin{array}{l}
\\
\frac{0.5}{v} \cdot {\left(\sqrt[3]{e^{\frac{-1 + sinTheta\_i \cdot sinTheta\_O}{v}} \cdot e^{0.6931}}\right)}^{3}
\end{array}
Initial program 99.7%
+-commutative99.7%
exp-sum99.8%
rem-exp-log99.8%
associate-/r*99.8%
metadata-eval99.8%
+-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
+-rgt-identity99.8%
+-commutative99.8%
associate--l-99.8%
associate-+r-99.8%
Simplified99.8%
add-cube-cbrt99.8%
pow399.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
associate--r+99.8%
associate-*r/99.8%
associate-*r/99.8%
sub-div99.8%
Applied egg-rr99.8%
exp-sum99.8%
Applied egg-rr99.8%
Taylor expanded in cosTheta_i around 0 99.8%
Final simplification99.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(let* ((t_0 (/ (* sinTheta_i sinTheta_O) v)))
(if (<= sinTheta_i -2.499999990010493e-13)
(exp t_0)
(if (<= sinTheta_i 8.00000025099516e-22)
t_0
(exp (* sinTheta_O (/ sinTheta_i (- v))))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float t_0 = (sinTheta_i * sinTheta_O) / v;
float tmp;
if (sinTheta_i <= -2.499999990010493e-13f) {
tmp = expf(t_0);
} else if (sinTheta_i <= 8.00000025099516e-22f) {
tmp = t_0;
} else {
tmp = expf((sinTheta_O * (sinTheta_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) :: t_0
real(4) :: tmp
t_0 = (sintheta_i * sintheta_o) / v
if (sintheta_i <= (-2.499999990010493e-13)) then
tmp = exp(t_0)
else if (sintheta_i <= 8.00000025099516e-22) then
tmp = t_0
else
tmp = exp((sintheta_o * (sintheta_i / -v)))
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = Float32(Float32(sinTheta_i * sinTheta_O) / v) tmp = Float32(0.0) if (sinTheta_i <= Float32(-2.499999990010493e-13)) tmp = exp(t_0); elseif (sinTheta_i <= Float32(8.00000025099516e-22)) tmp = t_0; else tmp = exp(Float32(sinTheta_O * Float32(sinTheta_i / Float32(-v)))); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = (sinTheta_i * sinTheta_O) / v; tmp = single(0.0); if (sinTheta_i <= single(-2.499999990010493e-13)) tmp = exp(t_0); elseif (sinTheta_i <= single(8.00000025099516e-22)) tmp = t_0; else tmp = exp((sinTheta_O * (sinTheta_i / -v))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sinTheta\_i \cdot sinTheta\_O}{v}\\
\mathbf{if}\;sinTheta\_i \leq -2.499999990010493 \cdot 10^{-13}:\\
\;\;\;\;e^{t\_0}\\
\mathbf{elif}\;sinTheta\_i \leq 8.00000025099516 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{sinTheta\_O \cdot \frac{sinTheta\_i}{-v}}\\
\end{array}
\end{array}
if sinTheta_i < -2.49999999e-13Initial program 100.0%
associate-+l+100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around inf 25.3%
associate-*r/25.3%
mul-1-neg25.3%
Simplified25.3%
clear-num25.3%
inv-pow25.3%
add-sqr-sqrt3.3%
sqrt-unprod5.4%
*-commutative5.4%
*-commutative5.4%
sqr-neg5.4%
sqrt-unprod2.0%
add-sqr-sqrt15.4%
Applied egg-rr15.4%
unpow-115.4%
*-commutative15.4%
Simplified15.4%
Taylor expanded in v around 0 15.4%
if -2.49999999e-13 < sinTheta_i < 8.00000025e-22Initial program 99.8%
associate-+l+99.8%
associate--l-99.8%
associate-/l*99.8%
associate-/l*99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in sinTheta_i around inf 9.0%
associate-*r/9.0%
mul-1-neg9.0%
Simplified9.0%
clear-num9.0%
inv-pow9.0%
add-sqr-sqrt4.5%
sqrt-unprod6.4%
*-commutative6.4%
*-commutative6.4%
sqr-neg6.4%
sqrt-unprod4.9%
add-sqr-sqrt7.6%
Applied egg-rr7.6%
unpow-17.6%
*-commutative7.6%
Simplified7.6%
Taylor expanded in v around inf 6.4%
Taylor expanded in sinTheta_O around inf 52.8%
if 8.00000025e-22 < sinTheta_i Initial program 99.6%
associate-+l+99.6%
associate--l-99.6%
associate-/l*99.6%
associate-/l*99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in sinTheta_i around inf 15.8%
mul-1-neg15.8%
associate-/l*15.8%
distribute-rgt-neg-in15.8%
distribute-frac-neg215.8%
Simplified15.8%
Final simplification36.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= sinTheta_i -2.499999990010493e-13)
(exp (/ 1.0 (/ v (* sinTheta_i sinTheta_O))))
(if (<= sinTheta_i 8.00000025099516e-22)
(/ (* sinTheta_i sinTheta_O) v)
(exp (* sinTheta_O (/ sinTheta_i (- v)))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if (sinTheta_i <= -2.499999990010493e-13f) {
tmp = expf((1.0f / (v / (sinTheta_i * sinTheta_O))));
} else if (sinTheta_i <= 8.00000025099516e-22f) {
tmp = (sinTheta_i * sinTheta_O) / v;
} else {
tmp = expf((sinTheta_O * (sinTheta_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 <= (-2.499999990010493e-13)) then
tmp = exp((1.0e0 / (v / (sintheta_i * sintheta_o))))
else if (sintheta_i <= 8.00000025099516e-22) then
tmp = (sintheta_i * sintheta_o) / v
else
tmp = exp((sintheta_o * (sintheta_i / -v)))
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = Float32(0.0) if (sinTheta_i <= Float32(-2.499999990010493e-13)) tmp = exp(Float32(Float32(1.0) / Float32(v / Float32(sinTheta_i * sinTheta_O)))); elseif (sinTheta_i <= Float32(8.00000025099516e-22)) tmp = Float32(Float32(sinTheta_i * sinTheta_O) / v); else tmp = exp(Float32(sinTheta_O * Float32(sinTheta_i / Float32(-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 <= single(-2.499999990010493e-13)) tmp = exp((single(1.0) / (v / (sinTheta_i * sinTheta_O)))); elseif (sinTheta_i <= single(8.00000025099516e-22)) tmp = (sinTheta_i * sinTheta_O) / v; else tmp = exp((sinTheta_O * (sinTheta_i / -v))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \leq -2.499999990010493 \cdot 10^{-13}:\\
\;\;\;\;e^{\frac{1}{\frac{v}{sinTheta\_i \cdot sinTheta\_O}}}\\
\mathbf{elif}\;sinTheta\_i \leq 8.00000025099516 \cdot 10^{-22}:\\
\;\;\;\;\frac{sinTheta\_i \cdot sinTheta\_O}{v}\\
\mathbf{else}:\\
\;\;\;\;e^{sinTheta\_O \cdot \frac{sinTheta\_i}{-v}}\\
\end{array}
\end{array}
if sinTheta_i < -2.49999999e-13Initial program 100.0%
associate-+l+100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around inf 25.3%
associate-*r/25.3%
mul-1-neg25.3%
Simplified25.3%
clear-num25.3%
inv-pow25.3%
add-sqr-sqrt3.3%
sqrt-unprod5.4%
*-commutative5.4%
*-commutative5.4%
sqr-neg5.4%
sqrt-unprod2.0%
add-sqr-sqrt15.4%
Applied egg-rr15.4%
unpow-115.4%
*-commutative15.4%
Simplified15.4%
if -2.49999999e-13 < sinTheta_i < 8.00000025e-22Initial program 99.8%
associate-+l+99.8%
associate--l-99.8%
associate-/l*99.8%
associate-/l*99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in sinTheta_i around inf 9.0%
associate-*r/9.0%
mul-1-neg9.0%
Simplified9.0%
clear-num9.0%
inv-pow9.0%
add-sqr-sqrt4.5%
sqrt-unprod6.4%
*-commutative6.4%
*-commutative6.4%
sqr-neg6.4%
sqrt-unprod4.9%
add-sqr-sqrt7.6%
Applied egg-rr7.6%
unpow-17.6%
*-commutative7.6%
Simplified7.6%
Taylor expanded in v around inf 6.4%
Taylor expanded in sinTheta_O around inf 52.8%
if 8.00000025e-22 < sinTheta_i Initial program 99.6%
associate-+l+99.6%
associate--l-99.6%
associate-/l*99.6%
associate-/l*99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in sinTheta_i around inf 15.8%
mul-1-neg15.8%
associate-/l*15.8%
distribute-rgt-neg-in15.8%
distribute-frac-neg215.8%
Simplified15.8%
Final simplification36.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ 0.5 v) (/ 1.0 (exp (- (/ 1.0 v) 0.6931)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (0.5f / v) * (1.0f / expf(((1.0f / v) - 0.6931f)));
}
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) * (1.0e0 / exp(((1.0e0 / v) - 0.6931e0)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(0.5) / v) * Float32(Float32(1.0) / exp(Float32(Float32(Float32(1.0) / v) - Float32(0.6931))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (single(0.5) / v) * (single(1.0) / exp(((single(1.0) / v) - single(0.6931)))); end
\begin{array}{l}
\\
\frac{0.5}{v} \cdot \frac{1}{e^{\frac{1}{v} - 0.6931}}
\end{array}
Initial program 99.7%
+-commutative99.7%
exp-sum99.8%
rem-exp-log99.8%
associate-/r*99.8%
metadata-eval99.8%
+-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
+-rgt-identity99.8%
+-commutative99.8%
associate--l-99.8%
associate-+r-99.8%
Simplified99.8%
Taylor expanded in sinTheta_i around 0 99.8%
exp-diff91.6%
clear-num91.6%
+-commutative91.6%
associate-/l*91.6%
fma-define91.6%
Applied egg-rr91.6%
Taylor expanded in cosTheta_O around 0 99.8%
div-exp99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (if (<= sinTheta_i -2.499999990010493e-13) (exp (* sinTheta_O (/ sinTheta_i v))) (/ (* 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 <= -2.499999990010493e-13f) {
tmp = expf((sinTheta_O * (sinTheta_i / v)));
} else {
tmp = (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 <= (-2.499999990010493e-13)) then
tmp = exp((sintheta_o * (sintheta_i / v)))
else
tmp = (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 (sinTheta_i <= Float32(-2.499999990010493e-13)) tmp = exp(Float32(sinTheta_O * Float32(sinTheta_i / v))); else tmp = 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 <= single(-2.499999990010493e-13)) tmp = exp((sinTheta_O * (sinTheta_i / v))); else tmp = (sinTheta_i * sinTheta_O) / v; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \leq -2.499999990010493 \cdot 10^{-13}:\\
\;\;\;\;e^{sinTheta\_O \cdot \frac{sinTheta\_i}{v}}\\
\mathbf{else}:\\
\;\;\;\;\frac{sinTheta\_i \cdot sinTheta\_O}{v}\\
\end{array}
\end{array}
if sinTheta_i < -2.49999999e-13Initial program 100.0%
associate-+l+100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around inf 25.3%
associate-*r/25.3%
mul-1-neg25.3%
Simplified25.3%
clear-num25.3%
inv-pow25.3%
add-sqr-sqrt3.3%
sqrt-unprod5.4%
*-commutative5.4%
*-commutative5.4%
sqr-neg5.4%
sqrt-unprod2.0%
add-sqr-sqrt15.4%
Applied egg-rr15.4%
unpow-115.4%
*-commutative15.4%
Simplified15.4%
Taylor expanded in v around 0 15.4%
associate-*r/15.4%
Simplified15.4%
if -2.49999999e-13 < sinTheta_i Initial program 99.7%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around inf 11.5%
associate-*r/11.5%
mul-1-neg11.5%
Simplified11.5%
clear-num11.5%
inv-pow11.5%
add-sqr-sqrt4.0%
sqrt-unprod6.1%
*-commutative6.1%
*-commutative6.1%
sqr-neg6.1%
sqrt-unprod4.2%
add-sqr-sqrt11.4%
Applied egg-rr11.4%
unpow-111.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in v around inf 6.3%
Taylor expanded in sinTheta_O around inf 40.1%
Final simplification37.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (if (<= sinTheta_i -2.499999990010493e-13) (exp (* sinTheta_i (/ sinTheta_O v))) (/ (* 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 <= -2.499999990010493e-13f) {
tmp = expf((sinTheta_i * (sinTheta_O / v)));
} else {
tmp = (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 <= (-2.499999990010493e-13)) then
tmp = exp((sintheta_i * (sintheta_o / v)))
else
tmp = (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 (sinTheta_i <= Float32(-2.499999990010493e-13)) tmp = exp(Float32(sinTheta_i * Float32(sinTheta_O / v))); else tmp = 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 <= single(-2.499999990010493e-13)) tmp = exp((sinTheta_i * (sinTheta_O / v))); else tmp = (sinTheta_i * sinTheta_O) / v; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta\_i \leq -2.499999990010493 \cdot 10^{-13}:\\
\;\;\;\;e^{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\\
\mathbf{else}:\\
\;\;\;\;\frac{sinTheta\_i \cdot sinTheta\_O}{v}\\
\end{array}
\end{array}
if sinTheta_i < -2.49999999e-13Initial program 100.0%
associate-+l+100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around inf 25.3%
associate-*r/25.3%
mul-1-neg25.3%
Simplified25.3%
add-log-exp25.3%
*-un-lft-identity25.3%
log-prod25.3%
metadata-eval25.3%
add-log-exp25.3%
add-sqr-sqrt3.3%
sqrt-unprod5.4%
*-commutative5.4%
*-commutative5.4%
sqr-neg5.4%
sqrt-unprod2.0%
add-sqr-sqrt15.4%
Applied egg-rr15.4%
+-lft-identity15.4%
associate-*r/15.4%
Simplified15.4%
if -2.49999999e-13 < sinTheta_i Initial program 99.7%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around inf 11.5%
associate-*r/11.5%
mul-1-neg11.5%
Simplified11.5%
clear-num11.5%
inv-pow11.5%
add-sqr-sqrt4.0%
sqrt-unprod6.1%
*-commutative6.1%
*-commutative6.1%
sqr-neg6.1%
sqrt-unprod4.2%
add-sqr-sqrt11.4%
Applied egg-rr11.4%
unpow-111.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in v around inf 6.3%
Taylor expanded in sinTheta_O around inf 40.1%
Final simplification37.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (let* ((t_0 (/ (* sinTheta_i sinTheta_O) v))) (if (<= sinTheta_i -2.499999990010493e-13) (exp t_0) t_0)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float t_0 = (sinTheta_i * sinTheta_O) / v;
float tmp;
if (sinTheta_i <= -2.499999990010493e-13f) {
tmp = expf(t_0);
} else {
tmp = 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 = (sintheta_i * sintheta_o) / v
if (sintheta_i <= (-2.499999990010493e-13)) then
tmp = exp(t_0)
else
tmp = t_0
end if
code = tmp
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = Float32(Float32(sinTheta_i * sinTheta_O) / v) tmp = Float32(0.0) if (sinTheta_i <= Float32(-2.499999990010493e-13)) tmp = exp(t_0); else tmp = t_0; end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = (sinTheta_i * sinTheta_O) / v; tmp = single(0.0); if (sinTheta_i <= single(-2.499999990010493e-13)) tmp = exp(t_0); else tmp = t_0; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sinTheta\_i \cdot sinTheta\_O}{v}\\
\mathbf{if}\;sinTheta\_i \leq -2.499999990010493 \cdot 10^{-13}:\\
\;\;\;\;e^{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if sinTheta_i < -2.49999999e-13Initial program 100.0%
associate-+l+100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around inf 25.3%
associate-*r/25.3%
mul-1-neg25.3%
Simplified25.3%
clear-num25.3%
inv-pow25.3%
add-sqr-sqrt3.3%
sqrt-unprod5.4%
*-commutative5.4%
*-commutative5.4%
sqr-neg5.4%
sqrt-unprod2.0%
add-sqr-sqrt15.4%
Applied egg-rr15.4%
unpow-115.4%
*-commutative15.4%
Simplified15.4%
Taylor expanded in v around 0 15.4%
if -2.49999999e-13 < sinTheta_i Initial program 99.7%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around inf 11.5%
associate-*r/11.5%
mul-1-neg11.5%
Simplified11.5%
clear-num11.5%
inv-pow11.5%
add-sqr-sqrt4.0%
sqrt-unprod6.1%
*-commutative6.1%
*-commutative6.1%
sqr-neg6.1%
sqrt-unprod4.2%
add-sqr-sqrt11.4%
Applied egg-rr11.4%
unpow-111.4%
*-commutative11.4%
Simplified11.4%
Taylor expanded in v around inf 6.3%
Taylor expanded in sinTheta_O around inf 40.1%
Final simplification37.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%
+-commutative99.7%
exp-sum99.8%
rem-exp-log99.8%
associate-/r*99.8%
metadata-eval99.8%
+-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
+-rgt-identity99.8%
+-commutative99.8%
associate--l-99.8%
associate-+r-99.8%
Simplified99.8%
Taylor expanded in sinTheta_i around 0 99.8%
Taylor expanded in cosTheta_O around 0 99.8%
Final simplification99.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (exp (/ (+ -1.0 (* cosTheta_i cosTheta_O)) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf(((-1.0f + (cosTheta_i * cosTheta_O)) / 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((((-1.0e0) + (costheta_i * costheta_o)) / v))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(Float32(Float32(-1.0) + Float32(cosTheta_i * cosTheta_O)) / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp(((single(-1.0) + (cosTheta_i * cosTheta_O)) / v)); end
\begin{array}{l}
\\
e^{\frac{-1 + cosTheta\_i \cdot cosTheta\_O}{v}}
\end{array}
Initial program 99.7%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around 0 99.7%
Taylor expanded in v around 0 98.1%
Final simplification98.1%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* sinTheta_O (/ sinTheta_i v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return sinTheta_O * (sinTheta_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 = sintheta_o * (sintheta_i / v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(sinTheta_O * Float32(sinTheta_i / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = sinTheta_O * (sinTheta_i / v); end
\begin{array}{l}
\\
sinTheta\_O \cdot \frac{sinTheta\_i}{v}
\end{array}
Initial program 99.7%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around inf 13.1%
associate-*r/13.1%
mul-1-neg13.1%
Simplified13.1%
clear-num13.1%
inv-pow13.1%
add-sqr-sqrt3.9%
sqrt-unprod6.0%
*-commutative6.0%
*-commutative6.0%
sqr-neg6.0%
sqrt-unprod4.0%
add-sqr-sqrt11.9%
Applied egg-rr11.9%
unpow-111.9%
*-commutative11.9%
Simplified11.9%
Taylor expanded in v around inf 6.2%
Taylor expanded in sinTheta_O around inf 36.6%
associate-*r/18.6%
Simplified18.6%
Final simplification18.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* sinTheta_i sinTheta_O) v))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (sinTheta_i * sinTheta_O) / 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 = (sintheta_i * sintheta_o) / v
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(sinTheta_i * sinTheta_O) / v) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (sinTheta_i * sinTheta_O) / v; end
\begin{array}{l}
\\
\frac{sinTheta\_i \cdot sinTheta\_O}{v}
\end{array}
Initial program 99.7%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around inf 13.1%
associate-*r/13.1%
mul-1-neg13.1%
Simplified13.1%
clear-num13.1%
inv-pow13.1%
add-sqr-sqrt3.9%
sqrt-unprod6.0%
*-commutative6.0%
*-commutative6.0%
sqr-neg6.0%
sqrt-unprod4.0%
add-sqr-sqrt11.9%
Applied egg-rr11.9%
unpow-111.9%
*-commutative11.9%
Simplified11.9%
Taylor expanded in v around inf 6.2%
Taylor expanded in sinTheta_O around inf 36.6%
Final simplification36.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%
associate-+l+99.7%
associate--l-99.7%
associate-/l*99.7%
associate-/l*99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in sinTheta_i around inf 13.1%
associate-*r/13.1%
mul-1-neg13.1%
Simplified13.1%
Taylor expanded in sinTheta_O around 0 6.4%
Final simplification6.4%
herbie shell --seed 2024041
(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))))))