Average Error: 0.3 → 0.3
Time: 12.3s
Precision: binary32
Cost: 23168
\[\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) \]
\[\begin{array}{l} t_0 := \cos \left(6.28318530718 \cdot u2\right)\\ \sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \left(t_0 \cdot 0.5 + t_0 \cdot \left(0.5 \cdot \cos \left(2 \cdot e^{\log \left(6.28318530718 \cdot u2\right)}\right)\right)\right)} \end{array} \]
(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 (cos (* 6.28318530718 u2))))
   (cbrt
    (*
     (pow (/ u1 (- 1.0 u1)) 1.5)
     (+
      (* t_0 0.5)
      (* t_0 (* 0.5 (cos (* 2.0 (exp (log (* 6.28318530718 u2))))))))))))
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 = cosf((6.28318530718f * u2));
	return cbrtf((powf((u1 / (1.0f - u1)), 1.5f) * ((t_0 * 0.5f) + (t_0 * (0.5f * cosf((2.0f * expf(logf((6.28318530718f * u2))))))))));
}
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 = cos(Float32(Float32(6.28318530718) * u2))
	return cbrt(Float32((Float32(u1 / Float32(Float32(1.0) - u1)) ^ Float32(1.5)) * Float32(Float32(t_0 * Float32(0.5)) + Float32(t_0 * Float32(Float32(0.5) * cos(Float32(Float32(2.0) * exp(log(Float32(Float32(6.28318530718) * u2))))))))))
end
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\begin{array}{l}
t_0 := \cos \left(6.28318530718 \cdot u2\right)\\
\sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \left(t_0 \cdot 0.5 + t_0 \cdot \left(0.5 \cdot \cos \left(2 \cdot e^{\log \left(6.28318530718 \cdot u2\right)}\right)\right)\right)}
\end{array}

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 \color{blue}{\sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot {\cos \left(6.28318530718 \cdot u2\right)}^{3}}} \]
  3. Applied egg-rr0.3

    \[\leadsto \sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \color{blue}{\left(\cos \left(6.28318530718 \cdot u2\right) \cdot 0.5 + \cos \left(6.28318530718 \cdot u2\right) \cdot \left(0.5 \cdot \cos \left(2 \cdot \left(6.28318530718 \cdot u2\right)\right)\right)\right)}} \]
  4. Applied egg-rr0.3

    \[\leadsto \sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \left(\cos \left(6.28318530718 \cdot u2\right) \cdot 0.5 + \cos \left(6.28318530718 \cdot u2\right) \cdot \left(0.5 \cdot \cos \left(2 \cdot \color{blue}{e^{\log \left(6.28318530718 \cdot u2\right)}}\right)\right)\right)} \]
  5. Final simplification0.3

    \[\leadsto \sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \left(\cos \left(6.28318530718 \cdot u2\right) \cdot 0.5 + \cos \left(6.28318530718 \cdot u2\right) \cdot \left(0.5 \cdot \cos \left(2 \cdot e^{\log \left(6.28318530718 \cdot u2\right)}\right)\right)\right)} \]

Alternatives

Alternative 1
Error0.3
Cost16640
\[\begin{array}{l} t_0 := \cos \left(6.28318530718 \cdot u2\right)\\ \sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \left(0.5 \cdot \left(t_0 + t_0 \cdot \cos \left(u2 \cdot 12.56637061436\right)\right)\right)} \end{array} \]
Alternative 2
Error0.3
Cost13376
\[\sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot \left(\frac{\cos \left(6.28318530718 \cdot u2\right)}{2} \cdot \left(1 + \cos \left(u2 \cdot 12.56637061436\right)\right)\right)} \]
Alternative 3
Error0.3
Cost13152
\[\sqrt[3]{{\left(\frac{u1}{1 - u1}\right)}^{1.5} \cdot {\cos \left(6.28318530718 \cdot u2\right)}^{3}} \]
Alternative 4
Error1.8
Cost6692
\[\begin{array}{l} \mathbf{if}\;6.28318530718 \cdot u2 \leq 0.3039500117301941:\\ \;\;\;\;\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1}\\ \end{array} \]
Alternative 5
Error0.3
Cost6688
\[\cos \left(6.28318530718 \cdot u2\right) \cdot \sqrt{\frac{u1}{1 - u1}} \]
Alternative 6
Error3.7
Cost3616
\[\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + -19.739208802181317 \cdot \left(u2 \cdot u2\right)\right) \]
Alternative 7
Error3.7
Cost3616
\[\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + u2 \cdot \left(u2 \cdot -19.739208802181317\right)\right) \]
Alternative 8
Error9.0
Cost3360
\[\sqrt{u1 \cdot \left(u1 + 1\right)} \]
Alternative 9
Error6.4
Cost3360
\[\sqrt{\frac{u1}{1 - u1}} \]
Alternative 10
Error11.7
Cost3232
\[\sqrt{u1} \]

Error

Reproduce

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