| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 20864 |
\[\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{x + y \cdot -2}{t_0} \cdot \left(\frac{x}{t_0} + y \cdot \frac{2}{t_0}\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 (hypot x (* y 2.0)))) (log (exp (- (pow (/ x t_0) 2.0) (pow (* 2.0 (/ y t_0)) 2.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 = hypot(x, (y * 2.0));
return log(exp((pow((x / t_0), 2.0) - pow((2.0 * (y / t_0)), 2.0))));
}
public static double code(double x, double y) {
return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
public static double code(double x, double y) {
double t_0 = Math.hypot(x, (y * 2.0));
return Math.log(Math.exp((Math.pow((x / t_0), 2.0) - Math.pow((2.0 * (y / t_0)), 2.0))));
}
def code(x, y): return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y))
def code(x, y): t_0 = math.hypot(x, (y * 2.0)) return math.log(math.exp((math.pow((x / t_0), 2.0) - math.pow((2.0 * (y / t_0)), 2.0))))
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 = hypot(x, Float64(y * 2.0)) return log(exp(Float64((Float64(x / t_0) ^ 2.0) - (Float64(2.0 * Float64(y / t_0)) ^ 2.0)))) end
function tmp = code(x, y) tmp = ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)); end
function tmp = code(x, y) t_0 = hypot(x, (y * 2.0)); tmp = log(exp((((x / t_0) ^ 2.0) - ((2.0 * (y / t_0)) ^ 2.0)))); 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[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[Log[N[Exp[N[(N[Power[N[(x / t$95$0), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[(2.0 * N[(y / t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $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 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\log \left(e^{{\left(\frac{x}{t_0}\right)}^{2} - {\left(2 \cdot \frac{y}{t_0}\right)}^{2}}\right)
\end{array}
Results
| Original | 31.7 |
|---|---|
| Target | 31.4 |
| Herbie | 0.1 |
Initial program 31.7
Applied egg-rr31.4
Simplified31.4
[Start]31.4 | \[ \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 [<=]31.4 | \[ \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* [=>]31.0 | \[ \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot 4}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \cdot y
\] |
associate-*l/ [=>]31.4 | \[ \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{\left(y \cdot 4\right) \cdot y}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}
\] |
*-commutative [<=]31.4 | \[ \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}
\] |
Applied egg-rr32.5
Applied egg-rr0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 20864 |
| Alternative 2 | |
|---|---|
| Error | 3.7 |
| Cost | 8776 |
| Alternative 3 | |
|---|---|
| Error | 12.4 |
| Cost | 7236 |
| Alternative 4 | |
|---|---|
| Error | 12.4 |
| Cost | 7236 |
| Alternative 5 | |
|---|---|
| Error | 12.6 |
| Cost | 1864 |
| Alternative 6 | |
|---|---|
| Error | 12.6 |
| Cost | 1736 |
| Alternative 7 | |
|---|---|
| Error | 17.5 |
| Cost | 1360 |
| Alternative 8 | |
|---|---|
| Error | 17.5 |
| Cost | 1234 |
| Alternative 9 | |
|---|---|
| Error | 18.0 |
| Cost | 1100 |
| Alternative 10 | |
|---|---|
| Error | 18.0 |
| Cost | 592 |
| Alternative 11 | |
|---|---|
| Error | 32.1 |
| Cost | 64 |
herbie shell --seed 2022356
(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))))