| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 9952 |
\[\cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right) \cdot \sqrt{\frac{u1}{1 - u1}}
\]
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (- 1.0 (* u1 u1))))
(*
(sqrt (/ (/ u1 t_0) (/ (- 1.0 u1) t_0)))
(cos (sqrt (* (* u2 u2) 39.47841760436263))))))float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((6.28318530718f * u2));
}
float code(float cosTheta_i, float u1, float u2) {
float t_0 = 1.0f - (u1 * u1);
return sqrtf(((u1 / t_0) / ((1.0f - u1) / t_0))) * cosf(sqrtf(((u2 * u2) * 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((6.28318530718e0 * u2))
end function
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
t_0 = 1.0e0 - (u1 * u1)
code = sqrt(((u1 / t_0) / ((1.0e0 - u1) / t_0))) * cos(sqrt(((u2 * u2) * 39.47841760436263e0)))
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 code(cosTheta_i, u1, u2) t_0 = Float32(Float32(1.0) - Float32(u1 * u1)) return Float32(sqrt(Float32(Float32(u1 / t_0) / Float32(Float32(Float32(1.0) - u1) / t_0))) * cos(sqrt(Float32(Float32(u2 * u2) * Float32(39.47841760436263))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((single(6.28318530718) * u2)); end
function tmp = code(cosTheta_i, u1, u2) t_0 = single(1.0) - (u1 * u1); tmp = sqrt(((u1 / t_0) / ((single(1.0) - u1) / t_0))) * cos(sqrt(((u2 * u2) * single(39.47841760436263)))); end
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\begin{array}{l}
t_0 := 1 - u1 \cdot u1\\
\sqrt{\frac{\frac{u1}{t_0}}{\frac{1 - u1}{t_0}}} \cdot \cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right)
\end{array}
Results
Initial program 0.3
Applied egg-rr0.3
Simplified0.3
[Start]0.3 | \[ \sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(\sqrt{39.47841760436263 \cdot \left(u2 \cdot u2\right)}\right)
\] |
|---|---|
*-commutative [=>]0.3 | \[ \sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(\sqrt{\color{blue}{\left(u2 \cdot u2\right) \cdot 39.47841760436263}}\right)
\] |
Applied egg-rr0.4
Applied egg-rr0.3
Simplified0.3
[Start]0.3 | \[ \sqrt{\frac{\frac{u1}{1 - u1 \cdot u1} \cdot \left(1 - u1 \cdot u1\right)}{1 - u1}} \cdot \cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right)
\] |
|---|---|
associate-/l* [=>]0.3 | \[ \sqrt{\color{blue}{\frac{\frac{u1}{1 - u1 \cdot u1}}{\frac{1 - u1}{1 - u1 \cdot u1}}}} \cdot \cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right)
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 9952 |
| Alternative 2 | |
|---|---|
| Error | 1.2 |
| Cost | 6820 |
| Alternative 3 | |
|---|---|
| Error | 2.0 |
| Cost | 6692 |
| Alternative 4 | |
|---|---|
| Error | 0.3 |
| Cost | 6688 |
| Alternative 5 | |
|---|---|
| Error | 4.0 |
| Cost | 3616 |
| Alternative 6 | |
|---|---|
| Error | 9.3 |
| Cost | 3360 |
| Alternative 7 | |
|---|---|
| Error | 6.7 |
| Cost | 3360 |
| Alternative 8 | |
|---|---|
| Error | 11.9 |
| Cost | 3232 |
herbie shell --seed 2023066
(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))))