?

Average Error: 14.2 → 0.5
Time: 19.3s
Precision: binary32
Cost: 10372

?

\[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
\[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9620000123977661:\\ \;\;\;\;\left(-\alpha\right) \cdot \frac{1}{\frac{1}{\log \left(1 - u0\right) \cdot \alpha}}\\ \mathbf{else}:\\ \;\;\;\;\left(u0 - \left(-0.25 \cdot {u0}^{4} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.5 \cdot {u0}^{2}\right)\right)\right) \cdot \left(\alpha \cdot \alpha\right)\\ \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (* (* (- alpha) alpha) (log (- 1.0 u0))))
(FPCore (alpha u0)
 :precision binary32
 (if (<= (- 1.0 u0) 0.9620000123977661)
   (* (- alpha) (/ 1.0 (/ 1.0 (* (log (- 1.0 u0)) alpha))))
   (*
    (-
     u0
     (+
      (* -0.25 (pow u0 4.0))
      (+ (* -0.3333333333333333 (pow u0 3.0)) (* -0.5 (pow u0 2.0)))))
    (* alpha alpha))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf((1.0f - u0));
}
float code(float alpha, float u0) {
	float tmp;
	if ((1.0f - u0) <= 0.9620000123977661f) {
		tmp = -alpha * (1.0f / (1.0f / (logf((1.0f - u0)) * alpha)));
	} else {
		tmp = (u0 - ((-0.25f * powf(u0, 4.0f)) + ((-0.3333333333333333f * powf(u0, 3.0f)) + (-0.5f * powf(u0, 2.0f))))) * (alpha * alpha);
	}
	return tmp;
}
real(4) function code(alpha, u0)
    real(4), intent (in) :: alpha
    real(4), intent (in) :: u0
    code = (-alpha * alpha) * log((1.0e0 - u0))
end function
real(4) function code(alpha, u0)
    real(4), intent (in) :: alpha
    real(4), intent (in) :: u0
    real(4) :: tmp
    if ((1.0e0 - u0) <= 0.9620000123977661e0) then
        tmp = -alpha * (1.0e0 / (1.0e0 / (log((1.0e0 - u0)) * alpha)))
    else
        tmp = (u0 - (((-0.25e0) * (u0 ** 4.0e0)) + (((-0.3333333333333333e0) * (u0 ** 3.0e0)) + ((-0.5e0) * (u0 ** 2.0e0))))) * (alpha * alpha)
    end if
    code = tmp
end function
function code(alpha, u0)
	return Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)))
end
function code(alpha, u0)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - u0) <= Float32(0.9620000123977661))
		tmp = Float32(Float32(-alpha) * Float32(Float32(1.0) / Float32(Float32(1.0) / Float32(log(Float32(Float32(1.0) - u0)) * alpha))));
	else
		tmp = Float32(Float32(u0 - Float32(Float32(Float32(-0.25) * (u0 ^ Float32(4.0))) + Float32(Float32(Float32(-0.3333333333333333) * (u0 ^ Float32(3.0))) + Float32(Float32(-0.5) * (u0 ^ Float32(2.0)))))) * Float32(alpha * alpha));
	end
	return tmp
end
function tmp = code(alpha, u0)
	tmp = (-alpha * alpha) * log((single(1.0) - u0));
end
function tmp_2 = code(alpha, u0)
	tmp = single(0.0);
	if ((single(1.0) - u0) <= single(0.9620000123977661))
		tmp = -alpha * (single(1.0) / (single(1.0) / (log((single(1.0) - u0)) * alpha)));
	else
		tmp = (u0 - ((single(-0.25) * (u0 ^ single(4.0))) + ((single(-0.3333333333333333) * (u0 ^ single(3.0))) + (single(-0.5) * (u0 ^ single(2.0)))))) * (alpha * alpha);
	end
	tmp_2 = tmp;
end
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\begin{array}{l}
\mathbf{if}\;1 - u0 \leq 0.9620000123977661:\\
\;\;\;\;\left(-\alpha\right) \cdot \frac{1}{\frac{1}{\log \left(1 - u0\right) \cdot \alpha}}\\

\mathbf{else}:\\
\;\;\;\;\left(u0 - \left(-0.25 \cdot {u0}^{4} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.5 \cdot {u0}^{2}\right)\right)\right) \cdot \left(\alpha \cdot \alpha\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (-.f32 1 u0) < 0.962000012

    1. Initial program 1.1

      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
    2. Applied egg-rr1.1

      \[\leadsto \color{blue}{\frac{-\log \left(1 - u0\right)}{\frac{1}{\alpha \cdot \alpha}}} \]
    3. Applied egg-rr1.1

      \[\leadsto \color{blue}{\left(-\alpha\right) \cdot \frac{1}{\frac{1}{\log \left(1 - u0\right) \cdot \alpha}}} \]

    if 0.962000012 < (-.f32 1 u0)

    1. Initial program 16.4

      \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
    2. Simplified16.4

      \[\leadsto \color{blue}{\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)} \]
      Proof

      [Start]16.4

      \[ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]

      rational.json-simplify-2 [=>]16.4

      \[ \color{blue}{\log \left(1 - u0\right) \cdot \left(\left(-\alpha\right) \cdot \alpha\right)} \]

      rational.json-simplify-43 [=>]16.4

      \[ \color{blue}{\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)} \]
    3. Taylor expanded in u0 around 0 0.4

      \[\leadsto \left(-\alpha\right) \cdot \left(\alpha \cdot \color{blue}{\left(-1 \cdot u0 + \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)}\right) \]
    4. Simplified0.4

      \[\leadsto \left(-\alpha\right) \cdot \left(\alpha \cdot \color{blue}{\left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)}\right) \]
      Proof

      [Start]0.4

      \[ \left(-\alpha\right) \cdot \left(\alpha \cdot \left(-1 \cdot u0 + \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) \]

      rational.json-simplify-2 [=>]0.4

      \[ \left(-\alpha\right) \cdot \left(\alpha \cdot \left(\color{blue}{u0 \cdot -1} + \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) \]

      rational.json-simplify-9 [=>]0.4

      \[ \left(-\alpha\right) \cdot \left(\alpha \cdot \left(\color{blue}{\left(-u0\right)} + \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) \]
    5. Applied egg-rr0.4

      \[\leadsto \color{blue}{\alpha \cdot \left(\left(-\alpha\right) \cdot \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) + 0} \]
    6. Simplified0.4

      \[\leadsto \color{blue}{\alpha \cdot \left(\alpha \cdot \left(u0 - \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right)} \]
      Proof

      [Start]0.4

      \[ \alpha \cdot \left(\left(-\alpha\right) \cdot \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) + 0 \]

      rational.json-simplify-4 [=>]0.4

      \[ \color{blue}{\alpha \cdot \left(\left(-\alpha\right) \cdot \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right)} \]

      rational.json-simplify-43 [=>]0.4

      \[ \color{blue}{\left(-\alpha\right) \cdot \left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \alpha\right)} \]

      rational.json-simplify-8 [=>]0.4

      \[ \color{blue}{\left(\alpha \cdot -1\right)} \cdot \left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \alpha\right) \]

      metadata-eval [<=]0.4

      \[ \left(\alpha \cdot \color{blue}{\left(-0.5 + -0.5\right)}\right) \cdot \left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \alpha\right) \]

      rational.json-simplify-51 [<=]0.4

      \[ \color{blue}{\left(\alpha \cdot -0.5 + -0.5 \cdot \alpha\right)} \cdot \left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \alpha\right) \]

      rational.json-simplify-2 [<=]0.4

      \[ \left(\alpha \cdot -0.5 + \color{blue}{\alpha \cdot -0.5}\right) \cdot \left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \alpha\right) \]

      rational.json-simplify-53 [<=]0.4

      \[ \color{blue}{\left(\alpha + \alpha\right) \cdot \left(\left(\alpha \cdot -0.5\right) \cdot \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right)} \]

      rational.json-simplify-2 [<=]0.4

      \[ \left(\alpha + \alpha\right) \cdot \color{blue}{\left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \left(\alpha \cdot -0.5\right)\right)} \]

      rational.json-simplify-2 [<=]0.4

      \[ \color{blue}{\left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \left(\alpha \cdot -0.5\right)\right) \cdot \left(\alpha + \alpha\right)} \]

      rational.json-simplify-51 [<=]0.4

      \[ \color{blue}{\left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \left(\alpha \cdot -0.5\right)\right) \cdot \alpha + \alpha \cdot \left(\left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + \left(-0.5 \cdot {u0}^{2} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \left(\alpha \cdot -0.5\right)\right)} \]
    7. Applied egg-rr0.4

      \[\leadsto \color{blue}{\alpha \cdot \left(\alpha \cdot \left(u0 - \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) + 0} \]
    8. Simplified0.4

      \[\leadsto \color{blue}{\left(u0 - \left(-0.25 \cdot {u0}^{4} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.5 \cdot {u0}^{2}\right)\right)\right) \cdot \left(\alpha \cdot \alpha\right)} \]
      Proof

      [Start]0.4

      \[ \alpha \cdot \left(\alpha \cdot \left(u0 - \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right) + 0 \]

      rational.json-simplify-4 [=>]0.4

      \[ \color{blue}{\alpha \cdot \left(\alpha \cdot \left(u0 - \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right)} \]

      rational.json-simplify-43 [<=]0.4

      \[ \color{blue}{\left(u0 - \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right) \cdot \left(\alpha \cdot \alpha\right)} \]

      rational.json-simplify-1 [=>]0.4

      \[ \left(u0 - \left(-0.5 \cdot {u0}^{2} + \color{blue}{\left(-0.25 \cdot {u0}^{4} + -0.3333333333333333 \cdot {u0}^{3}\right)}\right)\right) \cdot \left(\alpha \cdot \alpha\right) \]

      rational.json-simplify-41 [=>]0.4

      \[ \left(u0 - \color{blue}{\left(-0.25 \cdot {u0}^{4} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.5 \cdot {u0}^{2}\right)\right)}\right) \cdot \left(\alpha \cdot \alpha\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9620000123977661:\\ \;\;\;\;\left(-\alpha\right) \cdot \frac{1}{\frac{1}{\log \left(1 - u0\right) \cdot \alpha}}\\ \mathbf{else}:\\ \;\;\;\;\left(u0 - \left(-0.25 \cdot {u0}^{4} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.5 \cdot {u0}^{2}\right)\right)\right) \cdot \left(\alpha \cdot \alpha\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.5
Cost10372
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9620000123977661:\\ \;\;\;\;\left(-\alpha\right) \cdot \frac{1}{\frac{1}{\log \left(1 - u0\right) \cdot \alpha}}\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(\alpha \cdot \left(u0 - \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\right)\\ \end{array} \]
Alternative 2
Error0.6
Cost10244
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9819999933242798:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {\left(u0 \cdot \alpha\right)}^{2} + {\alpha}^{2} \cdot \left(u0 + {u0}^{3} \cdot 0.3333333333333333\right)\\ \end{array} \]
Alternative 3
Error0.6
Cost7076
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9819999933242798:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\alpha \cdot \left(\alpha \cdot \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\left(-u0\right) + -0.5 \cdot {u0}^{2}\right)\right)\right)\\ \end{array} \]
Alternative 4
Error0.6
Cost7012
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9819999933242798:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(\alpha \cdot \left(u0 - \left(-0.5 \cdot {u0}^{2} + -0.3333333333333333 \cdot {u0}^{3}\right)\right)\right)\\ \end{array} \]
Alternative 5
Error1.1
Cost6884
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9975000023841858:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{\alpha}^{2} \cdot u0 + 0.5 \cdot {\left(u0 \cdot \alpha\right)}^{2}\\ \end{array} \]
Alternative 6
Error1.1
Cost3716
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9975000023841858:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(u0 \cdot \alpha + {u0}^{2} \cdot \left(\alpha \cdot 0.5\right)\right)\\ \end{array} \]
Alternative 7
Error1.1
Cost3716
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9975000023841858:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(\left(-u0\right) + -0.5 \cdot {u0}^{2}\right)\\ \end{array} \]
Alternative 8
Error1.1
Cost3652
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9975000023841858:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(\alpha \cdot \left(u0 - {u0}^{2} \cdot -0.5\right)\right)\\ \end{array} \]
Alternative 9
Error3.2
Cost3588
\[\begin{array}{l} \mathbf{if}\;1 - u0 \leq 0.9998000264167786:\\ \;\;\;\;\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\alpha \cdot \left(u0 \cdot \alpha\right)\\ \end{array} \]
Alternative 10
Error8.1
Cost160
\[\alpha \cdot \left(u0 \cdot \alpha\right) \]

Error

Reproduce?

herbie shell --seed 2023074 
(FPCore (alpha u0)
  :name "Beckmann Distribution sample, tan2theta, alphax == alphay"
  :precision binary32
  :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0)) (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
  (* (* (- alpha) alpha) (log (- 1.0 u0))))