?

Average Error: 0.3 → 0.3
Time: 10.9s
Precision: binary32
Cost: 9952

?

\[\left(\left(cosTheta_i > 0.9999 \land cosTheta_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right) \]
\[\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right) \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (/ u1 (- 1.0 u1))) (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) {
	return sqrtf((u1 / (1.0f - u1))) * 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
    code = sqrt((u1 / (1.0e0 - u1))) * 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)
	return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * 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)
	tmp = sqrt((u1 / (single(1.0) - u1))) * cos(sqrt(((u2 * u2) * single(39.47841760436263))));
end
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.3

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right) \]
  2. Applied egg-rr0.3

    \[\leadsto \sqrt{\frac{u1}{1 - u1}} \cdot \cos \color{blue}{\left(\sqrt{39.47841760436263 \cdot \left(u2 \cdot u2\right)}\right)} \]
  3. Simplified0.3

    \[\leadsto \sqrt{\frac{u1}{1 - u1}} \cdot \cos \color{blue}{\left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right)} \]
    Proof

    [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) \]
  4. Final simplification0.3

    \[\leadsto \sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(\sqrt{\left(u2 \cdot u2\right) \cdot 39.47841760436263}\right) \]

Alternatives

Alternative 1
Error1.8
Cost6692
\[\begin{array}{l} \mathbf{if}\;u2 \cdot 6.28318530718 \leq 0.11999999731779099:\\ \;\;\;\;\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + u2 \cdot \left(u2 \cdot -19.739208802181317\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(u2 \cdot 6.28318530718\right) \cdot \sqrt{u1}\\ \end{array} \]
Alternative 2
Error0.3
Cost6688
\[\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(u2 \cdot 6.28318530718\right) \]
Alternative 3
Error3.6
Cost3616
\[\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + u2 \cdot \left(u2 \cdot -19.739208802181317\right)\right) \]
Alternative 4
Error9.1
Cost3360
\[\sqrt{u1 \cdot \left(u1 + 1\right)} \]
Alternative 5
Error6.3
Cost3360
\[\sqrt{\frac{u1}{1 - u1}} \]
Alternative 6
Error11.7
Cost3232
\[\sqrt{u1} \]

Error

Reproduce?

herbie shell --seed 2023034 
(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))))