
(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 (pow (exp (* 0.5 (+ (log (/ 0.5 v)) (+ 0.6931 (/ -1.0 v))))) 2.0))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return powf(expf((0.5f * (logf((0.5f / v)) + (0.6931f + (-1.0f / v))))), 2.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 = exp((0.5e0 * (log((0.5e0 / v)) + (0.6931e0 + ((-1.0e0) / v))))) ** 2.0e0
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(Float32(0.5) * Float32(log(Float32(Float32(0.5) / v)) + Float32(Float32(0.6931) + Float32(Float32(-1.0) / v))))) ^ Float32(2.0) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp((single(0.5) * (log((single(0.5) / v)) + (single(0.6931) + (single(-1.0) / v))))) ^ single(2.0); end
\begin{array}{l}
\\
{\left(e^{0.5 \cdot \left(\log \left(\frac{0.5}{v}\right) + \left(0.6931 + \frac{-1}{v}\right)\right)}\right)}^{2}
\end{array}
Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around 0 99.9%
Taylor expanded in cosTheta_i around 0 99.9%
add-sqr-sqrt100.0%
pow2100.0%
+-commutative100.0%
associate--l+100.0%
Applied egg-rr100.0%
pow1/2100.0%
pow-exp100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (exp (+ (+ (log (/ 0.5 v)) 0.6931) (/ -1.0 v))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf(((logf((0.5f / v)) + 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 = exp(((log((0.5e0 / v)) + 0.6931e0) + ((-1.0e0) / v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(Float32(log(Float32(Float32(0.5) / v)) + Float32(0.6931)) + Float32(Float32(-1.0) / v))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp(((log((single(0.5) / v)) + single(0.6931)) + (single(-1.0) / v))); end
\begin{array}{l}
\\
e^{\left(\log \left(\frac{0.5}{v}\right) + 0.6931\right) + \frac{-1}{v}}
\end{array}
Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around 0 99.9%
Taylor expanded in cosTheta_i around 0 99.9%
Final simplification99.9%
(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.9%
exp-sum99.8%
Simplified99.8%
Taylor expanded in sinTheta_i around 0 99.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 (exp (/ -1.0 v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return expf((-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 = exp(((-1.0e0) / v))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return exp(Float32(Float32(-1.0) / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = exp((single(-1.0) / v)); end
\begin{array}{l}
\\
e^{\frac{-1}{v}}
\end{array}
Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around 0 99.9%
Taylor expanded in cosTheta_i around 0 99.9%
Taylor expanded in v around 0 98.9%
Final simplification98.9%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= (* cosTheta_i cosTheta_O) -1.961817850054744e-44)
(/ (* sinTheta_O sinTheta_i) v)
(if (<= (* cosTheta_i cosTheta_O) 0.0)
(/ (* cosTheta_i cosTheta_O) v)
(/ (* sinTheta_O (- sinTheta_i)) v))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((cosTheta_i * cosTheta_O) <= -1.961817850054744e-44f) {
tmp = (sinTheta_O * sinTheta_i) / v;
} else if ((cosTheta_i * cosTheta_O) <= 0.0f) {
tmp = (cosTheta_i * cosTheta_O) / v;
} else {
tmp = (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 ((costheta_i * costheta_o) <= (-1.961817850054744e-44)) then
tmp = (sintheta_o * sintheta_i) / v
else if ((costheta_i * costheta_o) <= 0.0e0) then
tmp = (costheta_i * costheta_o) / v
else
tmp = (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 (Float32(cosTheta_i * cosTheta_O) <= Float32(-1.961817850054744e-44)) tmp = Float32(Float32(sinTheta_O * sinTheta_i) / v); elseif (Float32(cosTheta_i * cosTheta_O) <= Float32(0.0)) tmp = Float32(Float32(cosTheta_i * cosTheta_O) / v); else tmp = Float32(Float32(sinTheta_O * Float32(-sinTheta_i)) / v); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((cosTheta_i * cosTheta_O) <= single(-1.961817850054744e-44)) tmp = (sinTheta_O * sinTheta_i) / v; elseif ((cosTheta_i * cosTheta_O) <= single(0.0)) tmp = (cosTheta_i * cosTheta_O) / v; else tmp = (sinTheta_O * -sinTheta_i) / v; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;cosTheta_i \cdot cosTheta_O \leq -1.961817850054744 \cdot 10^{-44}:\\
\;\;\;\;\frac{sinTheta_O \cdot sinTheta_i}{v}\\
\mathbf{elif}\;cosTheta_i \cdot cosTheta_O \leq 0:\\
\;\;\;\;\frac{cosTheta_i \cdot cosTheta_O}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{sinTheta_O \cdot \left(-sinTheta_i\right)}{v}\\
\end{array}
\end{array}
if (*.f32 cosTheta_i cosTheta_O) < -1.96182e-44Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 15.3%
associate-*r/15.3%
associate-*l/15.3%
metadata-eval15.3%
distribute-neg-frac15.3%
distribute-lft-neg-in15.3%
*-commutative15.3%
associate-*l*15.3%
distribute-lft-neg-in15.3%
associate-*r/15.3%
*-commutative15.3%
*-lft-identity15.3%
Simplified15.3%
Taylor expanded in sinTheta_i around 0 6.2%
mul-1-neg6.2%
associate-*r/6.2%
distribute-lft-neg-in6.2%
+-commutative6.2%
distribute-lft-neg-in6.2%
associate-*r/6.2%
unsub-neg6.2%
*-commutative6.2%
associate-*r/6.2%
Simplified6.2%
Taylor expanded in sinTheta_O around inf 50.7%
mul-1-neg50.7%
*-commutative50.7%
associate-*r/24.2%
distribute-lft-neg-in24.2%
Simplified24.2%
associate-*r/50.7%
add-sqr-sqrt25.4%
sqrt-unprod64.8%
sqr-neg64.8%
sqrt-unprod25.3%
add-sqr-sqrt50.7%
Applied egg-rr50.7%
if -1.96182e-44 < (*.f32 cosTheta_i cosTheta_O) < 0.0Initial program 100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l-100.0%
associate-+l-100.0%
sub-neg100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around 0 100.0%
Taylor expanded in cosTheta_i around inf 6.3%
associate-*l/6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around 0 6.3%
*-commutative6.3%
associate-*r/6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around inf 96.3%
if 0.0 < (*.f32 cosTheta_i cosTheta_O) Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 17.0%
associate-*r/17.0%
associate-*l/17.0%
metadata-eval17.0%
distribute-neg-frac17.0%
distribute-lft-neg-in17.0%
*-commutative17.0%
associate-*l*17.0%
distribute-lft-neg-in17.0%
associate-*r/17.0%
*-commutative17.0%
*-lft-identity17.0%
Simplified17.0%
Taylor expanded in sinTheta_i around 0 6.1%
mul-1-neg6.1%
associate-*r/6.1%
distribute-lft-neg-in6.1%
+-commutative6.1%
distribute-lft-neg-in6.1%
associate-*r/6.1%
unsub-neg6.1%
*-commutative6.1%
associate-*r/6.1%
Simplified6.1%
Taylor expanded in sinTheta_O around inf 35.1%
Final simplification61.1%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= (* cosTheta_i cosTheta_O) -1.961817850054744e-44)
(/ 1.0 (/ v (* sinTheta_O sinTheta_i)))
(if (<= (* cosTheta_i cosTheta_O) 0.0)
(/ (* cosTheta_i cosTheta_O) v)
(/ (* sinTheta_O (- sinTheta_i)) v))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((cosTheta_i * cosTheta_O) <= -1.961817850054744e-44f) {
tmp = 1.0f / (v / (sinTheta_O * sinTheta_i));
} else if ((cosTheta_i * cosTheta_O) <= 0.0f) {
tmp = (cosTheta_i * cosTheta_O) / v;
} else {
tmp = (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 ((costheta_i * costheta_o) <= (-1.961817850054744e-44)) then
tmp = 1.0e0 / (v / (sintheta_o * sintheta_i))
else if ((costheta_i * costheta_o) <= 0.0e0) then
tmp = (costheta_i * costheta_o) / v
else
tmp = (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 (Float32(cosTheta_i * cosTheta_O) <= Float32(-1.961817850054744e-44)) tmp = Float32(Float32(1.0) / Float32(v / Float32(sinTheta_O * sinTheta_i))); elseif (Float32(cosTheta_i * cosTheta_O) <= Float32(0.0)) tmp = Float32(Float32(cosTheta_i * cosTheta_O) / v); else tmp = Float32(Float32(sinTheta_O * Float32(-sinTheta_i)) / v); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((cosTheta_i * cosTheta_O) <= single(-1.961817850054744e-44)) tmp = single(1.0) / (v / (sinTheta_O * sinTheta_i)); elseif ((cosTheta_i * cosTheta_O) <= single(0.0)) tmp = (cosTheta_i * cosTheta_O) / v; else tmp = (sinTheta_O * -sinTheta_i) / v; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;cosTheta_i \cdot cosTheta_O \leq -1.961817850054744 \cdot 10^{-44}:\\
\;\;\;\;\frac{1}{\frac{v}{sinTheta_O \cdot sinTheta_i}}\\
\mathbf{elif}\;cosTheta_i \cdot cosTheta_O \leq 0:\\
\;\;\;\;\frac{cosTheta_i \cdot cosTheta_O}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{sinTheta_O \cdot \left(-sinTheta_i\right)}{v}\\
\end{array}
\end{array}
if (*.f32 cosTheta_i cosTheta_O) < -1.96182e-44Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 15.3%
associate-*r/15.3%
associate-*l/15.3%
metadata-eval15.3%
distribute-neg-frac15.3%
distribute-lft-neg-in15.3%
*-commutative15.3%
associate-*l*15.3%
distribute-lft-neg-in15.3%
associate-*r/15.3%
*-commutative15.3%
*-lft-identity15.3%
Simplified15.3%
Taylor expanded in sinTheta_i around 0 6.2%
mul-1-neg6.2%
associate-*r/6.2%
distribute-lft-neg-in6.2%
+-commutative6.2%
distribute-lft-neg-in6.2%
associate-*r/6.2%
unsub-neg6.2%
*-commutative6.2%
associate-*r/6.2%
Simplified6.2%
Taylor expanded in sinTheta_O around inf 50.7%
mul-1-neg50.7%
*-commutative50.7%
associate-*r/24.2%
distribute-lft-neg-in24.2%
Simplified24.2%
associate-*r/50.7%
clear-num51.4%
add-sqr-sqrt26.2%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod25.3%
add-sqr-sqrt51.4%
Applied egg-rr51.4%
if -1.96182e-44 < (*.f32 cosTheta_i cosTheta_O) < 0.0Initial program 100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l-100.0%
associate-+l-100.0%
sub-neg100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around 0 100.0%
Taylor expanded in cosTheta_i around inf 6.3%
associate-*l/6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around 0 6.3%
*-commutative6.3%
associate-*r/6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around inf 96.3%
if 0.0 < (*.f32 cosTheta_i cosTheta_O) Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 17.0%
associate-*r/17.0%
associate-*l/17.0%
metadata-eval17.0%
distribute-neg-frac17.0%
distribute-lft-neg-in17.0%
*-commutative17.0%
associate-*l*17.0%
distribute-lft-neg-in17.0%
associate-*r/17.0%
*-commutative17.0%
*-lft-identity17.0%
Simplified17.0%
Taylor expanded in sinTheta_i around 0 6.1%
mul-1-neg6.1%
associate-*r/6.1%
distribute-lft-neg-in6.1%
+-commutative6.1%
distribute-lft-neg-in6.1%
associate-*r/6.1%
unsub-neg6.1%
*-commutative6.1%
associate-*r/6.1%
Simplified6.1%
Taylor expanded in sinTheta_O around inf 35.1%
Final simplification61.4%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (or (<= (* cosTheta_i cosTheta_O) -1.961817850054744e-44)
(not (<= (* cosTheta_i cosTheta_O) 0.0)))
(/ (* sinTheta_O sinTheta_i) v)
(/ (* cosTheta_i cosTheta_O) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if (((cosTheta_i * cosTheta_O) <= -1.961817850054744e-44f) || !((cosTheta_i * cosTheta_O) <= 0.0f)) {
tmp = (sinTheta_O * sinTheta_i) / v;
} else {
tmp = (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 (((costheta_i * costheta_o) <= (-1.961817850054744e-44)) .or. (.not. ((costheta_i * costheta_o) <= 0.0e0))) then
tmp = (sintheta_o * sintheta_i) / v
else
tmp = (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(cosTheta_i * cosTheta_O) <= Float32(-1.961817850054744e-44)) || !(Float32(cosTheta_i * cosTheta_O) <= Float32(0.0))) tmp = Float32(Float32(sinTheta_O * sinTheta_i) / v); else tmp = 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 (((cosTheta_i * cosTheta_O) <= single(-1.961817850054744e-44)) || ~(((cosTheta_i * cosTheta_O) <= single(0.0)))) tmp = (sinTheta_O * sinTheta_i) / v; else tmp = (cosTheta_i * cosTheta_O) / v; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;cosTheta_i \cdot cosTheta_O \leq -1.961817850054744 \cdot 10^{-44} \lor \neg \left(cosTheta_i \cdot cosTheta_O \leq 0\right):\\
\;\;\;\;\frac{sinTheta_O \cdot sinTheta_i}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{cosTheta_i \cdot cosTheta_O}{v}\\
\end{array}
\end{array}
if (*.f32 cosTheta_i cosTheta_O) < -1.96182e-44 or 0.0 < (*.f32 cosTheta_i cosTheta_O) Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 16.2%
associate-*r/16.2%
associate-*l/16.2%
metadata-eval16.2%
distribute-neg-frac16.2%
distribute-lft-neg-in16.2%
*-commutative16.2%
associate-*l*16.2%
distribute-lft-neg-in16.2%
associate-*r/16.2%
*-commutative16.2%
*-lft-identity16.2%
Simplified16.2%
Taylor expanded in sinTheta_i around 0 6.2%
mul-1-neg6.2%
associate-*r/6.2%
distribute-lft-neg-in6.2%
+-commutative6.2%
distribute-lft-neg-in6.2%
associate-*r/6.2%
unsub-neg6.2%
*-commutative6.2%
associate-*r/6.2%
Simplified6.2%
Taylor expanded in sinTheta_O around inf 42.7%
mul-1-neg42.7%
*-commutative42.7%
associate-*r/23.3%
distribute-lft-neg-in23.3%
Simplified23.3%
associate-*r/42.7%
add-sqr-sqrt20.9%
sqrt-unprod58.8%
sqr-neg58.8%
sqrt-unprod21.7%
add-sqr-sqrt42.7%
Applied egg-rr42.7%
if -1.96182e-44 < (*.f32 cosTheta_i cosTheta_O) < 0.0Initial program 100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l-100.0%
associate-+l-100.0%
sub-neg100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around 0 100.0%
Taylor expanded in cosTheta_i around inf 6.3%
associate-*l/6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around 0 6.3%
*-commutative6.3%
associate-*r/6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around inf 96.3%
Final simplification61.1%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= (* cosTheta_i cosTheta_O) -1.961817850054744e-44)
(/ sinTheta_O (/ v sinTheta_i))
(if (<= (* cosTheta_i cosTheta_O) 1.999933168284379e-41)
(/ (* cosTheta_i cosTheta_O) v)
(* sinTheta_O (/ sinTheta_i v)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float tmp;
if ((cosTheta_i * cosTheta_O) <= -1.961817850054744e-44f) {
tmp = sinTheta_O / (v / sinTheta_i);
} else if ((cosTheta_i * cosTheta_O) <= 1.999933168284379e-41f) {
tmp = (cosTheta_i * cosTheta_O) / v;
} else {
tmp = 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 ((costheta_i * costheta_o) <= (-1.961817850054744e-44)) then
tmp = sintheta_o / (v / sintheta_i)
else if ((costheta_i * costheta_o) <= 1.999933168284379e-41) then
tmp = (costheta_i * costheta_o) / v
else
tmp = 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 (Float32(cosTheta_i * cosTheta_O) <= Float32(-1.961817850054744e-44)) tmp = Float32(sinTheta_O / Float32(v / sinTheta_i)); elseif (Float32(cosTheta_i * cosTheta_O) <= Float32(1.999933168284379e-41)) tmp = Float32(Float32(cosTheta_i * cosTheta_O) / v); else tmp = Float32(sinTheta_O * Float32(sinTheta_i / v)); end return tmp end
function tmp_2 = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.0); if ((cosTheta_i * cosTheta_O) <= single(-1.961817850054744e-44)) tmp = sinTheta_O / (v / sinTheta_i); elseif ((cosTheta_i * cosTheta_O) <= single(1.999933168284379e-41)) tmp = (cosTheta_i * cosTheta_O) / v; else tmp = sinTheta_O * (sinTheta_i / v); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;cosTheta_i \cdot cosTheta_O \leq -1.961817850054744 \cdot 10^{-44}:\\
\;\;\;\;\frac{sinTheta_O}{\frac{v}{sinTheta_i}}\\
\mathbf{elif}\;cosTheta_i \cdot cosTheta_O \leq 1.999933168284379 \cdot 10^{-41}:\\
\;\;\;\;\frac{cosTheta_i \cdot cosTheta_O}{v}\\
\mathbf{else}:\\
\;\;\;\;sinTheta_O \cdot \frac{sinTheta_i}{v}\\
\end{array}
\end{array}
if (*.f32 cosTheta_i cosTheta_O) < -1.96182e-44Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 15.3%
associate-*r/15.3%
associate-*l/15.3%
metadata-eval15.3%
distribute-neg-frac15.3%
distribute-lft-neg-in15.3%
*-commutative15.3%
associate-*l*15.3%
distribute-lft-neg-in15.3%
associate-*r/15.3%
*-commutative15.3%
*-lft-identity15.3%
Simplified15.3%
Taylor expanded in sinTheta_i around 0 6.2%
mul-1-neg6.2%
associate-*r/6.2%
distribute-lft-neg-in6.2%
+-commutative6.2%
distribute-lft-neg-in6.2%
associate-*r/6.2%
unsub-neg6.2%
*-commutative6.2%
associate-*r/6.2%
Simplified6.2%
Taylor expanded in sinTheta_O around inf 50.7%
mul-1-neg50.7%
*-commutative50.7%
associate-*r/24.2%
distribute-lft-neg-in24.2%
Simplified24.2%
expm1-log1p-u23.7%
expm1-udef72.6%
add-sqr-sqrt35.5%
sqrt-unprod76.2%
sqr-neg76.2%
sqrt-unprod37.2%
add-sqr-sqrt72.7%
Applied egg-rr72.7%
expm1-def23.7%
expm1-log1p24.2%
associate-*r/50.7%
associate-/l*24.2%
Simplified24.2%
if -1.96182e-44 < (*.f32 cosTheta_i cosTheta_O) < 1.99993e-41Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around 0 99.9%
Taylor expanded in cosTheta_i around inf 6.3%
associate-*l/6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around 0 6.3%
*-commutative6.3%
associate-*r/6.3%
Simplified6.3%
Taylor expanded in cosTheta_O around inf 86.7%
if 1.99993e-41 < (*.f32 cosTheta_i cosTheta_O) Initial program 100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l-100.0%
associate-+l-100.0%
sub-neg100.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 18.7%
associate-*r/18.7%
associate-*l/18.7%
metadata-eval18.7%
distribute-neg-frac18.7%
distribute-lft-neg-in18.7%
*-commutative18.7%
associate-*l*18.7%
distribute-lft-neg-in18.7%
associate-*r/18.7%
*-commutative18.7%
*-lft-identity18.7%
Simplified18.7%
Taylor expanded in sinTheta_i around 0 6.0%
mul-1-neg6.0%
associate-*r/6.0%
distribute-lft-neg-in6.0%
+-commutative6.0%
distribute-lft-neg-in6.0%
associate-*r/6.0%
unsub-neg6.0%
*-commutative6.0%
associate-*r/6.0%
Simplified6.0%
Taylor expanded in sinTheta_O around inf 36.8%
mul-1-neg36.8%
*-commutative36.8%
associate-*r/23.2%
distribute-lft-neg-in23.2%
Simplified23.2%
expm1-log1p-u22.4%
expm1-udef69.9%
add-sqr-sqrt36.8%
sqrt-unprod76.4%
sqr-neg76.4%
sqrt-unprod34.4%
add-sqr-sqrt71.3%
Applied egg-rr71.3%
expm1-def22.6%
expm1-log1p23.2%
Simplified23.2%
Final simplification48.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (if (<= sinTheta_O 1.5000000170217692e-18) (* sinTheta_O (/ sinTheta_i v)) (* 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_O <= 1.5000000170217692e-18f) {
tmp = sinTheta_O * (sinTheta_i / v);
} else {
tmp = 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_o <= 1.5000000170217692e-18) then
tmp = sintheta_o * (sintheta_i / v)
else
tmp = 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 (sinTheta_O <= Float32(1.5000000170217692e-18)) tmp = Float32(sinTheta_O * Float32(sinTheta_i / v)); else tmp = 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_O <= single(1.5000000170217692e-18)) tmp = sinTheta_O * (sinTheta_i / v); else tmp = cosTheta_O * (cosTheta_i / v); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sinTheta_O \leq 1.5000000170217692 \cdot 10^{-18}:\\
\;\;\;\;sinTheta_O \cdot \frac{sinTheta_i}{v}\\
\mathbf{else}:\\
\;\;\;\;cosTheta_O \cdot \frac{cosTheta_i}{v}\\
\end{array}
\end{array}
if sinTheta_O < 1.50000002e-18Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 11.1%
associate-*r/11.1%
associate-*l/11.1%
metadata-eval11.1%
distribute-neg-frac11.1%
distribute-lft-neg-in11.1%
*-commutative11.1%
associate-*l*11.1%
distribute-lft-neg-in11.1%
associate-*r/11.1%
*-commutative11.1%
*-lft-identity11.1%
Simplified11.1%
Taylor expanded in sinTheta_i around 0 6.2%
mul-1-neg6.2%
associate-*r/6.2%
distribute-lft-neg-in6.2%
+-commutative6.2%
distribute-lft-neg-in6.2%
associate-*r/6.2%
unsub-neg6.2%
*-commutative6.2%
associate-*r/6.2%
Simplified6.2%
Taylor expanded in sinTheta_O around inf 48.3%
mul-1-neg48.3%
*-commutative48.3%
associate-*r/25.6%
distribute-lft-neg-in25.6%
Simplified25.6%
expm1-log1p-u25.3%
expm1-udef79.2%
add-sqr-sqrt46.6%
sqrt-unprod82.8%
sqr-neg82.8%
sqrt-unprod32.1%
add-sqr-sqrt78.1%
Applied egg-rr78.1%
expm1-def25.1%
expm1-log1p25.6%
Simplified25.6%
if 1.50000002e-18 < sinTheta_O Initial program 100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l-100.0%
associate-+l-100.0%
sub-neg100.0%
associate--l-100.0%
associate-/l*100.0%
associate-/r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in sinTheta_i around 0 100.0%
Taylor expanded in cosTheta_i around inf 15.7%
associate-*l/15.7%
*-commutative15.7%
Simplified15.7%
Taylor expanded in cosTheta_O around 0 6.1%
*-commutative6.1%
associate-*r/6.1%
Simplified6.1%
Taylor expanded in cosTheta_O around inf 42.1%
*-commutative42.1%
associate-*r/19.6%
Simplified19.6%
Final simplification24.5%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O (/ cosTheta_i v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 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 = costheta_o * (costheta_i / v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O * Float32(cosTheta_i / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = cosTheta_O * (cosTheta_i / v); end
\begin{array}{l}
\\
cosTheta_O \cdot \frac{cosTheta_i}{v}
\end{array}
Initial program 99.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around 0 99.9%
Taylor expanded in cosTheta_i around inf 16.7%
associate-*l/16.7%
*-commutative16.7%
Simplified16.7%
Taylor expanded in cosTheta_O around 0 6.1%
*-commutative6.1%
associate-*r/6.1%
Simplified6.1%
Taylor expanded in cosTheta_O around inf 38.7%
*-commutative38.7%
associate-*r/18.3%
Simplified18.3%
Final simplification18.3%
(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.9%
associate-+l+99.9%
sub-neg99.9%
associate-+l-99.9%
associate-+l-99.9%
sub-neg99.9%
associate--l-99.9%
associate-/l*99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in sinTheta_i around inf 13.8%
associate-*r/13.8%
associate-*l/13.8%
metadata-eval13.8%
distribute-neg-frac13.8%
distribute-lft-neg-in13.8%
*-commutative13.8%
associate-*l*13.8%
distribute-lft-neg-in13.8%
associate-*r/13.8%
*-commutative13.8%
*-lft-identity13.8%
Simplified13.8%
Taylor expanded in sinTheta_i around 0 6.3%
Final simplification6.3%
herbie shell --seed 2023230
(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))))))