| Alternative 1 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 71492 |
(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (* x x) (* y (* y -4.0)))) (t_1 (* y (* y 4.0))))
(if (<= t_1 5e-309)
(fma
-8.0
(pow
(pow
(/
(cbrt (pow (cbrt y) 2.0))
(/
(* (pow (pow (cbrt x) 2.0) 0.3333333333333333) (cbrt (cbrt x)))
(cbrt (cbrt y))))
2.0)
3.0)
1.0)
(if (<= t_1 5e+117)
(/ t_0 (+ t_1 (* x x)))
(if (<= t_1 1e+161)
(+ 1.0 (* -8.0 (* y (/ (/ y x) x))))
(if (<= t_1 2e+196)
(/ t_0 (fma x x t_1))
(if (<= t_1 5e+237) 1.0 (+ (* (/ x y) (/ x (* y 4.0))) -1.0))))))))double code(double x, double y) {
return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
double code(double x, double y) {
double t_0 = (x * x) + (y * (y * -4.0));
double t_1 = y * (y * 4.0);
double tmp;
if (t_1 <= 5e-309) {
tmp = fma(-8.0, pow(pow((cbrt(pow(cbrt(y), 2.0)) / ((pow(pow(cbrt(x), 2.0), 0.3333333333333333) * cbrt(cbrt(x))) / cbrt(cbrt(y)))), 2.0), 3.0), 1.0);
} else if (t_1 <= 5e+117) {
tmp = t_0 / (t_1 + (x * x));
} else if (t_1 <= 1e+161) {
tmp = 1.0 + (-8.0 * (y * ((y / x) / x)));
} else if (t_1 <= 2e+196) {
tmp = t_0 / fma(x, x, t_1);
} else if (t_1 <= 5e+237) {
tmp = 1.0;
} else {
tmp = ((x / y) * (x / (y * 4.0))) + -1.0;
}
return tmp;
}
function code(x, y) return Float64(Float64(Float64(x * x) - Float64(Float64(y * 4.0) * y)) / Float64(Float64(x * x) + Float64(Float64(y * 4.0) * y))) end
function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * Float64(y * -4.0))) t_1 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_1 <= 5e-309) tmp = fma(-8.0, ((Float64(cbrt((cbrt(y) ^ 2.0)) / Float64(Float64(((cbrt(x) ^ 2.0) ^ 0.3333333333333333) * cbrt(cbrt(x))) / cbrt(cbrt(y)))) ^ 2.0) ^ 3.0), 1.0); elseif (t_1 <= 5e+117) tmp = Float64(t_0 / Float64(t_1 + Float64(x * x))); elseif (t_1 <= 1e+161) tmp = Float64(1.0 + Float64(-8.0 * Float64(y * Float64(Float64(y / x) / x)))); elseif (t_1 <= 2e+196) tmp = Float64(t_0 / fma(x, x, t_1)); elseif (t_1 <= 5e+237) tmp = 1.0; else tmp = Float64(Float64(Float64(x / y) * Float64(x / Float64(y * 4.0))) + -1.0); end return tmp end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-309], N[(-8.0 * N[Power[N[Power[N[(N[Power[N[Power[N[Power[y, 1/3], $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] / N[(N[(N[Power[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] * N[Power[N[Power[x, 1/3], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[N[Power[y, 1/3], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 3.0], $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[t$95$1, 5e+117], N[(t$95$0 / N[(t$95$1 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+161], N[(1.0 + N[(-8.0 * N[(y * N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+196], N[(t$95$0 / N[(x * x + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+237], 1.0, N[(N[(N[(x / y), $MachinePrecision] * N[(x / N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
t_0 := x \cdot x + y \cdot \left(y \cdot -4\right)\\
t_1 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{fma}\left(-8, {\left({\left(\frac{\sqrt[3]{{\left(\sqrt[3]{y}\right)}^{2}}}{\frac{{\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{0.3333333333333333} \cdot \sqrt[3]{\sqrt[3]{x}}}{\sqrt[3]{\sqrt[3]{y}}}}\right)}^{2}\right)}^{3}, 1\right)\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+117}:\\
\;\;\;\;\frac{t_0}{t_1 + x \cdot x}\\
\mathbf{elif}\;t_1 \leq 10^{+161}:\\
\;\;\;\;1 + -8 \cdot \left(y \cdot \frac{\frac{y}{x}}{x}\right)\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(x, x, t_1\right)}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+237}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y \cdot 4} + -1\\
\end{array}
| Original | 50.0% |
|---|---|
| Target | 50.5% |
| Herbie | 78.9% |
if (*.f64 (*.f64 y 4) y) < 4.9999999999999995e-309Initial program 51.9%
Simplified51.9%
[Start]51.9 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
|---|---|
*-commutative [=>]51.9 | \[ \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
fma-def [=>]51.9 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}
\] |
*-commutative [=>]51.9 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}
\] |
Taylor expanded in x around inf 76.7%
Simplified89.4%
[Start]76.7 | \[ \left(1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}\right) - 4 \cdot \frac{{y}^{2}}{{x}^{2}}
\] |
|---|---|
associate--l+ [=>]76.7 | \[ \color{blue}{1 + \left(-4 \cdot \frac{{y}^{2}}{{x}^{2}} - 4 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}
\] |
distribute-rgt-out-- [=>]76.7 | \[ 1 + \color{blue}{\frac{{y}^{2}}{{x}^{2}} \cdot \left(-4 - 4\right)}
\] |
metadata-eval [=>]76.7 | \[ 1 + \frac{{y}^{2}}{{x}^{2}} \cdot \color{blue}{-8}
\] |
*-commutative [<=]76.7 | \[ 1 + \color{blue}{-8 \cdot \frac{{y}^{2}}{{x}^{2}}}
\] |
+-commutative [<=]76.7 | \[ \color{blue}{-8 \cdot \frac{{y}^{2}}{{x}^{2}} + 1}
\] |
fma-def [=>]76.7 | \[ \color{blue}{\mathsf{fma}\left(-8, \frac{{y}^{2}}{{x}^{2}}, 1\right)}
\] |
unpow2 [=>]76.7 | \[ \mathsf{fma}\left(-8, \frac{\color{blue}{y \cdot y}}{{x}^{2}}, 1\right)
\] |
unpow2 [=>]76.7 | \[ \mathsf{fma}\left(-8, \frac{y \cdot y}{\color{blue}{x \cdot x}}, 1\right)
\] |
times-frac [=>]89.4 | \[ \mathsf{fma}\left(-8, \color{blue}{\frac{y}{x} \cdot \frac{y}{x}}, 1\right)
\] |
Applied egg-rr89.4%
Applied egg-rr89.4%
Applied egg-rr89.4%
if 4.9999999999999995e-309 < (*.f64 (*.f64 y 4) y) < 4.99999999999999983e117Initial program 74.5%
if 4.99999999999999983e117 < (*.f64 (*.f64 y 4) y) < 1e161Initial program 69.5%
Simplified69.5%
[Start]69.5 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
|---|---|
*-commutative [=>]69.5 | \[ \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
fma-def [=>]69.5 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}
\] |
*-commutative [=>]69.5 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}
\] |
Taylor expanded in x around inf 42.5%
Simplified42.6%
[Start]42.5 | \[ \left(1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}\right) - 4 \cdot \frac{{y}^{2}}{{x}^{2}}
\] |
|---|---|
associate--l+ [=>]42.6 | \[ \color{blue}{1 + \left(-4 \cdot \frac{{y}^{2}}{{x}^{2}} - 4 \cdot \frac{{y}^{2}}{{x}^{2}}\right)}
\] |
unpow2 [=>]42.6 | \[ 1 + \left(-4 \cdot \frac{\color{blue}{y \cdot y}}{{x}^{2}} - 4 \cdot \frac{{y}^{2}}{{x}^{2}}\right)
\] |
unpow2 [=>]42.6 | \[ 1 + \left(-4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} - 4 \cdot \frac{{y}^{2}}{{x}^{2}}\right)
\] |
associate-*r/ [=>]42.6 | \[ 1 + \left(-4 \cdot \frac{y \cdot y}{x \cdot x} - \color{blue}{\frac{4 \cdot {y}^{2}}{{x}^{2}}}\right)
\] |
*-commutative [=>]42.6 | \[ 1 + \left(-4 \cdot \frac{y \cdot y}{x \cdot x} - \frac{\color{blue}{{y}^{2} \cdot 4}}{{x}^{2}}\right)
\] |
unpow2 [=>]42.6 | \[ 1 + \left(-4 \cdot \frac{y \cdot y}{x \cdot x} - \frac{\color{blue}{\left(y \cdot y\right)} \cdot 4}{{x}^{2}}\right)
\] |
associate-*r* [<=]42.6 | \[ 1 + \left(-4 \cdot \frac{y \cdot y}{x \cdot x} - \frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{{x}^{2}}\right)
\] |
unpow2 [=>]42.6 | \[ 1 + \left(-4 \cdot \frac{y \cdot y}{x \cdot x} - \frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{x \cdot x}}\right)
\] |
Taylor expanded in y around 0 42.6%
Simplified42.6%
[Start]42.6 | \[ 1 + -8 \cdot \frac{{y}^{2}}{{x}^{2}}
\] |
|---|---|
*-commutative [=>]42.6 | \[ 1 + \color{blue}{\frac{{y}^{2}}{{x}^{2}} \cdot -8}
\] |
unpow2 [=>]42.6 | \[ 1 + \frac{\color{blue}{y \cdot y}}{{x}^{2}} \cdot -8
\] |
unpow2 [=>]42.6 | \[ 1 + \frac{y \cdot y}{\color{blue}{x \cdot x}} \cdot -8
\] |
associate-*r/ [<=]42.6 | \[ 1 + \color{blue}{\left(y \cdot \frac{y}{x \cdot x}\right)} \cdot -8
\] |
associate-/r* [=>]42.6 | \[ 1 + \left(y \cdot \color{blue}{\frac{\frac{y}{x}}{x}}\right) \cdot -8
\] |
if 1e161 < (*.f64 (*.f64 y 4) y) < 1.9999999999999999e196Initial program 73.8%
Simplified73.8%
[Start]73.8 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
|---|---|
*-commutative [=>]73.8 | \[ \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
fma-def [=>]73.8 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}
\] |
*-commutative [=>]73.8 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}
\] |
if 1.9999999999999999e196 < (*.f64 (*.f64 y 4) y) < 5.0000000000000002e237Initial program 77.2%
Simplified77.2%
[Start]77.2 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
|---|---|
*-commutative [=>]77.2 | \[ \frac{x \cdot x - \color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\] |
fma-def [=>]77.2 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}
\] |
*-commutative [=>]77.2 | \[ \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}
\] |
Taylor expanded in x around inf 31.9%
if 5.0000000000000002e237 < (*.f64 (*.f64 y 4) y) Initial program 13.9%
Taylor expanded in x around 0 13.4%
Simplified13.4%
[Start]13.4 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{4 \cdot {y}^{2}}
\] |
|---|---|
*-commutative [=>]13.4 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{{y}^{2} \cdot 4}}
\] |
unpow2 [=>]13.4 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{\left(y \cdot y\right)} \cdot 4}
\] |
associate-*r* [<=]13.4 | \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{y \cdot \left(y \cdot 4\right)}}
\] |
Applied egg-rr84.8%
Final simplification78.9%
| Alternative 1 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 71492 |
| Alternative 2 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 58820 |
| Alternative 3 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 52356 |
| Alternative 4 | |
|---|---|
| Accuracy | 78.8% |
| Cost | 20100 |
| Alternative 5 | |
|---|---|
| Accuracy | 78.8% |
| Cost | 9040 |
| Alternative 6 | |
|---|---|
| Accuracy | 78.8% |
| Cost | 2768 |
| Alternative 7 | |
|---|---|
| Accuracy | 73.7% |
| Cost | 1869 |
| Alternative 8 | |
|---|---|
| Accuracy | 74.5% |
| Cost | 1233 |
| Alternative 9 | |
|---|---|
| Accuracy | 74.7% |
| Cost | 1232 |
| Alternative 10 | |
|---|---|
| Accuracy | 74.1% |
| Cost | 592 |
| Alternative 11 | |
|---|---|
| Accuracy | 49.9% |
| Cost | 64 |
herbie shell --seed 2023129
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))