
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * sinf((6.28318530718f * u2));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * sin((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * sin((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right)
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * sinf((6.28318530718f * u2));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * sin((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * sin((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right)
\end{array}
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (sin (sqrt (* (pow u2 2.0) 39.47841760436263)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * sinf(sqrtf((powf(u2, 2.0f) * 39.47841760436263f)));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * sin(sqrt(((u2 ** 2.0e0) * 39.47841760436263e0)))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(sqrt(Float32((u2 ^ Float32(2.0)) * Float32(39.47841760436263))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * sin(sqrt(((u2 ^ single(2.0)) * single(39.47841760436263)))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(\sqrt{{u2}^{2} \cdot 39.47841760436263}\right)
\end{array}
Initial program 98.5%
add-sqr-sqrt97.6%
sqrt-unprod98.5%
*-commutative98.5%
*-commutative98.5%
swap-sqr98.2%
pow298.2%
metadata-eval98.5%
Applied egg-rr98.5%
(FPCore (cosTheta_i u1 u2) :precision binary32 (if (<= (* u2 6.28318530718) 0.000859999970998615) (sqrt (* 39.47841760436263 (* u2 (* (/ u1 (- 1.0 u1)) u2)))) (* (sin (* u2 6.28318530718)) (sqrt (* u1 (+ u1 1.0))))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if ((u2 * 6.28318530718f) <= 0.000859999970998615f) {
tmp = sqrtf((39.47841760436263f * (u2 * ((u1 / (1.0f - u1)) * u2))));
} else {
tmp = sinf((u2 * 6.28318530718f)) * sqrtf((u1 * (u1 + 1.0f)));
}
return tmp;
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
real(4) :: tmp
if ((u2 * 6.28318530718e0) <= 0.000859999970998615e0) then
tmp = sqrt((39.47841760436263e0 * (u2 * ((u1 / (1.0e0 - u1)) * u2))))
else
tmp = sin((u2 * 6.28318530718e0)) * sqrt((u1 * (u1 + 1.0e0)))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (Float32(u2 * Float32(6.28318530718)) <= Float32(0.000859999970998615)) tmp = sqrt(Float32(Float32(39.47841760436263) * Float32(u2 * Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * u2)))); else tmp = Float32(sin(Float32(u2 * Float32(6.28318530718))) * sqrt(Float32(u1 * Float32(u1 + Float32(1.0))))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) tmp = single(0.0); if ((u2 * single(6.28318530718)) <= single(0.000859999970998615)) tmp = sqrt((single(39.47841760436263) * (u2 * ((u1 / (single(1.0) - u1)) * u2)))); else tmp = sin((u2 * single(6.28318530718))) * sqrt((u1 * (u1 + single(1.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \cdot 6.28318530718 \leq 0.000859999970998615:\\
\;\;\;\;\sqrt{39.47841760436263 \cdot \left(u2 \cdot \left(\frac{u1}{1 - u1} \cdot u2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(u2 \cdot 6.28318530718\right) \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\\
\end{array}
\end{array}
if (*.f32 #s(literal 314159265359/50000000000 binary32) u2) < 8.59999971e-4Initial program 98.6%
Taylor expanded in u2 around 0 98.3%
clear-num98.4%
sqrt-div98.2%
metadata-eval98.2%
Applied egg-rr98.2%
add-sqr-sqrt97.5%
sqrt-unprod98.2%
*-commutative98.2%
*-commutative98.2%
swap-sqr98.1%
Applied egg-rr98.9%
div-inv98.8%
unpow298.8%
associate-*l*98.8%
metadata-eval98.8%
sub-neg98.8%
*-inverses98.8%
div-sub98.9%
clear-num99.0%
Applied egg-rr99.0%
if 8.59999971e-4 < (*.f32 #s(literal 314159265359/50000000000 binary32) u2) Initial program 98.2%
Taylor expanded in u1 around 0 89.7%
+-commutative89.7%
Simplified89.7%
Final simplification95.3%
(FPCore (cosTheta_i u1 u2) :precision binary32 (if (<= (* u2 6.28318530718) 0.019999999552965164) (sqrt (* 39.47841760436263 (* u2 (* (/ u1 (- 1.0 u1)) u2)))) (/ (sin (* u2 6.28318530718)) (sqrt (/ 1.0 u1)))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if ((u2 * 6.28318530718f) <= 0.019999999552965164f) {
tmp = sqrtf((39.47841760436263f * (u2 * ((u1 / (1.0f - u1)) * u2))));
} else {
tmp = sinf((u2 * 6.28318530718f)) / sqrtf((1.0f / u1));
}
return tmp;
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
real(4) :: tmp
if ((u2 * 6.28318530718e0) <= 0.019999999552965164e0) then
tmp = sqrt((39.47841760436263e0 * (u2 * ((u1 / (1.0e0 - u1)) * u2))))
else
tmp = sin((u2 * 6.28318530718e0)) / sqrt((1.0e0 / u1))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (Float32(u2 * Float32(6.28318530718)) <= Float32(0.019999999552965164)) tmp = sqrt(Float32(Float32(39.47841760436263) * Float32(u2 * Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * u2)))); else tmp = Float32(sin(Float32(u2 * Float32(6.28318530718))) / sqrt(Float32(Float32(1.0) / u1))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) tmp = single(0.0); if ((u2 * single(6.28318530718)) <= single(0.019999999552965164)) tmp = sqrt((single(39.47841760436263) * (u2 * ((u1 / (single(1.0) - u1)) * u2)))); else tmp = sin((u2 * single(6.28318530718))) / sqrt((single(1.0) / u1)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \cdot 6.28318530718 \leq 0.019999999552965164:\\
\;\;\;\;\sqrt{39.47841760436263 \cdot \left(u2 \cdot \left(\frac{u1}{1 - u1} \cdot u2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin \left(u2 \cdot 6.28318530718\right)}{\sqrt{\frac{1}{u1}}}\\
\end{array}
\end{array}
if (*.f32 #s(literal 314159265359/50000000000 binary32) u2) < 0.0199999996Initial program 98.6%
Taylor expanded in u2 around 0 95.5%
clear-num95.5%
sqrt-div95.4%
metadata-eval95.4%
Applied egg-rr95.4%
add-sqr-sqrt94.8%
sqrt-unprod95.4%
*-commutative95.4%
*-commutative95.4%
swap-sqr95.3%
Applied egg-rr95.9%
div-inv95.9%
unpow295.9%
associate-*l*95.9%
metadata-eval95.9%
sub-neg95.9%
*-inverses95.9%
div-sub95.9%
clear-num96.0%
Applied egg-rr96.0%
if 0.0199999996 < (*.f32 #s(literal 314159265359/50000000000 binary32) u2) Initial program 98.1%
add-sqr-sqrt97.0%
sqrt-unprod98.1%
*-commutative98.1%
*-commutative98.1%
swap-sqr97.6%
pow297.6%
metadata-eval98.0%
Applied egg-rr98.0%
*-commutative98.0%
*-commutative98.0%
sqrt-prod97.4%
metadata-eval98.1%
sqrt-pow198.1%
metadata-eval98.1%
pow198.1%
sqrt-div97.8%
clear-num97.5%
div-inv97.9%
*-commutative97.9%
sqrt-undiv98.3%
div-sub98.2%
*-inverses98.2%
sub-neg98.2%
metadata-eval98.2%
Applied egg-rr98.2%
Taylor expanded in u1 around 0 80.2%
Final simplification91.8%
(FPCore (cosTheta_i u1 u2) :precision binary32 (if (<= (* u2 6.28318530718) 0.019999999552965164) (sqrt (* 39.47841760436263 (* u2 (* (/ u1 (- 1.0 u1)) u2)))) (* (sin (* u2 6.28318530718)) (sqrt u1))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if ((u2 * 6.28318530718f) <= 0.019999999552965164f) {
tmp = sqrtf((39.47841760436263f * (u2 * ((u1 / (1.0f - u1)) * u2))));
} else {
tmp = sinf((u2 * 6.28318530718f)) * sqrtf(u1);
}
return tmp;
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
real(4) :: tmp
if ((u2 * 6.28318530718e0) <= 0.019999999552965164e0) then
tmp = sqrt((39.47841760436263e0 * (u2 * ((u1 / (1.0e0 - u1)) * u2))))
else
tmp = sin((u2 * 6.28318530718e0)) * sqrt(u1)
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (Float32(u2 * Float32(6.28318530718)) <= Float32(0.019999999552965164)) tmp = sqrt(Float32(Float32(39.47841760436263) * Float32(u2 * Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * u2)))); else tmp = Float32(sin(Float32(u2 * Float32(6.28318530718))) * sqrt(u1)); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) tmp = single(0.0); if ((u2 * single(6.28318530718)) <= single(0.019999999552965164)) tmp = sqrt((single(39.47841760436263) * (u2 * ((u1 / (single(1.0) - u1)) * u2)))); else tmp = sin((u2 * single(6.28318530718))) * sqrt(u1); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \cdot 6.28318530718 \leq 0.019999999552965164:\\
\;\;\;\;\sqrt{39.47841760436263 \cdot \left(u2 \cdot \left(\frac{u1}{1 - u1} \cdot u2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(u2 \cdot 6.28318530718\right) \cdot \sqrt{u1}\\
\end{array}
\end{array}
if (*.f32 #s(literal 314159265359/50000000000 binary32) u2) < 0.0199999996Initial program 98.6%
Taylor expanded in u2 around 0 95.5%
clear-num95.5%
sqrt-div95.4%
metadata-eval95.4%
Applied egg-rr95.4%
add-sqr-sqrt94.8%
sqrt-unprod95.4%
*-commutative95.4%
*-commutative95.4%
swap-sqr95.3%
Applied egg-rr95.9%
div-inv95.9%
unpow295.9%
associate-*l*95.9%
metadata-eval95.9%
sub-neg95.9%
*-inverses95.9%
div-sub95.9%
clear-num96.0%
Applied egg-rr96.0%
if 0.0199999996 < (*.f32 #s(literal 314159265359/50000000000 binary32) u2) Initial program 98.1%
Taylor expanded in u1 around 0 79.9%
Final simplification91.7%
(FPCore (cosTheta_i u1 u2) :precision binary32 (/ (sin (* u2 6.28318530718)) (sqrt (/ (- 1.0 u1) u1))))
float code(float cosTheta_i, float u1, float u2) {
return sinf((u2 * 6.28318530718f)) / sqrtf(((1.0f - u1) / u1));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sin((u2 * 6.28318530718e0)) / sqrt(((1.0e0 - u1) / u1))
end function
function code(cosTheta_i, u1, u2) return Float32(sin(Float32(u2 * Float32(6.28318530718))) / sqrt(Float32(Float32(Float32(1.0) - u1) / u1))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sin((u2 * single(6.28318530718))) / sqrt(((single(1.0) - u1) / u1)); end
\begin{array}{l}
\\
\frac{\sin \left(u2 \cdot 6.28318530718\right)}{\sqrt{\frac{1 - u1}{u1}}}
\end{array}
Initial program 98.5%
add-sqr-sqrt97.6%
sqrt-unprod98.5%
*-commutative98.5%
*-commutative98.5%
swap-sqr98.2%
pow298.2%
metadata-eval98.5%
Applied egg-rr98.5%
*-commutative98.5%
*-commutative98.5%
sqrt-prod97.9%
metadata-eval98.5%
sqrt-pow198.5%
metadata-eval98.5%
pow198.5%
sqrt-div98.2%
clear-num98.1%
div-inv98.2%
*-commutative98.2%
sqrt-undiv98.5%
div-sub98.4%
*-inverses98.4%
sub-neg98.4%
metadata-eval98.4%
Applied egg-rr98.4%
Taylor expanded in u1 around 0 98.5%
neg-mul-198.5%
sub-neg98.5%
Simplified98.5%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (sin (* u2 6.28318530718))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * sinf((u2 * 6.28318530718f));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * sin((u2 * 6.28318530718e0))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(Float32(u2 * Float32(6.28318530718)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * sin((u2 * single(6.28318530718))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(u2 \cdot 6.28318530718\right)
\end{array}
Initial program 98.5%
Final simplification98.5%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt (* 39.47841760436263 (* u2 (* (/ u1 (- 1.0 u1)) u2)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((39.47841760436263f * (u2 * ((u1 / (1.0f - u1)) * u2))));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((39.47841760436263e0 * (u2 * ((u1 / (1.0e0 - u1)) * u2))))
end function
function code(cosTheta_i, u1, u2) return sqrt(Float32(Float32(39.47841760436263) * Float32(u2 * Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * u2)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((single(39.47841760436263) * (u2 * ((u1 / (single(1.0) - u1)) * u2)))); end
\begin{array}{l}
\\
\sqrt{39.47841760436263 \cdot \left(u2 \cdot \left(\frac{u1}{1 - u1} \cdot u2\right)\right)}
\end{array}
Initial program 98.5%
Taylor expanded in u2 around 0 80.9%
clear-num80.9%
sqrt-div80.8%
metadata-eval80.8%
Applied egg-rr80.8%
add-sqr-sqrt80.4%
sqrt-unprod80.8%
*-commutative80.8%
*-commutative80.8%
swap-sqr80.7%
Applied egg-rr81.2%
div-inv81.1%
unpow281.1%
associate-*l*81.1%
metadata-eval81.1%
sub-neg81.1%
*-inverses81.1%
div-sub81.2%
clear-num81.2%
Applied egg-rr81.2%
Final simplification81.2%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (* u2 6.28318530718)))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * (u2 * 6.28318530718f);
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * (u2 * 6.28318530718e0)
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * Float32(u2 * Float32(6.28318530718))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * (u2 * single(6.28318530718)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \left(u2 \cdot 6.28318530718\right)
\end{array}
Initial program 98.5%
Taylor expanded in u2 around 0 80.9%
Final simplification80.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* 6.28318530718 (* (sqrt (/ u1 (- 1.0 u1))) u2)))
float code(float cosTheta_i, float u1, float u2) {
return 6.28318530718f * (sqrtf((u1 / (1.0f - u1))) * u2);
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = 6.28318530718e0 * (sqrt((u1 / (1.0e0 - u1))) * u2)
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(6.28318530718) * Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * u2)) end
function tmp = code(cosTheta_i, u1, u2) tmp = single(6.28318530718) * (sqrt((u1 / (single(1.0) - u1))) * u2); end
\begin{array}{l}
\\
6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)
\end{array}
Initial program 98.5%
Taylor expanded in u2 around 0 80.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* 6.28318530718 (* u2 (sqrt (* u1 (+ u1 1.0))))))
float code(float cosTheta_i, float u1, float u2) {
return 6.28318530718f * (u2 * sqrtf((u1 * (u1 + 1.0f))));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = 6.28318530718e0 * (u2 * sqrt((u1 * (u1 + 1.0e0))))
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(6.28318530718) * Float32(u2 * sqrt(Float32(u1 * Float32(u1 + Float32(1.0)))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = single(6.28318530718) * (u2 * sqrt((u1 * (u1 + single(1.0))))); end
\begin{array}{l}
\\
6.28318530718 \cdot \left(u2 \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\right)
\end{array}
Initial program 98.5%
Taylor expanded in u2 around 0 80.9%
Taylor expanded in u1 around 0 74.0%
+-commutative88.3%
Simplified74.0%
Final simplification74.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* 6.28318530718 (* u2 (/ 1.0 (pow u1 -0.5)))))
float code(float cosTheta_i, float u1, float u2) {
return 6.28318530718f * (u2 * (1.0f / powf(u1, -0.5f)));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = 6.28318530718e0 * (u2 * (1.0e0 / (u1 ** (-0.5e0))))
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(6.28318530718) * Float32(u2 * Float32(Float32(1.0) / (u1 ^ Float32(-0.5))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = single(6.28318530718) * (u2 * (single(1.0) / (u1 ^ single(-0.5)))); end
\begin{array}{l}
\\
6.28318530718 \cdot \left(u2 \cdot \frac{1}{{u1}^{-0.5}}\right)
\end{array}
Initial program 98.5%
Taylor expanded in u2 around 0 80.9%
Taylor expanded in u1 around 0 64.6%
pow1/264.6%
metadata-eval64.6%
pow-flip64.7%
Applied egg-rr64.7%
Final simplification64.7%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* 6.28318530718 (* u2 (sqrt u1))))
float code(float cosTheta_i, float u1, float u2) {
return 6.28318530718f * (u2 * sqrtf(u1));
}
real(4) function code(costheta_i, u1, u2)
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = 6.28318530718e0 * (u2 * sqrt(u1))
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(6.28318530718) * Float32(u2 * sqrt(u1))) end
function tmp = code(cosTheta_i, u1, u2) tmp = single(6.28318530718) * (u2 * sqrt(u1)); end
\begin{array}{l}
\\
6.28318530718 \cdot \left(u2 \cdot \sqrt{u1}\right)
\end{array}
Initial program 98.5%
Taylor expanded in u2 around 0 80.9%
Taylor expanded in u1 around 0 64.6%
Final simplification64.6%
herbie shell --seed 2024146
(FPCore (cosTheta_i u1 u2)
:name "Trowbridge-Reitz Sample, near normal, slope_y"
:precision binary32
:pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
(* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))