(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 (/ (fma x x (* -4.0 (* y y))) (fma x x (* y (* y 4.0))))))
(if (<= (* x x) 0.0)
-1.0
(if (<= (* x x) 5e-218)
t_0
(if (<= (* x x) 2e-9) -1.0 (if (<= (* x x) 4e+198) t_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 = fma(x, x, (-4.0 * (y * y))) / fma(x, x, (y * (y * 4.0)));
double tmp;
if ((x * x) <= 0.0) {
tmp = -1.0;
} else if ((x * x) <= 5e-218) {
tmp = t_0;
} else if ((x * x) <= 2e-9) {
tmp = -1.0;
} else if ((x * x) <= 4e+198) {
tmp = t_0;
} else {
tmp = 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(fma(x, x, Float64(-4.0 * Float64(y * y))) / fma(x, x, Float64(y * Float64(y * 4.0)))) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = -1.0; elseif (Float64(x * x) <= 5e-218) tmp = t_0; elseif (Float64(x * x) <= 2e-9) tmp = -1.0; elseif (Float64(x * x) <= 4e+198) tmp = t_0; else tmp = 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 + N[(-4.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 5e-218], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 2e-9], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 4e+198], t$95$0, 1.0]]]]]
\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{\mathsf{fma}\left(x, x, -4 \cdot \left(y \cdot y\right)\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-218}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-9}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+198}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
| Original | 31.1 |
|---|---|
| Target | 30.8 |
| Herbie | 13.9 |
if (*.f64 x x) < 0.0 or 5.00000000000000041e-218 < (*.f64 x x) < 2.00000000000000012e-9Initial program 24.3
Simplified24.5
Taylor expanded in x around 0 15.4
if 0.0 < (*.f64 x x) < 5.00000000000000041e-218 or 2.00000000000000012e-9 < (*.f64 x x) < 4.00000000000000007e198Initial program 15.6
Simplified15.6
if 4.00000000000000007e198 < (*.f64 x x) Initial program 51.4
Simplified51.4
Taylor expanded in x around inf 10.9
Final simplification13.9
herbie shell --seed 2022210
(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))))