
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= (* x x) 5e-259)
(fma 0.5 (* (/ x y) (/ x y)) -1.0)
(if (<= (* x x) 5e-72)
t_1
(if (<= (* x x) 100000000000.0)
(+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))
(if (<= (* x x) 1e+247) t_1 (fma (* (/ y x) (/ y x)) -8.0 1.0)))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if ((x * x) <= 5e-259) {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
} else if ((x * x) <= 5e-72) {
tmp = t_1;
} else if ((x * x) <= 100000000000.0) {
tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
} else if ((x * x) <= 1e+247) {
tmp = t_1;
} else {
tmp = fma(((y / x) * (y / x)), -8.0, 1.0);
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) tmp = 0.0 if (Float64(x * x) <= 5e-259) tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); elseif (Float64(x * x) <= 5e-72) tmp = t_1; elseif (Float64(x * x) <= 100000000000.0) tmp = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)); elseif (Float64(x * x) <= 1e+247) tmp = t_1; else tmp = fma(Float64(Float64(y / x) * Float64(y / x)), -8.0, 1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-259], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e-72], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 100000000000.0], N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+247], t$95$1, N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0 + 1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-259}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-72}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 100000000000:\\
\;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\mathbf{elif}\;x \cdot x \leq 10^{+247}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4.99999999999999977e-259Initial program 50.0%
Taylor expanded in x around 0 70.4%
fma-neg70.4%
unpow270.4%
unpow270.4%
times-frac88.6%
metadata-eval88.6%
Simplified88.6%
if 4.99999999999999977e-259 < (*.f64 x x) < 4.9999999999999996e-72 or 1e11 < (*.f64 x x) < 9.99999999999999952e246Initial program 86.4%
if 4.9999999999999996e-72 < (*.f64 x x) < 1e11Initial program 46.7%
Taylor expanded in x around 0 27.7%
*-commutative27.7%
unpow227.7%
associate-*r*27.7%
Simplified27.7%
div-sub27.5%
associate-*r*27.5%
associate-/r*27.5%
frac-times27.5%
pow227.5%
*-commutative27.5%
*-inverses81.0%
Applied egg-rr81.0%
unpow281.0%
clear-num81.0%
un-div-inv81.0%
Applied egg-rr81.0%
if 9.99999999999999952e246 < (*.f64 x x) Initial program 8.1%
Taylor expanded in x around inf 81.6%
associate--l+81.6%
distribute-rgt-out--81.6%
metadata-eval81.6%
*-commutative81.6%
+-commutative81.6%
*-commutative81.6%
fma-def81.6%
unpow281.6%
unpow281.6%
times-frac92.3%
Simplified92.3%
Final simplification88.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= x 7.5e-130)
(fma 0.5 (* (/ x y) (/ x y)) -1.0)
(if (<= x 1.1e-34)
t_1
(if (<= x 260000.0)
(+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))
(if (<= x 2.9e+124) t_1 (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if (x <= 7.5e-130) {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
} else if (x <= 1.1e-34) {
tmp = t_1;
} else if (x <= 260000.0) {
tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
} else if (x <= 2.9e+124) {
tmp = t_1;
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) tmp = 0.0 if (x <= 7.5e-130) tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); elseif (x <= 1.1e-34) tmp = t_1; elseif (x <= 260000.0) tmp = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)); elseif (x <= 2.9e+124) tmp = t_1; else tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 7.5e-130], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 1.1e-34], t$95$1, If[LessEqual[x, 260000.0], N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.9e+124], t$95$1, N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{if}\;x \leq 7.5 \cdot 10^{-130}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-34}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 260000:\\
\;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+124}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\end{array}
\end{array}
if x < 7.4999999999999994e-130Initial program 45.0%
Taylor expanded in x around 0 50.2%
fma-neg50.2%
unpow250.2%
unpow250.2%
times-frac60.6%
metadata-eval60.6%
Simplified60.6%
if 7.4999999999999994e-130 < x < 1.0999999999999999e-34 or 2.6e5 < x < 2.90000000000000021e124Initial program 87.5%
if 1.0999999999999999e-34 < x < 2.6e5Initial program 50.0%
Taylor expanded in x around 0 31.0%
*-commutative31.0%
unpow231.0%
associate-*r*31.0%
Simplified31.0%
div-sub30.7%
associate-*r*30.7%
associate-/r*30.7%
frac-times30.7%
pow230.7%
*-commutative30.7%
*-inverses81.0%
Applied egg-rr81.0%
unpow281.0%
clear-num81.0%
un-div-inv81.0%
Applied egg-rr81.0%
if 2.90000000000000021e124 < x Initial program 12.8%
Taylor expanded in x around inf 13.0%
unpow213.0%
Simplified13.0%
Taylor expanded in x around inf 79.0%
unpow279.0%
unpow279.0%
times-frac91.4%
unpow291.4%
Simplified91.4%
unpow291.4%
clear-num91.4%
un-div-inv91.4%
Applied egg-rr91.4%
Final simplification72.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
(if (<= (* x x) 5e-259)
t_2
(if (<= (* x x) 5e-72)
t_1
(if (<= (* x x) 100000000000.0)
t_2
(if (<= (* x x) 1e+247) t_1 (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double t_2 = -1.0 + (((x / y) / (y / x)) / 4.0);
double tmp;
if ((x * x) <= 5e-259) {
tmp = t_2;
} else if ((x * x) <= 5e-72) {
tmp = t_1;
} else if ((x * x) <= 100000000000.0) {
tmp = t_2;
} else if ((x * x) <= 1e+247) {
tmp = t_1;
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = y * (y * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
t_2 = (-1.0d0) + (((x / y) / (y / x)) / 4.0d0)
if ((x * x) <= 5d-259) then
tmp = t_2
else if ((x * x) <= 5d-72) then
tmp = t_1
else if ((x * x) <= 100000000000.0d0) then
tmp = t_2
else if ((x * x) <= 1d+247) then
tmp = t_1
else
tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double t_2 = -1.0 + (((x / y) / (y / x)) / 4.0);
double tmp;
if ((x * x) <= 5e-259) {
tmp = t_2;
} else if ((x * x) <= 5e-72) {
tmp = t_1;
} else if ((x * x) <= 100000000000.0) {
tmp = t_2;
} else if ((x * x) <= 1e+247) {
tmp = t_1;
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) t_2 = -1.0 + (((x / y) / (y / x)) / 4.0) tmp = 0 if (x * x) <= 5e-259: tmp = t_2 elif (x * x) <= 5e-72: tmp = t_1 elif (x * x) <= 100000000000.0: tmp = t_2 elif (x * x) <= 1e+247: tmp = t_1 else: tmp = 1.0 + (-4.0 * ((y / x) / (x / y))) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) t_2 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)) tmp = 0.0 if (Float64(x * x) <= 5e-259) tmp = t_2; elseif (Float64(x * x) <= 5e-72) tmp = t_1; elseif (Float64(x * x) <= 100000000000.0) tmp = t_2; elseif (Float64(x * x) <= 1e+247) tmp = t_1; else tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = ((x * x) - t_0) / ((x * x) + t_0); t_2 = -1.0 + (((x / y) / (y / x)) / 4.0); tmp = 0.0; if ((x * x) <= 5e-259) tmp = t_2; elseif ((x * x) <= 5e-72) tmp = t_1; elseif ((x * x) <= 100000000000.0) tmp = t_2; elseif ((x * x) <= 1e+247) tmp = t_1; else tmp = 1.0 + (-4.0 * ((y / x) / (x / y))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-259], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e-72], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 100000000000.0], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+247], t$95$1, N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
t_2 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-259}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-72}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 100000000000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+247}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\end{array}
\end{array}
if (*.f64 x x) < 4.99999999999999977e-259 or 4.9999999999999996e-72 < (*.f64 x x) < 1e11Initial program 49.4%
Taylor expanded in x around 0 45.2%
*-commutative45.2%
unpow245.2%
associate-*r*45.2%
Simplified45.2%
div-sub45.2%
associate-*r*45.2%
associate-/r*45.2%
frac-times45.2%
pow245.2%
*-commutative45.2%
*-inverses86.8%
Applied egg-rr86.8%
unpow286.8%
clear-num86.8%
un-div-inv86.8%
Applied egg-rr86.8%
if 4.99999999999999977e-259 < (*.f64 x x) < 4.9999999999999996e-72 or 1e11 < (*.f64 x x) < 9.99999999999999952e246Initial program 86.4%
if 9.99999999999999952e246 < (*.f64 x x) Initial program 8.1%
Taylor expanded in x around inf 8.3%
unpow28.3%
Simplified8.3%
Taylor expanded in x around inf 81.6%
unpow281.6%
unpow281.6%
times-frac92.0%
unpow292.0%
Simplified92.0%
unpow292.0%
clear-num92.0%
un-div-inv92.0%
Applied egg-rr92.0%
Final simplification88.4%
(FPCore (x y) :precision binary64 (if (<= (* x x) 1e+173) (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0)) (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))
double code(double x, double y) {
double tmp;
if ((x * x) <= 1e+173) {
tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x * x) <= 1d+173) then
tmp = (-1.0d0) + (((x / y) / (y / x)) / 4.0d0)
else
tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x * x) <= 1e+173) {
tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x * x) <= 1e+173: tmp = -1.0 + (((x / y) / (y / x)) / 4.0) else: tmp = 1.0 + (-4.0 * ((y / x) / (x / y))) return tmp
function code(x, y) tmp = 0.0 if (Float64(x * x) <= 1e+173) tmp = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)); else tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x * x) <= 1e+173) tmp = -1.0 + (((x / y) / (y / x)) / 4.0); else tmp = 1.0 + (-4.0 * ((y / x) / (x / y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+173], N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+173}:\\
\;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\mathbf{else}:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\end{array}
\end{array}
if (*.f64 x x) < 1e173Initial program 64.2%
Taylor expanded in x around 0 44.5%
*-commutative44.5%
unpow244.5%
associate-*r*44.5%
Simplified44.5%
div-sub44.1%
associate-*r*44.1%
associate-/r*44.1%
frac-times44.1%
pow244.1%
*-commutative44.1%
*-inverses75.0%
Applied egg-rr75.0%
unpow275.0%
clear-num75.0%
un-div-inv75.0%
Applied egg-rr75.0%
if 1e173 < (*.f64 x x) Initial program 22.9%
Taylor expanded in x around inf 20.7%
unpow220.7%
Simplified20.7%
Taylor expanded in x around inf 80.8%
unpow280.8%
unpow280.8%
times-frac89.4%
unpow289.4%
Simplified89.4%
unpow289.4%
clear-num89.4%
un-div-inv89.4%
Applied egg-rr89.4%
Final simplification80.9%
(FPCore (x y) :precision binary64 (if (<= x 3.2e+86) -1.0 (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= 3.2e+86) {
tmp = -1.0;
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 3.2d+86) then
tmp = -1.0d0
else
tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 3.2e+86) {
tmp = -1.0;
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 3.2e+86: tmp = -1.0 else: tmp = 1.0 + (-4.0 * ((y / x) / (x / y))) return tmp
function code(x, y) tmp = 0.0 if (x <= 3.2e+86) tmp = -1.0; else tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 3.2e+86) tmp = -1.0; else tmp = 1.0 + (-4.0 * ((y / x) / (x / y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 3.2e+86], -1.0, N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{+86}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\end{array}
\end{array}
if x < 3.2e86Initial program 53.3%
Taylor expanded in x around 0 59.1%
if 3.2e86 < x Initial program 26.3%
Taylor expanded in x around inf 23.9%
unpow223.9%
Simplified23.9%
Taylor expanded in x around inf 78.4%
unpow278.4%
unpow278.4%
times-frac88.7%
unpow288.7%
Simplified88.7%
unpow288.7%
clear-num88.7%
un-div-inv88.7%
Applied egg-rr88.7%
Final simplification65.7%
(FPCore (x y) :precision binary64 (if (<= x 9.5e+86) -1.0 1.0))
double code(double x, double y) {
double tmp;
if (x <= 9.5e+86) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 9.5d+86) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 9.5e+86) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 9.5e+86: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= 9.5e+86) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 9.5e+86) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 9.5e+86], -1.0, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{+86}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 9.50000000000000028e86Initial program 53.3%
Taylor expanded in x around 0 59.1%
if 9.50000000000000028e86 < x Initial program 26.3%
Taylor expanded in x around inf 88.3%
Final simplification65.6%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 47.3%
Taylor expanded in x around 0 48.6%
Final simplification48.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (* y y) 4.0))
(t_1 (+ (* x x) t_0))
(t_2 (/ t_0 t_1))
(t_3 (* (* y 4.0) y)))
(if (< (/ (- (* x x) t_3) (+ (* x x) t_3)) 0.9743233849626781)
(- (/ (* x x) t_1) t_2)
(- (pow (/ x (sqrt t_1)) 2.0) t_2))))
double code(double x, double y) {
double t_0 = (y * y) * 4.0;
double t_1 = (x * x) + t_0;
double t_2 = t_0 / t_1;
double t_3 = (y * 4.0) * y;
double tmp;
if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
tmp = ((x * x) / t_1) - t_2;
} else {
tmp = pow((x / sqrt(t_1)), 2.0) - t_2;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (y * y) * 4.0d0
t_1 = (x * x) + t_0
t_2 = t_0 / t_1
t_3 = (y * 4.0d0) * y
if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781d0) then
tmp = ((x * x) / t_1) - t_2
else
tmp = ((x / sqrt(t_1)) ** 2.0d0) - t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y * y) * 4.0;
double t_1 = (x * x) + t_0;
double t_2 = t_0 / t_1;
double t_3 = (y * 4.0) * y;
double tmp;
if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
tmp = ((x * x) / t_1) - t_2;
} else {
tmp = Math.pow((x / Math.sqrt(t_1)), 2.0) - t_2;
}
return tmp;
}
def code(x, y): t_0 = (y * y) * 4.0 t_1 = (x * x) + t_0 t_2 = t_0 / t_1 t_3 = (y * 4.0) * y tmp = 0 if (((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781: tmp = ((x * x) / t_1) - t_2 else: tmp = math.pow((x / math.sqrt(t_1)), 2.0) - t_2 return tmp
function code(x, y) t_0 = Float64(Float64(y * y) * 4.0) t_1 = Float64(Float64(x * x) + t_0) t_2 = Float64(t_0 / t_1) t_3 = Float64(Float64(y * 4.0) * y) tmp = 0.0 if (Float64(Float64(Float64(x * x) - t_3) / Float64(Float64(x * x) + t_3)) < 0.9743233849626781) tmp = Float64(Float64(Float64(x * x) / t_1) - t_2); else tmp = Float64((Float64(x / sqrt(t_1)) ^ 2.0) - t_2); end return tmp end
function tmp_2 = code(x, y) t_0 = (y * y) * 4.0; t_1 = (x * x) + t_0; t_2 = t_0 / t_1; t_3 = (y * 4.0) * y; tmp = 0.0; if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) tmp = ((x * x) / t_1) - t_2; else tmp = ((x / sqrt(t_1)) ^ 2.0) - t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * y), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[Less[N[(N[(N[(x * x), $MachinePrecision] - t$95$3), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision], 0.9743233849626781], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], N[(N[Power[N[(x / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot y\right) \cdot 4\\
t_1 := x \cdot x + t_0\\
t_2 := \frac{t_0}{t_1}\\
t_3 := \left(y \cdot 4\right) \cdot y\\
\mathbf{if}\;\frac{x \cdot x - t_3}{x \cdot x + t_3} < 0.9743233849626781:\\
\;\;\;\;\frac{x \cdot x}{t_1} - t_2\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{x}{\sqrt{t_1}}\right)}^{2} - t_2\\
\end{array}
\end{array}
herbie shell --seed 2023213
(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))))