| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 10372 |
(FPCore (alpha u0) :precision binary32 (* (* (- alpha) alpha) (log (- 1.0 u0))))
(FPCore (alpha u0)
:precision binary32
(let* ((t_0 (log (- 1.0 u0))))
(if (<= (- 1.0 u0) 0.9649999737739563)
(* (* t_0 (* alpha (* alpha (/ -1.0 t_0)))) (- (- t_0)))
(*
(* alpha alpha)
(+
(* (pow u0 2.0) 0.5)
(-
u0
(+ (* -0.3333333333333333 (pow u0 3.0)) (* -0.25 (pow u0 4.0)))))))))float code(float alpha, float u0) {
return (-alpha * alpha) * logf((1.0f - u0));
}
float code(float alpha, float u0) {
float t_0 = logf((1.0f - u0));
float tmp;
if ((1.0f - u0) <= 0.9649999737739563f) {
tmp = (t_0 * (alpha * (alpha * (-1.0f / t_0)))) * -(-t_0);
} else {
tmp = (alpha * alpha) * ((powf(u0, 2.0f) * 0.5f) + (u0 - ((-0.3333333333333333f * powf(u0, 3.0f)) + (-0.25f * powf(u0, 4.0f)))));
}
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) :: t_0
real(4) :: tmp
t_0 = log((1.0e0 - u0))
if ((1.0e0 - u0) <= 0.9649999737739563e0) then
tmp = (t_0 * (alpha * (alpha * ((-1.0e0) / t_0)))) * -(-t_0)
else
tmp = (alpha * alpha) * (((u0 ** 2.0e0) * 0.5e0) + (u0 - (((-0.3333333333333333e0) * (u0 ** 3.0e0)) + ((-0.25e0) * (u0 ** 4.0e0)))))
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) t_0 = log(Float32(Float32(1.0) - u0)) tmp = Float32(0.0) if (Float32(Float32(1.0) - u0) <= Float32(0.9649999737739563)) tmp = Float32(Float32(t_0 * Float32(alpha * Float32(alpha * Float32(Float32(-1.0) / t_0)))) * Float32(-Float32(-t_0))); else tmp = Float32(Float32(alpha * alpha) * Float32(Float32((u0 ^ Float32(2.0)) * Float32(0.5)) + Float32(u0 - Float32(Float32(Float32(-0.3333333333333333) * (u0 ^ Float32(3.0))) + Float32(Float32(-0.25) * (u0 ^ Float32(4.0))))))); end return tmp end
function tmp = code(alpha, u0) tmp = (-alpha * alpha) * log((single(1.0) - u0)); end
function tmp_2 = code(alpha, u0) t_0 = log((single(1.0) - u0)); tmp = single(0.0); if ((single(1.0) - u0) <= single(0.9649999737739563)) tmp = (t_0 * (alpha * (alpha * (single(-1.0) / t_0)))) * -(-t_0); else tmp = (alpha * alpha) * (((u0 ^ single(2.0)) * single(0.5)) + (u0 - ((single(-0.3333333333333333) * (u0 ^ single(3.0))) + (single(-0.25) * (u0 ^ single(4.0)))))); end tmp_2 = tmp; end
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\begin{array}{l}
t_0 := \log \left(1 - u0\right)\\
\mathbf{if}\;1 - u0 \leq 0.9649999737739563:\\
\;\;\;\;\left(t_0 \cdot \left(\alpha \cdot \left(\alpha \cdot \frac{-1}{t_0}\right)\right)\right) \cdot \left(-\left(-t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\alpha \cdot \alpha\right) \cdot \left({u0}^{2} \cdot 0.5 + \left(u0 - \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)\\
\end{array}
Results
if (-.f32 1 u0) < 0.964999974Initial program 1.1
Applied egg-rr1.1
Applied egg-rr1.1
Simplified1.2
[Start]1.1 | \[ 0 \cdot \left(\left(\alpha \cdot \alpha\right) \cdot \left(\log \left(1 - u0\right) \cdot \frac{-1}{\log \left(1 - u0\right)}\right)\right) - \left(\left(\alpha \cdot \alpha\right) \cdot \left(\log \left(1 - u0\right) \cdot \frac{-1}{\log \left(1 - u0\right)}\right)\right) \cdot \left(-\log \left(1 - u0\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-102 [=>]1.1 | \[ \color{blue}{\left(\left(\alpha \cdot \alpha\right) \cdot \left(\log \left(1 - u0\right) \cdot \frac{-1}{\log \left(1 - u0\right)}\right)\right) \cdot \left(0 - \left(-\log \left(1 - u0\right)\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]1.2 | \[ \color{blue}{\left(\log \left(1 - u0\right) \cdot \left(\left(\alpha \cdot \alpha\right) \cdot \frac{-1}{\log \left(1 - u0\right)}\right)\right)} \cdot \left(0 - \left(-\log \left(1 - u0\right)\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-97 [<=]1.2 | \[ \left(\log \left(1 - u0\right) \cdot \left(\left(\alpha \cdot \alpha\right) \cdot \frac{-1}{\log \left(1 - u0\right)}\right)\right) \cdot \color{blue}{\left(-\left(-\log \left(1 - u0\right)\right)\right)}
\] |
Applied egg-rr1.2
Simplified1.2
[Start]1.2 | \[ \left(\log \left(1 - u0\right) \cdot \left(\alpha \cdot \left(\alpha \cdot \frac{-1}{\log \left(1 - u0\right)}\right) + 0\right)\right) \cdot \left(-\left(-\log \left(1 - u0\right)\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-85 [=>]1.2 | \[ \left(\log \left(1 - u0\right) \cdot \color{blue}{\left(\alpha \cdot \left(\alpha \cdot \frac{-1}{\log \left(1 - u0\right)}\right)\right)}\right) \cdot \left(-\left(-\log \left(1 - u0\right)\right)\right)
\] |
if 0.964999974 < (-.f32 1 u0) Initial program 16.6
Taylor expanded in u0 around 0 0.4
Simplified0.4
[Start]0.4 | \[ \left(\left(-\alpha\right) \cdot \alpha\right) \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)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4 | \[ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \color{blue}{\left(-0.5 \cdot {u0}^{2} + \left(-1 \cdot u0 + \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4 | \[ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-0.5 \cdot {u0}^{2} + \color{blue}{\left(-0.3333333333333333 \cdot {u0}^{3} + \left(-1 \cdot u0 + -0.25 \cdot {u0}^{4}\right)\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.4 | \[ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\color{blue}{u0 \cdot -1} + -0.25 \cdot {u0}^{4}\right)\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]0.4 | \[ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \left(-0.5 \cdot {u0}^{2} + \left(-0.3333333333333333 \cdot {u0}^{3} + \left(\color{blue}{\left(-u0\right)} + -0.25 \cdot {u0}^{4}\right)\right)\right)
\] |
Applied egg-rr0.4
Simplified0.4
[Start]0.4 | \[ \left(\alpha \cdot \alpha\right) \cdot \left({u0}^{2} \cdot 0.5\right) + \left(\alpha \cdot \alpha\right) \cdot \left(u0 - \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.4 | \[ \color{blue}{\left({u0}^{2} \cdot 0.5\right) \cdot \left(\alpha \cdot \alpha\right)} + \left(\alpha \cdot \alpha\right) \cdot \left(u0 - \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.4 | \[ \color{blue}{\left(\alpha \cdot \alpha\right) \cdot \left({u0}^{2} \cdot 0.5 + \left(u0 - \left(-0.3333333333333333 \cdot {u0}^{3} + -0.25 \cdot {u0}^{4}\right)\right)\right)}
\] |
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 10372 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 7012 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 7012 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 7012 |
| Alternative 5 | |
|---|---|
| Error | 1.1 |
| Cost | 3844 |
| Alternative 6 | |
|---|---|
| Error | 1.1 |
| Cost | 3652 |
| Alternative 7 | |
|---|---|
| Error | 3.2 |
| Cost | 3588 |
| Alternative 8 | |
|---|---|
| Error | 3.2 |
| Cost | 3588 |
| Alternative 9 | |
|---|---|
| Error | 1.1 |
| Cost | 3588 |
| Alternative 10 | |
|---|---|
| Error | 8.2 |
| Cost | 160 |
| Alternative 11 | |
|---|---|
| Error | 8.2 |
| Cost | 160 |
herbie shell --seed 2023090
(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))))