
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((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))) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((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))) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (cos (* 6.28318530718 u2)) (pow (+ -1.0 (/ 1.0 u1)) -0.5)))
float code(float cosTheta_i, float u1, float u2) {
return cosf((6.28318530718f * u2)) * powf((-1.0f + (1.0f / 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 = cos((6.28318530718e0 * u2)) * (((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0))
end function
function code(cosTheta_i, u1, u2) return Float32(cos(Float32(Float32(6.28318530718) * u2)) * (Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5))) end
function tmp = code(cosTheta_i, u1, u2) tmp = cos((single(6.28318530718) * u2)) * ((single(-1.0) + (single(1.0) / u1)) ^ single(-0.5)); end
\begin{array}{l}
\\
\cos \left(6.28318530718 \cdot u2\right) \cdot {\left(-1 + \frac{1}{u1}\right)}^{-0.5}
\end{array}
Initial program 99.0%
add-sqr-sqrt99.0%
pow1/299.0%
pow1/299.0%
pow-prod-down99.0%
clear-num98.8%
clear-num98.8%
inv-pow98.8%
inv-pow98.8%
pow-prod-up98.7%
div-sub98.8%
inv-pow98.8%
pow198.8%
pow198.8%
pow-div98.8%
metadata-eval98.8%
metadata-eval98.8%
metadata-eval98.8%
Applied egg-rr98.8%
exp-to-pow96.5%
*-commutative96.5%
log-pow96.4%
associate-*r*96.4%
metadata-eval96.4%
mul-1-neg96.4%
rec-exp96.4%
rem-exp-log98.8%
unpow-198.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in u2 around inf 98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
unpow-198.8%
metadata-eval98.8%
pow-sqr99.0%
rem-sqrt-square99.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* 6.28318530718 u2))))
(if (<= t_0 0.9779999852180481)
(* t_0 (pow (/ 1.0 u1) -0.5))
(*
(pow (+ -1.0 (/ 1.0 u1)) -0.5)
(+ 1.0 (* -19.739208802181317 (* u2 u2)))))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((6.28318530718f * u2));
float tmp;
if (t_0 <= 0.9779999852180481f) {
tmp = t_0 * powf((1.0f / u1), -0.5f);
} else {
tmp = powf((-1.0f + (1.0f / u1)), -0.5f) * (1.0f + (-19.739208802181317f * (u2 * u2)));
}
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) :: t_0
real(4) :: tmp
t_0 = cos((6.28318530718e0 * u2))
if (t_0 <= 0.9779999852180481e0) then
tmp = t_0 * ((1.0e0 / u1) ** (-0.5e0))
else
tmp = (((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0)) * (1.0e0 + ((-19.739208802181317e0) * (u2 * u2)))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(Float32(6.28318530718) * u2)) tmp = Float32(0.0) if (t_0 <= Float32(0.9779999852180481)) tmp = Float32(t_0 * (Float32(Float32(1.0) / u1) ^ Float32(-0.5))); else tmp = Float32((Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5)) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * Float32(u2 * u2)))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((single(6.28318530718) * u2)); tmp = single(0.0); if (t_0 <= single(0.9779999852180481)) tmp = t_0 * ((single(1.0) / u1) ^ single(-0.5)); else tmp = ((single(-1.0) + (single(1.0) / u1)) ^ single(-0.5)) * (single(1.0) + (single(-19.739208802181317) * (u2 * u2))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(6.28318530718 \cdot u2\right)\\
\mathbf{if}\;t_0 \leq 0.9779999852180481:\\
\;\;\;\;t_0 \cdot {\left(\frac{1}{u1}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{\left(-1 + \frac{1}{u1}\right)}^{-0.5} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right)\\
\end{array}
\end{array}
if (cos.f32 (*.f32 314159265359/50000000000 u2)) < 0.977999985Initial program 96.8%
add-sqr-sqrt96.8%
pow1/296.8%
pow1/296.8%
pow-prod-down96.8%
clear-num96.7%
clear-num96.6%
inv-pow96.6%
inv-pow96.6%
pow-prod-up96.7%
div-sub96.6%
inv-pow96.6%
pow196.6%
pow196.6%
pow-div96.6%
metadata-eval96.6%
metadata-eval96.6%
metadata-eval96.6%
Applied egg-rr96.6%
exp-to-pow95.0%
*-commutative95.0%
log-pow94.9%
associate-*r*94.9%
metadata-eval94.9%
mul-1-neg94.9%
rec-exp95.0%
rem-exp-log96.4%
unpow-196.4%
sub-neg96.4%
metadata-eval96.4%
+-commutative96.4%
Simplified96.4%
Taylor expanded in u2 around inf 96.4%
sub-neg96.4%
metadata-eval96.4%
+-commutative96.4%
unpow-196.4%
metadata-eval96.4%
pow-sqr97.0%
rem-sqrt-square97.0%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt97.0%
Simplified97.0%
Taylor expanded in u1 around 0 79.2%
if 0.977999985 < (cos.f32 (*.f32 314159265359/50000000000 u2)) Initial program 99.4%
add-sqr-sqrt99.4%
pow1/299.4%
pow1/299.4%
pow-prod-down99.4%
clear-num99.2%
clear-num99.3%
inv-pow99.3%
inv-pow99.3%
pow-prod-up99.1%
div-sub99.2%
inv-pow99.2%
pow199.2%
pow199.2%
pow-div99.2%
metadata-eval99.2%
metadata-eval99.2%
metadata-eval99.2%
Applied egg-rr99.2%
exp-to-pow96.7%
*-commutative96.7%
log-pow96.7%
associate-*r*96.7%
metadata-eval96.7%
mul-1-neg96.7%
rec-exp96.7%
rem-exp-log99.3%
unpow-199.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in u2 around 0 97.1%
associate-*r*97.1%
distribute-rgt1-in97.1%
unpow297.1%
sub-neg97.1%
metadata-eval97.1%
+-commutative97.1%
unpow-197.1%
metadata-eval97.1%
pow-sqr97.2%
rem-sqrt-square97.2%
rem-square-sqrt96.2%
fabs-sqr96.2%
rem-square-sqrt97.2%
Simplified97.2%
Final simplification94.3%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* 6.28318530718 u2))))
(if (<= t_0 0.9779999852180481)
(* t_0 (sqrt u1))
(*
(pow (+ -1.0 (/ 1.0 u1)) -0.5)
(+ 1.0 (* -19.739208802181317 (* u2 u2)))))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((6.28318530718f * u2));
float tmp;
if (t_0 <= 0.9779999852180481f) {
tmp = t_0 * sqrtf(u1);
} else {
tmp = powf((-1.0f + (1.0f / u1)), -0.5f) * (1.0f + (-19.739208802181317f * (u2 * u2)));
}
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) :: t_0
real(4) :: tmp
t_0 = cos((6.28318530718e0 * u2))
if (t_0 <= 0.9779999852180481e0) then
tmp = t_0 * sqrt(u1)
else
tmp = (((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0)) * (1.0e0 + ((-19.739208802181317e0) * (u2 * u2)))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(Float32(6.28318530718) * u2)) tmp = Float32(0.0) if (t_0 <= Float32(0.9779999852180481)) tmp = Float32(t_0 * sqrt(u1)); else tmp = Float32((Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5)) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * Float32(u2 * u2)))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((single(6.28318530718) * u2)); tmp = single(0.0); if (t_0 <= single(0.9779999852180481)) tmp = t_0 * sqrt(u1); else tmp = ((single(-1.0) + (single(1.0) / u1)) ^ single(-0.5)) * (single(1.0) + (single(-19.739208802181317) * (u2 * u2))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(6.28318530718 \cdot u2\right)\\
\mathbf{if}\;t_0 \leq 0.9779999852180481:\\
\;\;\;\;t_0 \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;{\left(-1 + \frac{1}{u1}\right)}^{-0.5} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right)\\
\end{array}
\end{array}
if (cos.f32 (*.f32 314159265359/50000000000 u2)) < 0.977999985Initial program 96.8%
Taylor expanded in u1 around 0 79.2%
if 0.977999985 < (cos.f32 (*.f32 314159265359/50000000000 u2)) Initial program 99.4%
add-sqr-sqrt99.4%
pow1/299.4%
pow1/299.4%
pow-prod-down99.4%
clear-num99.2%
clear-num99.3%
inv-pow99.3%
inv-pow99.3%
pow-prod-up99.1%
div-sub99.2%
inv-pow99.2%
pow199.2%
pow199.2%
pow-div99.2%
metadata-eval99.2%
metadata-eval99.2%
metadata-eval99.2%
Applied egg-rr99.2%
exp-to-pow96.7%
*-commutative96.7%
log-pow96.7%
associate-*r*96.7%
metadata-eval96.7%
mul-1-neg96.7%
rec-exp96.7%
rem-exp-log99.3%
unpow-199.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in u2 around 0 97.1%
associate-*r*97.1%
distribute-rgt1-in97.1%
unpow297.1%
sub-neg97.1%
metadata-eval97.1%
+-commutative97.1%
unpow-197.1%
metadata-eval97.1%
pow-sqr97.2%
rem-sqrt-square97.2%
rem-square-sqrt96.2%
fabs-sqr96.2%
rem-square-sqrt97.2%
Simplified97.2%
Final simplification94.3%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (cos (* 6.28318530718 u2)) (sqrt (/ u1 (- 1.0 u1)))))
float code(float cosTheta_i, float u1, float u2) {
return cosf((6.28318530718f * u2)) * sqrtf((u1 / (1.0f - 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 = cos((6.28318530718e0 * u2)) * sqrt((u1 / (1.0e0 - u1)))
end function
function code(cosTheta_i, u1, u2) return Float32(cos(Float32(Float32(6.28318530718) * u2)) * sqrt(Float32(u1 / Float32(Float32(1.0) - u1)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = cos((single(6.28318530718) * u2)) * sqrt((u1 / (single(1.0) - u1))); end
\begin{array}{l}
\\
\cos \left(6.28318530718 \cdot u2\right) \cdot \sqrt{\frac{u1}{1 - u1}}
\end{array}
Initial program 99.0%
Final simplification99.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (pow (+ -1.0 (/ 1.0 u1)) -0.5) (+ 1.0 (* -19.739208802181317 (* u2 u2)))))
float code(float cosTheta_i, float u1, float u2) {
return powf((-1.0f + (1.0f / u1)), -0.5f) * (1.0f + (-19.739208802181317f * (u2 * 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 = (((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0)) * (1.0e0 + ((-19.739208802181317e0) * (u2 * u2)))
end function
function code(cosTheta_i, u1, u2) return Float32((Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5)) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * Float32(u2 * u2)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = ((single(-1.0) + (single(1.0) / u1)) ^ single(-0.5)) * (single(1.0) + (single(-19.739208802181317) * (u2 * u2))); end
\begin{array}{l}
\\
{\left(-1 + \frac{1}{u1}\right)}^{-0.5} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right)
\end{array}
Initial program 99.0%
add-sqr-sqrt99.0%
pow1/299.0%
pow1/299.0%
pow-prod-down99.0%
clear-num98.8%
clear-num98.8%
inv-pow98.8%
inv-pow98.8%
pow-prod-up98.7%
div-sub98.8%
inv-pow98.8%
pow198.8%
pow198.8%
pow-div98.8%
metadata-eval98.8%
metadata-eval98.8%
metadata-eval98.8%
Applied egg-rr98.8%
exp-to-pow96.5%
*-commutative96.5%
log-pow96.4%
associate-*r*96.4%
metadata-eval96.4%
mul-1-neg96.4%
rec-exp96.4%
rem-exp-log98.8%
unpow-198.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in u2 around 0 87.8%
associate-*r*87.8%
distribute-rgt1-in87.8%
unpow287.8%
sub-neg87.8%
metadata-eval87.8%
+-commutative87.8%
unpow-187.8%
metadata-eval87.8%
pow-sqr87.9%
rem-sqrt-square87.9%
rem-square-sqrt87.1%
fabs-sqr87.1%
rem-square-sqrt87.9%
Simplified87.9%
Final simplification87.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (+ 1.0 (* -19.739208802181317 (* u2 u2)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * (1.0f + (-19.739208802181317f * (u2 * 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))) * (1.0e0 + ((-19.739208802181317e0) * (u2 * u2)))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * Float32(u2 * u2)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * (single(1.0) + (single(-19.739208802181317) * (u2 * u2))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0 87.8%
unpow267.8%
Simplified87.8%
Final simplification87.8%
(FPCore (cosTheta_i u1 u2) :precision binary32 (if (<= u2 0.0008999999845400453) (pow (+ -1.0 (/ 1.0 u1)) -0.5) (* (sqrt u1) (+ 1.0 (* -19.739208802181317 (* u2 u2))))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.0008999999845400453f) {
tmp = powf((-1.0f + (1.0f / u1)), -0.5f);
} else {
tmp = sqrtf(u1) * (1.0f + (-19.739208802181317f * (u2 * u2)));
}
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 <= 0.0008999999845400453e0) then
tmp = ((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0)
else
tmp = sqrt(u1) * (1.0e0 + ((-19.739208802181317e0) * (u2 * u2)))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.0008999999845400453)) tmp = Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5); else tmp = Float32(sqrt(u1) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * Float32(u2 * u2)))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) tmp = single(0.0); if (u2 <= single(0.0008999999845400453)) tmp = (single(-1.0) + (single(1.0) / u1)) ^ single(-0.5); else tmp = sqrt(u1) * (single(1.0) + (single(-19.739208802181317) * (u2 * u2))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.0008999999845400453:\\
\;\;\;\;{\left(-1 + \frac{1}{u1}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{u1} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right)\\
\end{array}
\end{array}
if u2 < 8.99999985e-4Initial program 99.5%
add-sqr-sqrt99.5%
pow1/299.5%
pow1/299.5%
pow-prod-down99.5%
clear-num99.3%
clear-num99.4%
inv-pow99.4%
inv-pow99.4%
pow-prod-up99.2%
div-sub99.3%
inv-pow99.3%
pow199.3%
pow199.3%
pow-div99.3%
metadata-eval99.3%
metadata-eval99.3%
metadata-eval99.3%
Applied egg-rr99.3%
exp-to-pow96.9%
*-commutative96.9%
log-pow96.8%
associate-*r*96.8%
metadata-eval96.8%
mul-1-neg96.8%
rec-exp96.8%
rem-exp-log99.4%
unpow-199.4%
sub-neg99.4%
metadata-eval99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in u2 around 0 97.5%
sub-neg97.5%
metadata-eval97.5%
+-commutative97.5%
unpow-197.5%
metadata-eval97.5%
pow-sqr97.5%
rem-sqrt-square97.5%
rem-square-sqrt96.6%
fabs-sqr96.6%
rem-square-sqrt97.5%
Simplified97.5%
if 8.99999985e-4 < u2 Initial program 98.0%
Taylor expanded in u1 around 0 77.5%
Taylor expanded in u2 around 0 57.6%
unpow257.6%
Simplified57.6%
Final simplification83.5%
(FPCore (cosTheta_i u1 u2) :precision binary32 (pow (+ -1.0 (/ 1.0 u1)) -0.5))
float code(float cosTheta_i, float u1, float u2) {
return powf((-1.0f + (1.0f / 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 = ((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0)
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5) end
function tmp = code(cosTheta_i, u1, u2) tmp = (single(-1.0) + (single(1.0) / u1)) ^ single(-0.5); end
\begin{array}{l}
\\
{\left(-1 + \frac{1}{u1}\right)}^{-0.5}
\end{array}
Initial program 99.0%
add-sqr-sqrt99.0%
pow1/299.0%
pow1/299.0%
pow-prod-down99.0%
clear-num98.8%
clear-num98.8%
inv-pow98.8%
inv-pow98.8%
pow-prod-up98.7%
div-sub98.8%
inv-pow98.8%
pow198.8%
pow198.8%
pow-div98.8%
metadata-eval98.8%
metadata-eval98.8%
metadata-eval98.8%
Applied egg-rr98.8%
exp-to-pow96.5%
*-commutative96.5%
log-pow96.4%
associate-*r*96.4%
metadata-eval96.4%
mul-1-neg96.4%
rec-exp96.4%
rem-exp-log98.8%
unpow-198.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in u2 around 0 78.4%
sub-neg78.4%
metadata-eval78.4%
+-commutative78.4%
unpow-178.3%
metadata-eval78.3%
pow-sqr78.4%
rem-sqrt-square78.4%
rem-square-sqrt77.8%
fabs-sqr77.8%
rem-square-sqrt78.4%
Simplified78.4%
Final simplification78.4%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt (/ u1 (- 1.0 u1))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - 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 = sqrt((u1 / (1.0e0 - u1)))
end function
function code(cosTheta_i, u1, u2) return sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}}
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0 78.4%
Final simplification78.4%
(FPCore (cosTheta_i u1 u2) :precision binary32 (pow (/ 1.0 u1) -0.5))
float code(float cosTheta_i, float u1, float u2) {
return powf((1.0f / 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 = (1.0e0 / u1) ** (-0.5e0)
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(1.0) / u1) ^ Float32(-0.5) end
function tmp = code(cosTheta_i, u1, u2) tmp = (single(1.0) / u1) ^ single(-0.5); end
\begin{array}{l}
\\
{\left(\frac{1}{u1}\right)}^{-0.5}
\end{array}
Initial program 99.0%
add-sqr-sqrt99.0%
pow1/299.0%
pow1/299.0%
pow-prod-down99.0%
clear-num98.8%
clear-num98.8%
inv-pow98.8%
inv-pow98.8%
pow-prod-up98.7%
div-sub98.8%
inv-pow98.8%
pow198.8%
pow198.8%
pow-div98.8%
metadata-eval98.8%
metadata-eval98.8%
metadata-eval98.8%
Applied egg-rr98.8%
exp-to-pow96.5%
*-commutative96.5%
log-pow96.4%
associate-*r*96.4%
metadata-eval96.4%
mul-1-neg96.4%
rec-exp96.4%
rem-exp-log98.8%
unpow-198.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in u2 around 0 78.4%
sub-neg78.4%
metadata-eval78.4%
+-commutative78.4%
unpow-178.3%
metadata-eval78.3%
pow-sqr78.4%
rem-sqrt-square78.4%
rem-square-sqrt77.8%
fabs-sqr77.8%
rem-square-sqrt78.4%
Simplified78.4%
Taylor expanded in u1 around 0 61.8%
Final simplification61.8%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt u1))
float code(float cosTheta_i, float u1, float u2) {
return 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 = sqrt(u1)
end function
function code(cosTheta_i, u1, u2) return sqrt(u1) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt(u1); end
\begin{array}{l}
\\
\sqrt{u1}
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0 78.4%
Taylor expanded in u1 around 0 61.8%
Final simplification61.8%
herbie shell --seed 2023282
(FPCore (cosTheta_i u1 u2)
:name "Trowbridge-Reitz Sample, near normal, slope_x"
: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))) (cos (* 6.28318530718 u2))))