| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 20672.00 |
\[\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\frac{x}{t_0}}{\frac{t_0}{x}} - \frac{y}{\mathsf{fma}\left(0.25, x \cdot \frac{x}{y}, y\right)}
\end{array}
\]
(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 (hypot x (* y 2.0))))) (fma t_0 t_0 (/ (- y) (fma 0.25 (* x (/ x y)) y)))))
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 / hypot(x, (y * 2.0));
return fma(t_0, t_0, (-y / fma(0.25, (x * (x / y)), y)));
}
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(x / hypot(x, Float64(y * 2.0))) return fma(t_0, t_0, Float64(Float64(-y) / fma(0.25, Float64(x * Float64(x / y)), y))) 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[(x / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[((-y) / N[(0.25 * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $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 := \frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)}\\
\mathsf{fma}\left(t_0, t_0, \frac{-y}{\mathsf{fma}\left(0.25, x \cdot \frac{x}{y}, y\right)}\right)
\end{array}
| Original | 50.6% |
|---|---|
| Target | 51.1% |
| Herbie | 100.0% |
Initial program 50.6%
Applied egg-rr51.0%
Simplified51.1%
[Start]51.0 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot 4}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \cdot y\right)
\] |
|---|---|
sub-neg [<=]51.0 | \[ \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot 4}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \cdot y}
\] |
associate-*l/ [=>]50.6 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \color{blue}{\frac{\left(y \cdot 4\right) \cdot y}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}
\] |
*-commutative [<=]50.6 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}
\] |
associate-/l* [=>]51.1 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}}
\] |
Taylor expanded in x around 0 69.6%
Simplified69.6%
[Start]69.6 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y}{0.25 \cdot \frac{{x}^{2}}{y} + y}
\] |
|---|---|
fma-def [=>]69.6 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{y}, y\right)}}
\] |
unpow2 [=>]69.6 | \[ \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y}{\mathsf{fma}\left(0.25, \frac{\color{blue}{x \cdot x}}{y}, y\right)}
\] |
Applied egg-rr100.0%
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 20672.00 |
| Alternative 2 | |
|---|---|
| Accuracy | 80.4% |
| Cost | 14024.00 |
| Alternative 3 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 14016.00 |
| Alternative 4 | |
|---|---|
| Accuracy | 80.4% |
| Cost | 7504.00 |
| Alternative 5 | |
|---|---|
| Accuracy | 80.3% |
| Cost | 1744.00 |
| Alternative 6 | |
|---|---|
| Accuracy | 72.2% |
| Cost | 1234.00 |
| Alternative 7 | |
|---|---|
| Accuracy | 72.6% |
| Cost | 1232.00 |
| Alternative 8 | |
|---|---|
| Accuracy | 71.9% |
| Cost | 592.00 |
| Alternative 9 | |
|---|---|
| Accuracy | 50.7% |
| Cost | 64.00 |
herbie shell --seed 2023096
(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))))