
(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 13 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 (* (sqrt (/ u1 (- 1.0 u1))) (cos (sqrt (* (pow u2 2.0) 39.47841760436263)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf(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))) * cos(sqrt(((u2 ** 2.0e0) * 39.47841760436263e0)))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(sqrt(Float32((u2 ^ Float32(2.0)) * Float32(39.47841760436263))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos(sqrt(((u2 ^ single(2.0)) * single(39.47841760436263)))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(\sqrt{{u2}^{2} \cdot 39.47841760436263}\right)
\end{array}
Initial program 98.9%
add-sqr-sqrt98.9%
sqrt-unprod98.9%
*-commutative98.9%
*-commutative98.9%
swap-sqr98.9%
pow298.9%
metadata-eval99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* u2 6.28318530718))))
(if (<= t_0 0.9999499917030334)
(* t_0 (sqrt u1))
(* (sqrt u1) (sqrt (/ 1.0 (- 1.0 u1)))))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((u2 * 6.28318530718f));
float tmp;
if (t_0 <= 0.9999499917030334f) {
tmp = t_0 * sqrtf(u1);
} else {
tmp = sqrtf(u1) * sqrtf((1.0f / (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) :: t_0
real(4) :: tmp
t_0 = cos((u2 * 6.28318530718e0))
if (t_0 <= 0.9999499917030334e0) then
tmp = t_0 * sqrt(u1)
else
tmp = sqrt(u1) * sqrt((1.0e0 / (1.0e0 - u1)))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(u2 * Float32(6.28318530718))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999499917030334)) tmp = Float32(t_0 * sqrt(u1)); else tmp = Float32(sqrt(u1) * sqrt(Float32(Float32(1.0) / Float32(Float32(1.0) - u1)))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((u2 * single(6.28318530718))); tmp = single(0.0); if (t_0 <= single(0.9999499917030334)) tmp = t_0 * sqrt(u1); else tmp = sqrt(u1) * sqrt((single(1.0) / (single(1.0) - u1))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(u2 \cdot 6.28318530718\right)\\
\mathbf{if}\;t\_0 \leq 0.9999499917030334:\\
\;\;\;\;t\_0 \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{u1} \cdot \sqrt{\frac{1}{1 - u1}}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.999949992Initial program 97.9%
Taylor expanded in u1 around 0 73.7%
if 0.999949992 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.4%
Taylor expanded in u2 around 0 96.5%
pow1/296.5%
div-inv96.2%
unpow-prod-down96.0%
pow1/296.0%
Applied egg-rr96.0%
unpow1/296.0%
Simplified96.0%
Final simplification89.1%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* u2 6.28318530718))))
(if (<= t_0 0.9999499917030334)
(* t_0 (sqrt u1))
(/ 1.0 (/ (sqrt (- 1.0 u1)) (sqrt u1))))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((u2 * 6.28318530718f));
float tmp;
if (t_0 <= 0.9999499917030334f) {
tmp = t_0 * sqrtf(u1);
} else {
tmp = 1.0f / (sqrtf((1.0f - u1)) / 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) :: t_0
real(4) :: tmp
t_0 = cos((u2 * 6.28318530718e0))
if (t_0 <= 0.9999499917030334e0) then
tmp = t_0 * sqrt(u1)
else
tmp = 1.0e0 / (sqrt((1.0e0 - u1)) / sqrt(u1))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(u2 * Float32(6.28318530718))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999499917030334)) tmp = Float32(t_0 * sqrt(u1)); else tmp = Float32(Float32(1.0) / Float32(sqrt(Float32(Float32(1.0) - u1)) / sqrt(u1))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((u2 * single(6.28318530718))); tmp = single(0.0); if (t_0 <= single(0.9999499917030334)) tmp = t_0 * sqrt(u1); else tmp = single(1.0) / (sqrt((single(1.0) - u1)) / sqrt(u1)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(u2 \cdot 6.28318530718\right)\\
\mathbf{if}\;t\_0 \leq 0.9999499917030334:\\
\;\;\;\;t\_0 \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{1 - u1}}{\sqrt{u1}}}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.999949992Initial program 97.9%
Taylor expanded in u1 around 0 73.7%
if 0.999949992 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.4%
Taylor expanded in u2 around 0 96.5%
sqrt-div96.0%
clear-num95.7%
Applied egg-rr95.7%
Final simplification88.9%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* u2 6.28318530718))))
(if (<= t_0 0.9999499917030334)
(* t_0 (sqrt u1))
(pow (pow (/ u1 (- 1.0 u1)) 0.16666666666666666) 3.0))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((u2 * 6.28318530718f));
float tmp;
if (t_0 <= 0.9999499917030334f) {
tmp = t_0 * sqrtf(u1);
} else {
tmp = powf(powf((u1 / (1.0f - u1)), 0.16666666666666666f), 3.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) :: t_0
real(4) :: tmp
t_0 = cos((u2 * 6.28318530718e0))
if (t_0 <= 0.9999499917030334e0) then
tmp = t_0 * sqrt(u1)
else
tmp = ((u1 / (1.0e0 - u1)) ** 0.16666666666666666e0) ** 3.0e0
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(u2 * Float32(6.28318530718))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999499917030334)) tmp = Float32(t_0 * sqrt(u1)); else tmp = (Float32(u1 / Float32(Float32(1.0) - u1)) ^ Float32(0.16666666666666666)) ^ Float32(3.0); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((u2 * single(6.28318530718))); tmp = single(0.0); if (t_0 <= single(0.9999499917030334)) tmp = t_0 * sqrt(u1); else tmp = ((u1 / (single(1.0) - u1)) ^ single(0.16666666666666666)) ^ single(3.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(u2 \cdot 6.28318530718\right)\\
\mathbf{if}\;t\_0 \leq 0.9999499917030334:\\
\;\;\;\;t\_0 \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(\frac{u1}{1 - u1}\right)}^{0.16666666666666666}\right)}^{3}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.999949992Initial program 97.9%
Taylor expanded in u1 around 0 73.7%
if 0.999949992 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.4%
add-sqr-sqrt99.4%
sqrt-unprod99.4%
*-commutative99.4%
*-commutative99.4%
swap-sqr99.4%
pow299.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-cube-cbrt97.4%
pow397.4%
*-commutative97.4%
sqrt-prod97.4%
metadata-eval97.4%
sqrt-pow197.4%
metadata-eval97.4%
pow197.4%
*-commutative97.4%
Applied egg-rr97.4%
Taylor expanded in u2 around 0 93.4%
*-lft-identity93.4%
Simplified93.4%
Final simplification87.3%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* u2 6.28318530718))))
(if (<= t_0 0.9999499917030334)
(* t_0 (sqrt u1))
(pow (pow (/ u1 (- 1.0 u1)) 0.25) 2.0))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((u2 * 6.28318530718f));
float tmp;
if (t_0 <= 0.9999499917030334f) {
tmp = t_0 * sqrtf(u1);
} else {
tmp = powf(powf((u1 / (1.0f - u1)), 0.25f), 2.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) :: t_0
real(4) :: tmp
t_0 = cos((u2 * 6.28318530718e0))
if (t_0 <= 0.9999499917030334e0) then
tmp = t_0 * sqrt(u1)
else
tmp = ((u1 / (1.0e0 - u1)) ** 0.25e0) ** 2.0e0
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(u2 * Float32(6.28318530718))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999499917030334)) tmp = Float32(t_0 * sqrt(u1)); else tmp = (Float32(u1 / Float32(Float32(1.0) - u1)) ^ Float32(0.25)) ^ Float32(2.0); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((u2 * single(6.28318530718))); tmp = single(0.0); if (t_0 <= single(0.9999499917030334)) tmp = t_0 * sqrt(u1); else tmp = ((u1 / (single(1.0) - u1)) ^ single(0.25)) ^ single(2.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(u2 \cdot 6.28318530718\right)\\
\mathbf{if}\;t\_0 \leq 0.9999499917030334:\\
\;\;\;\;t\_0 \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(\frac{u1}{1 - u1}\right)}^{0.25}\right)}^{2}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.999949992Initial program 97.9%
Taylor expanded in u1 around 0 73.7%
if 0.999949992 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.4%
Taylor expanded in u2 around 0 96.5%
add-sqr-sqrt95.4%
pow295.5%
pow1/295.5%
sqrt-pow195.5%
metadata-eval95.5%
Applied egg-rr95.5%
Final simplification88.8%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* u2 6.28318530718))))
(if (<= t_0 0.9999499917030334)
(* t_0 (sqrt u1))
(pow (pow (/ u1 (- 1.0 u1)) 1.5) 0.3333333333333333))))
float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((u2 * 6.28318530718f));
float tmp;
if (t_0 <= 0.9999499917030334f) {
tmp = t_0 * sqrtf(u1);
} else {
tmp = powf(powf((u1 / (1.0f - u1)), 1.5f), 0.3333333333333333f);
}
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((u2 * 6.28318530718e0))
if (t_0 <= 0.9999499917030334e0) then
tmp = t_0 * sqrt(u1)
else
tmp = ((u1 / (1.0e0 - u1)) ** 1.5e0) ** 0.3333333333333333e0
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(u2 * Float32(6.28318530718))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999499917030334)) tmp = Float32(t_0 * sqrt(u1)); else tmp = (Float32(u1 / Float32(Float32(1.0) - u1)) ^ Float32(1.5)) ^ Float32(0.3333333333333333); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((u2 * single(6.28318530718))); tmp = single(0.0); if (t_0 <= single(0.9999499917030334)) tmp = t_0 * sqrt(u1); else tmp = ((u1 / (single(1.0) - u1)) ^ single(1.5)) ^ single(0.3333333333333333); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(u2 \cdot 6.28318530718\right)\\
\mathbf{if}\;t\_0 \leq 0.9999499917030334:\\
\;\;\;\;t\_0 \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(\frac{u1}{1 - u1}\right)}^{1.5}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.999949992Initial program 97.9%
Taylor expanded in u1 around 0 73.7%
if 0.999949992 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.4%
Taylor expanded in u2 around 0 96.5%
add-cbrt-cube96.5%
pow1/393.3%
add-sqr-sqrt93.4%
pow193.4%
pow1/293.4%
pow-prod-up93.3%
metadata-eval93.3%
Applied egg-rr93.3%
Final simplification87.3%
(FPCore (cosTheta_i u1 u2) :precision binary32 (if (<= (* u2 6.28318530718) 0.006000000052154064) (sqrt (/ u1 (- 1.0 u1))) (* (cos (* u2 6.28318530718)) (sqrt (* u1 (+ u1 1.0))))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if ((u2 * 6.28318530718f) <= 0.006000000052154064f) {
tmp = sqrtf((u1 / (1.0f - u1)));
} else {
tmp = cosf((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.006000000052154064e0) then
tmp = sqrt((u1 / (1.0e0 - u1)))
else
tmp = cos((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.006000000052154064)) tmp = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))); else tmp = Float32(cos(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.006000000052154064)) tmp = sqrt((u1 / (single(1.0) - u1))); else tmp = cos((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.006000000052154064:\\
\;\;\;\;\sqrt{\frac{u1}{1 - u1}}\\
\mathbf{else}:\\
\;\;\;\;\cos \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) < 0.00600000005Initial program 99.4%
Taylor expanded in u2 around 0 97.3%
if 0.00600000005 < (*.f32 #s(literal 314159265359/50000000000 binary32) u2) Initial program 98.0%
Taylor expanded in u1 around 0 85.5%
+-commutative43.7%
Simplified85.5%
Final simplification93.4%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (pow (+ -1.0 (/ 1.0 u1)) -0.5) (cos (* u2 6.28318530718))))
float code(float cosTheta_i, float u1, float u2) {
return powf((-1.0f + (1.0f / u1)), -0.5f) * cosf((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 = (((-1.0e0) + (1.0e0 / u1)) ** (-0.5e0)) * cos((u2 * 6.28318530718e0))
end function
function code(cosTheta_i, u1, u2) return Float32((Float32(Float32(-1.0) + Float32(Float32(1.0) / u1)) ^ Float32(-0.5)) * cos(Float32(u2 * Float32(6.28318530718)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = ((single(-1.0) + (single(1.0) / u1)) ^ single(-0.5)) * cos((u2 * single(6.28318530718))); end
\begin{array}{l}
\\
{\left(-1 + \frac{1}{u1}\right)}^{-0.5} \cdot \cos \left(u2 \cdot 6.28318530718\right)
\end{array}
Initial program 98.9%
add-sqr-sqrt98.9%
sqrt-unprod98.9%
*-commutative98.9%
*-commutative98.9%
swap-sqr98.9%
pow298.9%
metadata-eval99.0%
Applied egg-rr99.0%
add-cube-cbrt97.2%
pow397.2%
*-commutative97.2%
sqrt-prod97.1%
metadata-eval97.2%
sqrt-pow197.2%
metadata-eval97.2%
pow197.2%
*-commutative97.2%
Applied egg-rr97.2%
rem-cube-cbrt98.9%
add-sqr-sqrt97.8%
metadata-eval97.9%
unpow1/297.9%
*-commutative97.9%
associate-*l*97.8%
pow1/297.8%
sqrt-pow198.1%
metadata-eval98.1%
pow1/298.2%
sqrt-pow197.9%
metadata-eval97.9%
unpow1/297.9%
metadata-eval97.9%
Applied egg-rr97.9%
pow197.9%
associate-*r*98.0%
pow-prod-up99.0%
metadata-eval99.0%
pow1/298.9%
*-commutative98.9%
clear-num98.8%
unpow-198.8%
sqrt-pow199.0%
div-sub99.0%
*-inverses99.0%
sub-neg99.0%
metadata-eval99.0%
metadata-eval99.0%
Applied egg-rr99.0%
unpow199.0%
*-commutative99.0%
+-commutative99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* u2 6.28318530718))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((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))) * cos((u2 * 6.28318530718e0))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(Float32(u2 * Float32(6.28318530718)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((u2 * single(6.28318530718))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(u2 \cdot 6.28318530718\right)
\end{array}
Initial program 98.9%
Final simplification98.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt (* u1 (+ u1 1.0))))
float code(float cosTheta_i, float u1, float u2) {
return 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 = sqrt((u1 * (u1 + 1.0e0)))
end function
function code(cosTheta_i, u1, u2) return sqrt(Float32(u1 * Float32(u1 + Float32(1.0)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 * (u1 + single(1.0)))); end
\begin{array}{l}
\\
\sqrt{u1 \cdot \left(u1 + 1\right)}
\end{array}
Initial program 98.9%
Taylor expanded in u2 around 0 79.7%
Taylor expanded in u1 around 0 72.5%
+-commutative72.5%
Simplified72.5%
Final simplification72.5%
(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 98.9%
Taylor expanded in u2 around 0 79.7%
Final simplification79.7%
(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 98.9%
Taylor expanded in u2 around 0 79.7%
Taylor expanded in u1 around 0 64.7%
Final simplification64.7%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* u1 (+ 1.0 (/ 0.5 u1))))
float code(float cosTheta_i, float u1, float u2) {
return u1 * (1.0f + (0.5f / 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 = u1 * (1.0e0 + (0.5e0 / u1))
end function
function code(cosTheta_i, u1, u2) return Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) / u1))) end
function tmp = code(cosTheta_i, u1, u2) tmp = u1 * (single(1.0) + (single(0.5) / u1)); end
\begin{array}{l}
\\
u1 \cdot \left(1 + \frac{0.5}{u1}\right)
\end{array}
Initial program 98.9%
Taylor expanded in u2 around 0 79.7%
Taylor expanded in u1 around 0 72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in u1 around inf 19.9%
associate-*r/19.9%
metadata-eval19.9%
Simplified19.9%
Final simplification19.9%
herbie shell --seed 2024066
(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))))