
(FPCore (cosTheta_i u1 u2)
: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))))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)
use fmin_fmax_functions
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
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i u1 u2)
: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))))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)
use fmin_fmax_functions
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
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
(FPCore (cosTheta_i u1 u2)
: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 (fma -6.28318530718 u2 1.5707963705062866))))float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * sinf(fmaf(-6.28318530718f, u2, 1.5707963705062866f));
}
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(fma(Float32(-6.28318530718), u2, Float32(1.5707963705062866)))) end
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(\mathsf{fma}\left(-6.28318530718, u2, 1.5707963705062866\right)\right)
Initial program 99.0%
Applied rewrites99.2%
Evaluated real constant99.2%
(FPCore (cosTheta_i u1 u2)
: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)))
(let* ((t_0 (sqrt (/ u1 (- 1.0 u1)))))
(if (<= u2 0.017999999225139618)
(+ t_0 (* -19.739208802181317 (* (pow u2 2.0) t_0)))
(* (sqrt (fma u1 u1 u1)) (cos (* 6.28318530718 u2))))))float code(float cosTheta_i, float u1, float u2) {
float t_0 = sqrtf((u1 / (1.0f - u1)));
float tmp;
if (u2 <= 0.017999999225139618f) {
tmp = t_0 + (-19.739208802181317f * (powf(u2, 2.0f) * t_0));
} else {
tmp = sqrtf(fmaf(u1, u1, u1)) * cosf((6.28318530718f * u2));
}
return tmp;
}
function code(cosTheta_i, u1, u2) t_0 = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) tmp = Float32(0.0) if (u2 <= Float32(0.017999999225139618)) tmp = Float32(t_0 + Float32(Float32(-19.739208802181317) * Float32((u2 ^ Float32(2.0)) * t_0))); else tmp = Float32(sqrt(fma(u1, u1, u1)) * cos(Float32(Float32(6.28318530718) * u2))); end return tmp end
\begin{array}{l}
t_0 := \sqrt{\frac{u1}{1 - u1}}\\
\mathbf{if}\;u2 \leq 0.017999999225139618:\\
\;\;\;\;t\_0 + -19.739208802181317 \cdot \left({u2}^{2} \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(u1, u1, u1\right)} \cdot \cos \left(6.28318530718 \cdot u2\right)\\
\end{array}
if u2 < 0.0179999992Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites88.4%
if 0.0179999992 < u2 Initial program 99.0%
Taylor expanded in u1 around 0
Applied rewrites86.8%
Applied rewrites86.9%
(FPCore (cosTheta_i u1 u2)
: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)))
(let* ((t_0 (sqrt (/ u1 (- 1.0 u1)))))
(if (<= (cos (* 6.28318530718 u2)) 0.9934999942779541)
(* (sin (+ 1.5707963705062866 (* -6.28318530718 u2))) (sqrt u1))
(+ t_0 (* -19.739208802181317 (* (pow u2 2.0) t_0))))))float code(float cosTheta_i, float u1, float u2) {
float t_0 = sqrtf((u1 / (1.0f - u1)));
float tmp;
if (cosf((6.28318530718f * u2)) <= 0.9934999942779541f) {
tmp = sinf((1.5707963705062866f + (-6.28318530718f * u2))) * sqrtf(u1);
} else {
tmp = t_0 + (-19.739208802181317f * (powf(u2, 2.0f) * t_0));
}
return tmp;
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
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 = sqrt((u1 / (1.0e0 - u1)))
if (cos((6.28318530718e0 * u2)) <= 0.9934999942779541e0) then
tmp = sin((1.5707963705062866e0 + ((-6.28318530718e0) * u2))) * sqrt(u1)
else
tmp = t_0 + ((-19.739208802181317e0) * ((u2 ** 2.0e0) * t_0))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) tmp = Float32(0.0) if (cos(Float32(Float32(6.28318530718) * u2)) <= Float32(0.9934999942779541)) tmp = Float32(sin(Float32(Float32(1.5707963705062866) + Float32(Float32(-6.28318530718) * u2))) * sqrt(u1)); else tmp = Float32(t_0 + Float32(Float32(-19.739208802181317) * Float32((u2 ^ Float32(2.0)) * t_0))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = sqrt((u1 / (single(1.0) - u1))); tmp = single(0.0); if (cos((single(6.28318530718) * u2)) <= single(0.9934999942779541)) tmp = sin((single(1.5707963705062866) + (single(-6.28318530718) * u2))) * sqrt(u1); else tmp = t_0 + (single(-19.739208802181317) * ((u2 ^ single(2.0)) * t_0)); end tmp_2 = tmp; end
\begin{array}{l}
t_0 := \sqrt{\frac{u1}{1 - u1}}\\
\mathbf{if}\;\cos \left(6.28318530718 \cdot u2\right) \leq 0.9934999942779541:\\
\;\;\;\;\sin \left(1.5707963705062866 + -6.28318530718 \cdot u2\right) \cdot \sqrt{u1}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + -19.739208802181317 \cdot \left({u2}^{2} \cdot t\_0\right)\\
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.993499994Initial program 99.0%
Applied rewrites99.2%
Evaluated real constant99.2%
Taylor expanded in u1 around 0
Applied rewrites74.5%
if 0.993499994 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites88.4%
(FPCore (cosTheta_i u1 u2)
: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)))
(let* ((t_0 (sqrt (/ u1 (- 1.0 u1)))))
(if (<= (cos (* 6.28318530718 u2)) 0.9934999942779541)
(* (sqrt u1) (sin (fma -6.28318530718 u2 1.5707963705062866)))
(+ t_0 (* -19.739208802181317 (* (pow u2 2.0) t_0))))))float code(float cosTheta_i, float u1, float u2) {
float t_0 = sqrtf((u1 / (1.0f - u1)));
float tmp;
if (cosf((6.28318530718f * u2)) <= 0.9934999942779541f) {
tmp = sqrtf(u1) * sinf(fmaf(-6.28318530718f, u2, 1.5707963705062866f));
} else {
tmp = t_0 + (-19.739208802181317f * (powf(u2, 2.0f) * t_0));
}
return tmp;
}
function code(cosTheta_i, u1, u2) t_0 = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) tmp = Float32(0.0) if (cos(Float32(Float32(6.28318530718) * u2)) <= Float32(0.9934999942779541)) tmp = Float32(sqrt(u1) * sin(fma(Float32(-6.28318530718), u2, Float32(1.5707963705062866)))); else tmp = Float32(t_0 + Float32(Float32(-19.739208802181317) * Float32((u2 ^ Float32(2.0)) * t_0))); end return tmp end
\begin{array}{l}
t_0 := \sqrt{\frac{u1}{1 - u1}}\\
\mathbf{if}\;\cos \left(6.28318530718 \cdot u2\right) \leq 0.9934999942779541:\\
\;\;\;\;\sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(-6.28318530718, u2, 1.5707963705062866\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + -19.739208802181317 \cdot \left({u2}^{2} \cdot t\_0\right)\\
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.993499994Initial program 99.0%
Applied rewrites99.2%
Evaluated real constant99.2%
Taylor expanded in u1 around 0
Applied rewrites74.5%
if 0.993499994 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites88.4%
(FPCore (cosTheta_i u1 u2)
: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)))
(let* ((t_0 (cos (* 6.28318530718 u2)))
(t_1 (sqrt (/ u1 (- 1.0 u1)))))
(if (<= t_0 0.9934999942779541)
(* (sqrt u1) t_0)
(+ t_1 (* -19.739208802181317 (* (pow u2 2.0) t_1))))))float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((6.28318530718f * u2));
float t_1 = sqrtf((u1 / (1.0f - u1)));
float tmp;
if (t_0 <= 0.9934999942779541f) {
tmp = sqrtf(u1) * t_0;
} else {
tmp = t_1 + (-19.739208802181317f * (powf(u2, 2.0f) * t_1));
}
return tmp;
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = cos((6.28318530718e0 * u2))
t_1 = sqrt((u1 / (1.0e0 - u1)))
if (t_0 <= 0.9934999942779541e0) then
tmp = sqrt(u1) * t_0
else
tmp = t_1 + ((-19.739208802181317e0) * ((u2 ** 2.0e0) * t_1))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) t_0 = cos(Float32(Float32(6.28318530718) * u2)) t_1 = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) tmp = Float32(0.0) if (t_0 <= Float32(0.9934999942779541)) tmp = Float32(sqrt(u1) * t_0); else tmp = Float32(t_1 + Float32(Float32(-19.739208802181317) * Float32((u2 ^ Float32(2.0)) * t_1))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) t_0 = cos((single(6.28318530718) * u2)); t_1 = sqrt((u1 / (single(1.0) - u1))); tmp = single(0.0); if (t_0 <= single(0.9934999942779541)) tmp = sqrt(u1) * t_0; else tmp = t_1 + (single(-19.739208802181317) * ((u2 ^ single(2.0)) * t_1)); end tmp_2 = tmp; end
\begin{array}{l}
t_0 := \cos \left(6.28318530718 \cdot u2\right)\\
t_1 := \sqrt{\frac{u1}{1 - u1}}\\
\mathbf{if}\;t\_0 \leq 0.9934999942779541:\\
\;\;\;\;\sqrt{u1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1 + -19.739208802181317 \cdot \left({u2}^{2} \cdot t\_1\right)\\
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.993499994Initial program 99.0%
Taylor expanded in u1 around 0
Applied rewrites74.4%
if 0.993499994 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites88.4%
(FPCore (cosTheta_i u1 u2)
: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)))
(let* ((t_0 (cos (* 6.28318530718 u2))))
(if (<= t_0 0.9934999942779541)
(* (sqrt u1) t_0)
(*
(sqrt (/ u1 (- 1.0 u1)))
(+ 1.0 (* -19.739208802181317 (pow u2 2.0)))))))float code(float cosTheta_i, float u1, float u2) {
float t_0 = cosf((6.28318530718f * u2));
float tmp;
if (t_0 <= 0.9934999942779541f) {
tmp = sqrtf(u1) * t_0;
} else {
tmp = sqrtf((u1 / (1.0f - u1))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
}
return tmp;
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
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.9934999942779541e0) then
tmp = sqrt(u1) * t_0
else
tmp = sqrt((u1 / (1.0e0 - u1))) * (1.0e0 + ((-19.739208802181317e0) * (u2 ** 2.0e0)))
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.9934999942779541)) tmp = Float32(sqrt(u1) * t_0); else tmp = Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))); 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.9934999942779541)) tmp = sqrt(u1) * t_0; else tmp = sqrt((u1 / (single(1.0) - u1))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
t_0 := \cos \left(6.28318530718 \cdot u2\right)\\
\mathbf{if}\;t\_0 \leq 0.9934999942779541:\\
\;\;\;\;\sqrt{u1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)\\
\end{array}
if (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) < 0.993499994Initial program 99.0%
Taylor expanded in u1 around 0
Applied rewrites74.4%
if 0.993499994 < (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2)) Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites88.4%
(FPCore (cosTheta_i u1 u2)
: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)))
(+ 1.0 (* -19.739208802181317 (pow u2 2.0)))))float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
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 ** 2.0e0)))
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) * (u2 ^ Float32(2.0))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); end
\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)
Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites88.4%
(FPCore (cosTheta_i u1 u2)
: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)))
(/
(fma (* (* u2 u2) -19.739208802181317) (sqrt u1) (sqrt u1))
(sqrt (fabs (- u1 1.0)))))float code(float cosTheta_i, float u1, float u2) {
return fmaf(((u2 * u2) * -19.739208802181317f), sqrtf(u1), sqrtf(u1)) / sqrtf(fabsf((u1 - 1.0f)));
}
function code(cosTheta_i, u1, u2) return Float32(fma(Float32(Float32(u2 * u2) * Float32(-19.739208802181317)), sqrt(u1), sqrt(u1)) / sqrt(abs(Float32(u1 - Float32(1.0))))) end
\frac{\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -19.739208802181317, \sqrt{u1}, \sqrt{u1}\right)}{\sqrt{\left|u1 - 1\right|}}
Initial program 99.0%
Applied rewrites98.6%
Taylor expanded in u2 around 0
Applied rewrites88.1%
Applied rewrites88.1%
(FPCore (cosTheta_i u1 u2)
: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)))
(/
(fma (* (* -19.739208802181317 u2) u2) (sqrt u1) (sqrt u1))
(sqrt (fabs (- u1 1.0)))))float code(float cosTheta_i, float u1, float u2) {
return fmaf(((-19.739208802181317f * u2) * u2), sqrtf(u1), sqrtf(u1)) / sqrtf(fabsf((u1 - 1.0f)));
}
function code(cosTheta_i, u1, u2) return Float32(fma(Float32(Float32(Float32(-19.739208802181317) * u2) * u2), sqrt(u1), sqrt(u1)) / sqrt(abs(Float32(u1 - Float32(1.0))))) end
\frac{\mathsf{fma}\left(\left(-19.739208802181317 \cdot u2\right) \cdot u2, \sqrt{u1}, \sqrt{u1}\right)}{\sqrt{\left|u1 - 1\right|}}
Initial program 99.0%
Applied rewrites98.6%
Taylor expanded in u2 around 0
Applied rewrites88.1%
Applied rewrites88.1%
Applied rewrites88.1%
(FPCore (cosTheta_i u1 u2)
: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)))
(/
(fma (* (sqrt u1) u2) (* -19.739208802181317 u2) (sqrt u1))
(sqrt (fabs (- u1 1.0)))))float code(float cosTheta_i, float u1, float u2) {
return fmaf((sqrtf(u1) * u2), (-19.739208802181317f * u2), sqrtf(u1)) / sqrtf(fabsf((u1 - 1.0f)));
}
function code(cosTheta_i, u1, u2) return Float32(fma(Float32(sqrt(u1) * u2), Float32(Float32(-19.739208802181317) * u2), sqrt(u1)) / sqrt(abs(Float32(u1 - Float32(1.0))))) end
\frac{\mathsf{fma}\left(\sqrt{u1} \cdot u2, -19.739208802181317 \cdot u2, \sqrt{u1}\right)}{\sqrt{\left|u1 - 1\right|}}
Initial program 99.0%
Applied rewrites98.6%
Taylor expanded in u2 around 0
Applied rewrites88.1%
Applied rewrites88.1%
(FPCore (cosTheta_i u1 u2)
: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)))
(/
(* (fma (* u2 u2) -19.739208802181317 1.0) (sqrt u1))
(sqrt (fabs (- u1 1.0)))))float code(float cosTheta_i, float u1, float u2) {
return (fmaf((u2 * u2), -19.739208802181317f, 1.0f) * sqrtf(u1)) / sqrtf(fabsf((u1 - 1.0f)));
}
function code(cosTheta_i, u1, u2) return Float32(Float32(fma(Float32(u2 * u2), Float32(-19.739208802181317), Float32(1.0)) * sqrt(u1)) / sqrt(abs(Float32(u1 - Float32(1.0))))) end
\frac{\mathsf{fma}\left(u2 \cdot u2, -19.739208802181317, 1\right) \cdot \sqrt{u1}}{\sqrt{\left|u1 - 1\right|}}
Initial program 99.0%
Applied rewrites98.6%
Taylor expanded in u2 around 0
Applied rewrites88.1%
Applied rewrites88.1%
Applied rewrites88.1%
(FPCore (cosTheta_i u1 u2)
: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)))
(let* ((t_0 (sqrt (/ u1 (- 1.0 u1)))))
(if (<= (* t_0 (cos (* 6.28318530718 u2))) 0.0005920000257901847)
(/
(fma (* (* u2 u2) -19.739208802181317) (sqrt u1) (sqrt u1))
(sqrt (fabs -1.0)))
t_0)))float code(float cosTheta_i, float u1, float u2) {
float t_0 = sqrtf((u1 / (1.0f - u1)));
float tmp;
if ((t_0 * cosf((6.28318530718f * u2))) <= 0.0005920000257901847f) {
tmp = fmaf(((u2 * u2) * -19.739208802181317f), sqrtf(u1), sqrtf(u1)) / sqrtf(fabsf(-1.0f));
} else {
tmp = t_0;
}
return tmp;
}
function code(cosTheta_i, u1, u2) t_0 = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) tmp = Float32(0.0) if (Float32(t_0 * cos(Float32(Float32(6.28318530718) * u2))) <= Float32(0.0005920000257901847)) tmp = Float32(fma(Float32(Float32(u2 * u2) * Float32(-19.739208802181317)), sqrt(u1), sqrt(u1)) / sqrt(abs(Float32(-1.0)))); else tmp = t_0; end return tmp end
\begin{array}{l}
t_0 := \sqrt{\frac{u1}{1 - u1}}\\
\mathbf{if}\;t\_0 \cdot \cos \left(6.28318530718 \cdot u2\right) \leq 0.0005920000257901847:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -19.739208802181317, \sqrt{u1}, \sqrt{u1}\right)}{\sqrt{\left|-1\right|}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (*.f32 (sqrt.f32 (/.f32 u1 (-.f32 #s(literal 1 binary32) u1))) (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2))) < 5.92000026e-4Initial program 99.0%
Applied rewrites98.6%
Taylor expanded in u2 around 0
Applied rewrites88.1%
Applied rewrites88.1%
Taylor expanded in u1 around 0
Applied rewrites67.8%
if 5.92000026e-4 < (*.f32 (sqrt.f32 (/.f32 u1 (-.f32 #s(literal 1 binary32) u1))) (cos.f32 (*.f32 #s(literal 314159265359/50000000000 binary32) u2))) Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites80.1%
(FPCore (cosTheta_i u1 u2)
: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))))float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1)));
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
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
\sqrt{\frac{u1}{1 - u1}}
Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites80.1%
(FPCore (cosTheta_i u1 u2)
: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))))float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 * (1.0f + u1)));
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
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
\sqrt{u1 \cdot \left(1 + u1\right)}
Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites80.1%
Taylor expanded in u1 around 0
Applied rewrites71.7%
(FPCore (cosTheta_i u1 u2)
: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))float code(float cosTheta_i, float u1, float u2) {
return sqrtf(u1);
}
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
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
\sqrt{u1}
Initial program 99.0%
Taylor expanded in u2 around 0
Applied rewrites80.1%
Taylor expanded in u1 around 0
Applied rewrites63.3%
herbie shell --seed 2025359
(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))))