
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 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(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\begin{array}{l}
\\
\frac{e^{-\frac{sinTheta_i \cdot sinTheta_O}{v}} \cdot \frac{cosTheta_i \cdot cosTheta_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 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(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\begin{array}{l}
\\
\frac{e^{-\frac{sinTheta_i \cdot sinTheta_O}{v}} \cdot \frac{cosTheta_i \cdot cosTheta_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (* (pow v 2.0) (- (exp (/ 1.0 v)) (exp (/ -1.0 v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O * cosTheta_i) / (powf(v, 2.0f) * (expf((1.0f / v)) - 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 = (costheta_o * costheta_i) / ((v ** 2.0e0) * (exp((1.0e0 / v)) - exp(((-1.0e0) / v))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O * cosTheta_i) / Float32((v ^ Float32(2.0)) * Float32(exp(Float32(Float32(1.0) / v)) - exp(Float32(Float32(-1.0) / v))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (cosTheta_O * cosTheta_i) / ((v ^ single(2.0)) * (exp((single(1.0) / v)) - exp((single(-1.0) / v)))); end
\begin{array}{l}
\\
\frac{cosTheta_O \cdot cosTheta_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - e^{\frac{-1}{v}}\right)}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in sinTheta_i around 0 98.7%
expm1-log1p-u98.7%
expm1-udef98.7%
rec-exp98.7%
distribute-neg-frac98.7%
metadata-eval98.7%
Applied egg-rr98.7%
expm1-def98.7%
expm1-log1p98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ (* cosTheta_i (/ cosTheta_O v)) (sinh (/ 1.0 v))) (/ (exp (- (* sinTheta_O (/ sinTheta_i v)))) (* v 2.0))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return ((cosTheta_i * (cosTheta_O / v)) / sinhf((1.0f / v))) * (expf(-(sinTheta_O * (sinTheta_i / v))) / (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 = ((costheta_i * (costheta_o / v)) / sinh((1.0e0 / v))) * (exp(-(sintheta_o * (sintheta_i / v))) / (v * 2.0e0))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(cosTheta_i * Float32(cosTheta_O / v)) / sinh(Float32(Float32(1.0) / v))) * Float32(exp(Float32(-Float32(sinTheta_O * Float32(sinTheta_i / v)))) / Float32(v * Float32(2.0)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = ((cosTheta_i * (cosTheta_O / v)) / sinh((single(1.0) / v))) * (exp(-(sinTheta_O * (sinTheta_i / v))) / (v * single(2.0))); end
\begin{array}{l}
\\
\frac{cosTheta_i \cdot \frac{cosTheta_O}{v}}{\sinh \left(\frac{1}{v}\right)} \cdot \frac{e^{-sinTheta_O \cdot \frac{sinTheta_i}{v}}}{v \cdot 2}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in v around 0 98.6%
Final simplification98.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* (exp (/ (* sinTheta_i (- sinTheta_O)) v)) (* cosTheta_i (/ cosTheta_O v))) (* v (* 2.0 (sinh (/ 1.0 v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(((sinTheta_i * -sinTheta_O) / v)) * (cosTheta_i * (cosTheta_O / v))) / (v * (2.0f * sinhf((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(((sintheta_i * -sintheta_o) / v)) * (costheta_i * (costheta_o / v))) / (v * (2.0e0 * sinh((1.0e0 / v))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(Float32(sinTheta_i * Float32(-sinTheta_O)) / v)) * Float32(cosTheta_i * Float32(cosTheta_O / v))) / Float32(v * Float32(Float32(2.0) * sinh(Float32(Float32(1.0) / v))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(((sinTheta_i * -sinTheta_O) / v)) * (cosTheta_i * (cosTheta_O / v))) / (v * (single(2.0) * sinh((single(1.0) / v)))); end
\begin{array}{l}
\\
\frac{e^{\frac{sinTheta_i \cdot \left(-sinTheta_O\right)}{v}} \cdot \left(cosTheta_i \cdot \frac{cosTheta_O}{v}\right)}{v \cdot \left(2 \cdot \sinh \left(\frac{1}{v}\right)\right)}
\end{array}
Initial program 98.6%
*-commutative98.6%
associate-*l/98.6%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= v 0.24199999868869781)
(/ (* cosTheta_O cosTheta_i) (* (pow v 2.0) (exp (/ 1.0 v))))
(/
cosTheta_O
(/ (* (pow v 2.0) (* 2.0 (sinh (reciprocal v)))) cosTheta_i))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 0.24199999868869781:\\
\;\;\;\;\frac{cosTheta_O \cdot cosTheta_i}{{v}^{2} \cdot e^{\frac{1}{v}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{cosTheta_O}{\frac{{v}^{2} \cdot \left(2 \cdot \sinh \mathsf{reciprocal}\left(v\right)\right)}{cosTheta_i}}\\
\end{array}
\end{array}
if v < 0.241999999Initial program 97.9%
associate-*l*97.9%
*-commutative97.9%
times-frac97.8%
*-commutative97.8%
associate-*l/97.8%
reciprocal-define79.1%
exp-neg79.1%
1-exp79.1%
div079.1%
exp-diff79.1%
associate-/l*79.1%
div-sub79.1%
neg-sub079.1%
associate-/r/79.1%
*-commutative79.1%
Simplified79.1%
Taylor expanded in sinTheta_i around 0 98.1%
Taylor expanded in v around inf 81.3%
reciprocal-define81.3%
Simplified81.3%
Taylor expanded in v around 0 90.4%
if 0.241999999 < v Initial program 98.9%
associate-/l*98.9%
frac-2neg98.9%
add-sqr-sqrt57.2%
sqrt-unprod98.9%
sqr-neg98.9%
sqrt-unprod41.7%
add-sqr-sqrt98.9%
neg-sub098.9%
div-sub98.9%
add-sqr-sqrt41.7%
sqrt-unprod98.9%
sqr-neg98.9%
sqrt-unprod57.2%
add-sqr-sqrt98.9%
add-sqr-sqrt48.8%
sqrt-unprod98.9%
sqr-neg98.9%
sqrt-unprod50.1%
add-sqr-sqrt98.9%
Applied egg-rr98.9%
div098.9%
neg-sub098.9%
associate-/r/98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
Taylor expanded in sinTheta_i around 0 98.9%
Simplified84.3%
Final simplification86.2%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= v 0.45500001311302185)
(/ (* cosTheta_O cosTheta_i) (* (pow v 2.0) (exp (/ 1.0 v))))
(/
(* cosTheta_O cosTheta_i)
(+
(* 0.016666666666666666 (pow (reciprocal v) 3.0))
(+ (* (/ 1.0 v) 0.3333333333333333) (* v 2.0))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 0.45500001311302185:\\
\;\;\;\;\frac{cosTheta_O \cdot cosTheta_i}{{v}^{2} \cdot e^{\frac{1}{v}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{cosTheta_O \cdot cosTheta_i}{0.016666666666666666 \cdot {\mathsf{reciprocal}\left(v\right)}^{3} + \left(\frac{1}{v} \cdot 0.3333333333333333 + v \cdot 2\right)}\\
\end{array}
\end{array}
if v < 0.455000013Initial program 98.2%
associate-*l*98.2%
*-commutative98.2%
times-frac98.2%
*-commutative98.2%
associate-*l/98.2%
reciprocal-define80.7%
exp-neg80.7%
1-exp80.7%
div080.7%
exp-diff80.7%
associate-/l*80.7%
div-sub80.7%
neg-sub080.7%
associate-/r/80.7%
*-commutative80.7%
Simplified80.7%
Taylor expanded in sinTheta_i around 0 98.3%
Taylor expanded in v around inf 78.5%
reciprocal-define78.5%
Simplified78.5%
Taylor expanded in v around 0 85.4%
if 0.455000013 < v Initial program 98.9%
associate-*l*98.9%
*-commutative98.9%
times-frac99.2%
*-commutative99.2%
associate-*l/99.0%
reciprocal-define84.5%
exp-neg84.5%
1-exp84.5%
div084.5%
exp-diff84.5%
associate-/l*84.5%
div-sub84.5%
neg-sub084.5%
associate-/r/84.5%
*-commutative84.5%
Simplified84.5%
Taylor expanded in sinTheta_i around 0 99.0%
Taylor expanded in v around inf 80.5%
add-cube-cbrt80.5%
pow380.5%
cbrt-div80.5%
metadata-eval80.5%
rem-cbrt-cube80.5%
reciprocal-define80.5%
Applied egg-rr80.5%
Final simplification83.0%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(if (<= v 0.45500001311302185)
(/ (* cosTheta_O cosTheta_i) (* (pow v 2.0) (exp (reciprocal v))))
(/
(* cosTheta_O cosTheta_i)
(+
(* 0.016666666666666666 (pow (reciprocal v) 3.0))
(+ (* (/ 1.0 v) 0.3333333333333333) (* v 2.0))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 0.45500001311302185:\\
\;\;\;\;\frac{cosTheta_O \cdot cosTheta_i}{{v}^{2} \cdot e^{\mathsf{reciprocal}\left(v\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{cosTheta_O \cdot cosTheta_i}{0.016666666666666666 \cdot {\mathsf{reciprocal}\left(v\right)}^{3} + \left(\frac{1}{v} \cdot 0.3333333333333333 + v \cdot 2\right)}\\
\end{array}
\end{array}
if v < 0.455000013Initial program 98.2%
associate-*l*98.2%
*-commutative98.2%
times-frac98.2%
*-commutative98.2%
associate-*l/98.2%
reciprocal-define80.7%
exp-neg80.7%
1-exp80.7%
div080.7%
exp-diff80.7%
associate-/l*80.7%
div-sub80.7%
neg-sub080.7%
associate-/r/80.7%
*-commutative80.7%
Simplified80.7%
Taylor expanded in sinTheta_i around 0 98.3%
Taylor expanded in v around inf 78.5%
reciprocal-define78.5%
Simplified78.5%
Taylor expanded in v around 0 85.4%
reciprocal-define78.9%
Simplified78.9%
if 0.455000013 < v Initial program 98.9%
associate-*l*98.9%
*-commutative98.9%
times-frac99.2%
*-commutative99.2%
associate-*l/99.0%
reciprocal-define84.5%
exp-neg84.5%
1-exp84.5%
div084.5%
exp-diff84.5%
associate-/l*84.5%
div-sub84.5%
neg-sub084.5%
associate-/r/84.5%
*-commutative84.5%
Simplified84.5%
Taylor expanded in sinTheta_i around 0 99.0%
Taylor expanded in v around inf 80.5%
add-cube-cbrt80.5%
pow380.5%
cbrt-div80.5%
metadata-eval80.5%
rem-cbrt-cube80.5%
reciprocal-define80.5%
Applied egg-rr80.5%
Final simplification79.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (+ (+ (* (/ 1.0 v) 0.3333333333333333) (* v 2.0)) (* 0.016666666666666666 (reciprocal (pow v 3.0))))))
\begin{array}{l}
\\
\frac{cosTheta_O \cdot cosTheta_i}{\left(\frac{1}{v} \cdot 0.3333333333333333 + v \cdot 2\right) + 0.016666666666666666 \cdot \mathsf{reciprocal}\left(\left({v}^{3}\right)\right)}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in sinTheta_i around 0 98.7%
Taylor expanded in v around inf 71.7%
reciprocal-define71.7%
Applied egg-rr71.7%
Final simplification71.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (+ (* 0.016666666666666666 (pow (reciprocal v) 3.0)) (+ (* (/ 1.0 v) 0.3333333333333333) (* v 2.0)))))
\begin{array}{l}
\\
\frac{cosTheta_O \cdot cosTheta_i}{0.016666666666666666 \cdot {\mathsf{reciprocal}\left(v\right)}^{3} + \left(\frac{1}{v} \cdot 0.3333333333333333 + v \cdot 2\right)}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in sinTheta_i around 0 98.7%
Taylor expanded in v around inf 71.7%
add-cube-cbrt71.7%
pow371.7%
cbrt-div71.7%
metadata-eval71.7%
rem-cbrt-cube71.7%
reciprocal-define71.7%
Applied egg-rr71.7%
Final simplification71.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (+ (* 0.016666666666666666 (/ 1.0 (pow v 3.0))) (+ (* v 2.0) (/ 0.3333333333333333 v)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O * cosTheta_i) / ((0.016666666666666666f * (1.0f / powf(v, 3.0f))) + ((v * 2.0f) + (0.3333333333333333f / 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) / ((0.016666666666666666e0 * (1.0e0 / (v ** 3.0e0))) + ((v * 2.0e0) + (0.3333333333333333e0 / v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O * cosTheta_i) / Float32(Float32(Float32(0.016666666666666666) * Float32(Float32(1.0) / (v ^ Float32(3.0)))) + Float32(Float32(v * Float32(2.0)) + Float32(Float32(0.3333333333333333) / v)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (cosTheta_O * cosTheta_i) / ((single(0.016666666666666666) * (single(1.0) / (v ^ single(3.0)))) + ((v * single(2.0)) + (single(0.3333333333333333) / v))); end
\begin{array}{l}
\\
\frac{cosTheta_O \cdot cosTheta_i}{0.016666666666666666 \cdot \frac{1}{{v}^{3}} + \left(v \cdot 2 + \frac{0.3333333333333333}{v}\right)}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in sinTheta_i around 0 98.7%
Taylor expanded in v around inf 71.7%
Taylor expanded in v around 0 71.7%
Final simplification71.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (fma v 2.0 (/ 0.3333333333333333 v))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O * cosTheta_i) / fmaf(v, 2.0f, (0.3333333333333333f / v));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O * cosTheta_i) / fma(v, Float32(2.0), Float32(Float32(0.3333333333333333) / v))) end
\begin{array}{l}
\\
\frac{cosTheta_O \cdot cosTheta_i}{\mathsf{fma}\left(v, 2, \frac{0.3333333333333333}{v}\right)}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in sinTheta_i around 0 98.7%
Taylor expanded in v around inf 65.7%
*-commutative65.7%
fma-def65.7%
associate-*r/65.7%
metadata-eval65.7%
Simplified65.7%
Final simplification65.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (+ (* (/ 1.0 v) 0.3333333333333333) (* v 2.0))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O * cosTheta_i) / (((1.0f / v) * 0.3333333333333333f) + (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 = (costheta_o * costheta_i) / (((1.0e0 / v) * 0.3333333333333333e0) + (v * 2.0e0))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O * cosTheta_i) / Float32(Float32(Float32(Float32(1.0) / v) * Float32(0.3333333333333333)) + Float32(v * Float32(2.0)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (cosTheta_O * cosTheta_i) / (((single(1.0) / v) * single(0.3333333333333333)) + (v * single(2.0))); end
\begin{array}{l}
\\
\frac{cosTheta_O \cdot cosTheta_i}{\frac{1}{v} \cdot 0.3333333333333333 + v \cdot 2}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in sinTheta_i around 0 98.7%
Taylor expanded in v around inf 65.7%
Final simplification65.7%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* 0.5 (reciprocal (/ (/ v cosTheta_i) cosTheta_O))))
\begin{array}{l}
\\
0.5 \cdot \mathsf{reciprocal}\left(\left(\frac{\frac{v}{cosTheta_i}}{cosTheta_O}\right)\right)
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in v around inf 60.3%
associate-*l/60.3%
*-commutative60.3%
Simplified60.3%
clear-num60.3%
div-inv60.3%
clear-num60.3%
reciprocal-define60.3%
associate-/l/60.3%
associate-/r*60.3%
Applied egg-rr60.3%
Final simplification60.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (* cosTheta_i (/ cosTheta_O v)) 0.5))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_i * (cosTheta_O / v)) * 0.5f;
}
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_i * (costheta_o / v)) * 0.5e0
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_i * Float32(cosTheta_O / v)) * Float32(0.5)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (cosTheta_i * (cosTheta_O / v)) * single(0.5); end
\begin{array}{l}
\\
\left(cosTheta_i \cdot \frac{cosTheta_O}{v}\right) \cdot 0.5
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in v around inf 60.3%
associate-*l/60.3%
*-commutative60.3%
Simplified60.3%
Final simplification60.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* 0.5 (/ cosTheta_O (/ v cosTheta_i))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 0.5f * (cosTheta_O / (v / cosTheta_i));
}
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 * (costheta_o / (v / costheta_i))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(0.5) * Float32(cosTheta_O / Float32(v / cosTheta_i))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.5) * (cosTheta_O / (v / cosTheta_i)); end
\begin{array}{l}
\\
0.5 \cdot \frac{cosTheta_O}{\frac{v}{cosTheta_i}}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in v around inf 60.3%
associate-*l/60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in cosTheta_i around 0 60.3%
associate-/l*60.3%
Simplified60.3%
Final simplification60.3%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ 0.5 (/ (/ v cosTheta_i) cosTheta_O)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 0.5f / ((v / cosTheta_i) / cosTheta_O);
}
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 / costheta_i) / costheta_o)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(0.5) / Float32(Float32(v / cosTheta_i) / cosTheta_O)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.5) / ((v / cosTheta_i) / cosTheta_O); end
\begin{array}{l}
\\
\frac{0.5}{\frac{\frac{v}{cosTheta_i}}{cosTheta_O}}
\end{array}
Initial program 98.6%
associate-*l*98.6%
*-commutative98.6%
times-frac98.7%
*-commutative98.7%
associate-*l/98.6%
reciprocal-define82.6%
exp-neg82.6%
1-exp82.6%
div082.6%
exp-diff82.6%
associate-/l*82.6%
div-sub82.6%
neg-sub082.6%
associate-/r/82.6%
*-commutative82.6%
Simplified82.6%
Taylor expanded in v around inf 60.3%
associate-*l/60.3%
*-commutative60.3%
Simplified60.3%
clear-num60.3%
div-inv60.3%
clear-num60.3%
un-div-inv60.3%
associate-/l/60.3%
associate-/r*60.3%
Applied egg-rr60.3%
Final simplification60.3%
herbie shell --seed 2024024
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:name "HairBSDF, Mp, upper"
:precision binary32
:pre (and (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))) (< 0.1 v)) (<= v 1.5707964))
(/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))