
(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 9 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 (hypot x (+ y y)))) (- (/ (/ x t_0) (/ t_0 x)) (pow (/ (* y 2.0) (hypot x (* y 2.0))) 2.0))))
double code(double x, double y) {
double t_0 = hypot(x, (y + y));
return ((x / t_0) / (t_0 / x)) - pow(((y * 2.0) / hypot(x, (y * 2.0))), 2.0);
}
public static double code(double x, double y) {
double t_0 = Math.hypot(x, (y + y));
return ((x / t_0) / (t_0 / x)) - Math.pow(((y * 2.0) / Math.hypot(x, (y * 2.0))), 2.0);
}
def code(x, y): t_0 = math.hypot(x, (y + y)) return ((x / t_0) / (t_0 / x)) - math.pow(((y * 2.0) / math.hypot(x, (y * 2.0))), 2.0)
function code(x, y) t_0 = hypot(x, Float64(y + y)) return Float64(Float64(Float64(x / t_0) / Float64(t_0 / x)) - (Float64(Float64(y * 2.0) / hypot(x, Float64(y * 2.0))) ^ 2.0)) end
function tmp = code(x, y) t_0 = hypot(x, (y + y)); tmp = ((x / t_0) / (t_0 / x)) - (((y * 2.0) / hypot(x, (y * 2.0))) ^ 2.0); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y + y), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(x / t$95$0), $MachinePrecision] / N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] - N[Power[N[(N[(y * 2.0), $MachinePrecision] / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y + y\right)\\
\frac{\frac{x}{t_0}}{\frac{t_0}{x}} - {\left(\frac{y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right)}^{2}
\end{array}
\end{array}
Initial program 49.6%
div-sub49.6%
fma-def49.6%
*-commutative49.6%
*-commutative49.6%
fma-def49.6%
*-commutative49.6%
Applied egg-rr49.6%
Applied egg-rr99.6%
unsub-neg99.6%
Simplified99.6%
unpow299.6%
metadata-eval99.6%
div-inv99.6%
clear-num99.6%
un-div-inv99.6%
div-inv99.6%
metadata-eval99.6%
add-log-exp82.9%
exp-lft-sqr82.9%
log-prod83.3%
add-log-exp83.4%
add-log-exp99.6%
add-log-exp82.9%
exp-lft-sqr82.9%
log-prod83.3%
add-log-exp83.4%
add-log-exp99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (- (pow (/ x t_0) 2.0) (pow (/ (* y 2.0) t_0) 2.0))))
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return pow((x / t_0), 2.0) - pow(((y * 2.0) / t_0), 2.0);
}
public static double code(double x, double y) {
double t_0 = Math.hypot(x, (y * 2.0));
return Math.pow((x / t_0), 2.0) - Math.pow(((y * 2.0) / t_0), 2.0);
}
def code(x, y): t_0 = math.hypot(x, (y * 2.0)) return math.pow((x / t_0), 2.0) - math.pow(((y * 2.0) / t_0), 2.0)
function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64((Float64(x / t_0) ^ 2.0) - (Float64(Float64(y * 2.0) / t_0) ^ 2.0)) end
function tmp = code(x, y) t_0 = hypot(x, (y * 2.0)); tmp = ((x / t_0) ^ 2.0) - (((y * 2.0) / t_0) ^ 2.0); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[Power[N[(x / t$95$0), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[(N[(y * 2.0), $MachinePrecision] / t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
{\left(\frac{x}{t_0}\right)}^{2} - {\left(\frac{y \cdot 2}{t_0}\right)}^{2}
\end{array}
\end{array}
Initial program 49.6%
div-sub49.6%
fma-def49.6%
*-commutative49.6%
*-commutative49.6%
fma-def49.6%
*-commutative49.6%
Applied egg-rr49.6%
Applied egg-rr99.6%
unsub-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= (* x x) 5e-311)
-1.0
(if (<= (* x x) 1e+238)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(-
(+ 1.0 (* (/ (/ y x) (/ x y)) -4.0))
(pow (/ (* y 2.0) (hypot x (* y 2.0))) 2.0))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-311) {
tmp = -1.0;
} else if ((x * x) <= 1e+238) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (1.0 + (((y / x) / (x / y)) * -4.0)) - pow(((y * 2.0) / hypot(x, (y * 2.0))), 2.0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-311) {
tmp = -1.0;
} else if ((x * x) <= 1e+238) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (1.0 + (((y / x) / (x / y)) * -4.0)) - Math.pow(((y * 2.0) / Math.hypot(x, (y * 2.0))), 2.0);
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if (x * x) <= 5e-311: tmp = -1.0 elif (x * x) <= 1e+238: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = (1.0 + (((y / x) / (x / y)) * -4.0)) - math.pow(((y * 2.0) / math.hypot(x, (y * 2.0))), 2.0) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (Float64(x * x) <= 5e-311) tmp = -1.0; elseif (Float64(x * x) <= 1e+238) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(y / x) / Float64(x / y)) * -4.0)) - (Float64(Float64(y * 2.0) / hypot(x, Float64(y * 2.0))) ^ 2.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if ((x * x) <= 5e-311) tmp = -1.0; elseif ((x * x) <= 1e+238) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = (1.0 + (((y / x) / (x / y)) * -4.0)) - (((y * 2.0) / hypot(x, (y * 2.0))) ^ 2.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-311], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+238], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] - N[Power[N[(N[(y * 2.0), $MachinePrecision] / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-311}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 10^{+238}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{\frac{y}{x}}{\frac{x}{y}} \cdot -4\right) - {\left(\frac{y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right)}^{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000023e-311Initial program 45.1%
Taylor expanded in x around 0 96.1%
if 5.00000000000023e-311 < (*.f64 x x) < 1e238Initial program 78.3%
if 1e238 < (*.f64 x x) Initial program 11.8%
div-sub11.8%
fma-def11.8%
*-commutative11.8%
*-commutative11.8%
fma-def11.8%
*-commutative11.8%
Applied egg-rr11.8%
Applied egg-rr100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 73.1%
*-commutative73.1%
unpow273.1%
unpow273.1%
times-frac83.7%
unpow283.7%
Simplified83.7%
unpow283.6%
clear-num83.6%
un-div-inv83.6%
Applied egg-rr83.7%
Final simplification83.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 2.0 (/ y x))) (t_1 (* y (* y 4.0))))
(if (<= (* x x) 5e-311)
-1.0
(if (<= (* x x) 1e+238)
(/ (- (* x x) t_1) (+ (* x x) t_1))
(- (pow (/ x (hypot x (* y 2.0))) 2.0) (* t_0 t_0))))))
double code(double x, double y) {
double t_0 = 2.0 * (y / x);
double t_1 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-311) {
tmp = -1.0;
} else if ((x * x) <= 1e+238) {
tmp = ((x * x) - t_1) / ((x * x) + t_1);
} else {
tmp = pow((x / hypot(x, (y * 2.0))), 2.0) - (t_0 * t_0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = 2.0 * (y / x);
double t_1 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-311) {
tmp = -1.0;
} else if ((x * x) <= 1e+238) {
tmp = ((x * x) - t_1) / ((x * x) + t_1);
} else {
tmp = Math.pow((x / Math.hypot(x, (y * 2.0))), 2.0) - (t_0 * t_0);
}
return tmp;
}
def code(x, y): t_0 = 2.0 * (y / x) t_1 = y * (y * 4.0) tmp = 0 if (x * x) <= 5e-311: tmp = -1.0 elif (x * x) <= 1e+238: tmp = ((x * x) - t_1) / ((x * x) + t_1) else: tmp = math.pow((x / math.hypot(x, (y * 2.0))), 2.0) - (t_0 * t_0) return tmp
function code(x, y) t_0 = Float64(2.0 * Float64(y / x)) t_1 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (Float64(x * x) <= 5e-311) tmp = -1.0; elseif (Float64(x * x) <= 1e+238) tmp = Float64(Float64(Float64(x * x) - t_1) / Float64(Float64(x * x) + t_1)); else tmp = Float64((Float64(x / hypot(x, Float64(y * 2.0))) ^ 2.0) - Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(x, y) t_0 = 2.0 * (y / x); t_1 = y * (y * 4.0); tmp = 0.0; if ((x * x) <= 5e-311) tmp = -1.0; elseif ((x * x) <= 1e+238) tmp = ((x * x) - t_1) / ((x * x) + t_1); else tmp = ((x / hypot(x, (y * 2.0))) ^ 2.0) - (t_0 * t_0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-311], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+238], N[(N[(N[(x * x), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(x / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \frac{y}{x}\\
t_1 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-311}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 10^{+238}:\\
\;\;\;\;\frac{x \cdot x - t_1}{x \cdot x + t_1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right)}^{2} - t_0 \cdot t_0\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000023e-311Initial program 45.1%
Taylor expanded in x around 0 96.1%
if 5.00000000000023e-311 < (*.f64 x x) < 1e238Initial program 78.3%
if 1e238 < (*.f64 x x) Initial program 11.8%
div-sub11.8%
fma-def11.8%
*-commutative11.8%
*-commutative11.8%
fma-def11.8%
*-commutative11.8%
Applied egg-rr11.8%
Applied egg-rr100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 83.6%
associate-*r/83.6%
count-283.6%
Simplified83.6%
unpow283.6%
count-283.6%
*-un-lft-identity83.6%
times-frac83.6%
metadata-eval83.6%
count-283.6%
*-un-lft-identity83.6%
times-frac83.6%
metadata-eval83.6%
Applied egg-rr83.6%
Final simplification83.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (or (<= t_0 5e+118) (and (not (<= t_0 2e+209)) (<= t_0 2e+279)))
(+ 1.0 (* (/ (/ y x) (/ x y)) -8.0))
-1.0)))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((t_0 <= 5e+118) || (!(t_0 <= 2e+209) && (t_0 <= 2e+279))) {
tmp = 1.0 + (((y / x) / (x / y)) * -8.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) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if ((t_0 <= 5d+118) .or. (.not. (t_0 <= 2d+209)) .and. (t_0 <= 2d+279)) then
tmp = 1.0d0 + (((y / x) / (x / y)) * (-8.0d0))
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((t_0 <= 5e+118) || (!(t_0 <= 2e+209) && (t_0 <= 2e+279))) {
tmp = 1.0 + (((y / x) / (x / y)) * -8.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if (t_0 <= 5e+118) or (not (t_0 <= 2e+209) and (t_0 <= 2e+279)): tmp = 1.0 + (((y / x) / (x / y)) * -8.0) else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if ((t_0 <= 5e+118) || (!(t_0 <= 2e+209) && (t_0 <= 2e+279))) tmp = Float64(1.0 + Float64(Float64(Float64(y / x) / Float64(x / y)) * -8.0)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if ((t_0 <= 5e+118) || (~((t_0 <= 2e+209)) && (t_0 <= 2e+279))) tmp = 1.0 + (((y / x) / (x / y)) * -8.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 5e+118], And[N[Not[LessEqual[t$95$0, 2e+209]], $MachinePrecision], LessEqual[t$95$0, 2e+279]]], N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+118} \lor \neg \left(t_0 \leq 2 \cdot 10^{+209}\right) \land t_0 \leq 2 \cdot 10^{+279}:\\
\;\;\;\;1 + \frac{\frac{y}{x}}{\frac{x}{y}} \cdot -8\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 4.99999999999999972e118 or 2.0000000000000001e209 < (*.f64 (*.f64 y 4) y) < 2.00000000000000012e279Initial program 64.4%
Taylor expanded in x around inf 74.2%
associate--l+74.2%
unpow274.2%
associate-*r/74.2%
*-commutative74.2%
unpow274.2%
associate-*r*74.2%
unpow274.2%
associate-*r/74.2%
*-commutative74.2%
unpow274.2%
associate-*r*74.2%
Simplified74.2%
Taylor expanded in y around 0 74.2%
unpow274.2%
unpow274.2%
times-frac75.7%
unpow275.7%
Simplified75.7%
unpow275.7%
clear-num75.7%
un-div-inv75.7%
Applied egg-rr75.7%
if 4.99999999999999972e118 < (*.f64 (*.f64 y 4) y) < 2.0000000000000001e209 or 2.00000000000000012e279 < (*.f64 (*.f64 y 4) y) Initial program 23.7%
Taylor expanded in x around 0 83.1%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (+ 1.0 (* (/ (/ y x) (/ x y)) -8.0))))
(if (<= t_0 5e+118)
t_1
(if (<= t_0 2e+209)
(/ (* y (* y -4.0)) (+ (* x x) t_0))
(if (<= t_0 2e+279) t_1 -1.0)))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = 1.0 + (((y / x) / (x / y)) * -8.0);
double tmp;
if (t_0 <= 5e+118) {
tmp = t_1;
} else if (t_0 <= 2e+209) {
tmp = (y * (y * -4.0)) / ((x * x) + t_0);
} else if (t_0 <= 2e+279) {
tmp = t_1;
} else {
tmp = -1.0;
}
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) :: tmp
t_0 = y * (y * 4.0d0)
t_1 = 1.0d0 + (((y / x) / (x / y)) * (-8.0d0))
if (t_0 <= 5d+118) then
tmp = t_1
else if (t_0 <= 2d+209) then
tmp = (y * (y * (-4.0d0))) / ((x * x) + t_0)
else if (t_0 <= 2d+279) then
tmp = t_1
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = 1.0 + (((y / x) / (x / y)) * -8.0);
double tmp;
if (t_0 <= 5e+118) {
tmp = t_1;
} else if (t_0 <= 2e+209) {
tmp = (y * (y * -4.0)) / ((x * x) + t_0);
} else if (t_0 <= 2e+279) {
tmp = t_1;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = 1.0 + (((y / x) / (x / y)) * -8.0) tmp = 0 if t_0 <= 5e+118: tmp = t_1 elif t_0 <= 2e+209: tmp = (y * (y * -4.0)) / ((x * x) + t_0) elif t_0 <= 2e+279: tmp = t_1 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(1.0 + Float64(Float64(Float64(y / x) / Float64(x / y)) * -8.0)) tmp = 0.0 if (t_0 <= 5e+118) tmp = t_1; elseif (t_0 <= 2e+209) tmp = Float64(Float64(y * Float64(y * -4.0)) / Float64(Float64(x * x) + t_0)); elseif (t_0 <= 2e+279) tmp = t_1; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = 1.0 + (((y / x) / (x / y)) * -8.0); tmp = 0.0; if (t_0 <= 5e+118) tmp = t_1; elseif (t_0 <= 2e+209) tmp = (y * (y * -4.0)) / ((x * x) + t_0); elseif (t_0 <= 2e+279) tmp = t_1; else tmp = -1.0; 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[(1.0 + N[(N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+118], t$95$1, If[LessEqual[t$95$0, 2e+209], N[(N[(y * N[(y * -4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+279], t$95$1, -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := 1 + \frac{\frac{y}{x}}{\frac{x}{y}} \cdot -8\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+118}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+209}:\\
\;\;\;\;\frac{y \cdot \left(y \cdot -4\right)}{x \cdot x + t_0}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+279}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 4.99999999999999972e118 or 2.0000000000000001e209 < (*.f64 (*.f64 y 4) y) < 2.00000000000000012e279Initial program 64.4%
Taylor expanded in x around inf 74.2%
associate--l+74.2%
unpow274.2%
associate-*r/74.2%
*-commutative74.2%
unpow274.2%
associate-*r*74.2%
unpow274.2%
associate-*r/74.2%
*-commutative74.2%
unpow274.2%
associate-*r*74.2%
Simplified74.2%
Taylor expanded in y around 0 74.2%
unpow274.2%
unpow274.2%
times-frac75.7%
unpow275.7%
Simplified75.7%
unpow275.7%
clear-num75.7%
un-div-inv75.7%
Applied egg-rr75.7%
if 4.99999999999999972e118 < (*.f64 (*.f64 y 4) y) < 2.0000000000000001e209Initial program 86.4%
Taylor expanded in x around 0 73.4%
*-commutative73.4%
unpow273.4%
associate-*r*73.4%
Simplified73.4%
if 2.00000000000000012e279 < (*.f64 (*.f64 y 4) y) Initial program 4.2%
Taylor expanded in x around 0 86.1%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= (* x x) 5e-311)
-1.0
(if (<= (* x x) 1e+238)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ 1.0 (* (/ (/ y x) (/ x y)) -8.0))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-311) {
tmp = -1.0;
} else if ((x * x) <= 1e+238) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (((y / x) / (x / y)) * -8.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if ((x * x) <= 5d-311) then
tmp = -1.0d0
else if ((x * x) <= 1d+238) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
else
tmp = 1.0d0 + (((y / x) / (x / y)) * (-8.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-311) {
tmp = -1.0;
} else if ((x * x) <= 1e+238) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (((y / x) / (x / y)) * -8.0);
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if (x * x) <= 5e-311: tmp = -1.0 elif (x * x) <= 1e+238: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = 1.0 + (((y / x) / (x / y)) * -8.0) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (Float64(x * x) <= 5e-311) tmp = -1.0; elseif (Float64(x * x) <= 1e+238) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(1.0 + Float64(Float64(Float64(y / x) / Float64(x / y)) * -8.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if ((x * x) <= 5e-311) tmp = -1.0; elseif ((x * x) <= 1e+238) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = 1.0 + (((y / x) / (x / y)) * -8.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-311], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+238], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-311}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 10^{+238}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{y}{x}}{\frac{x}{y}} \cdot -8\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000023e-311Initial program 45.1%
Taylor expanded in x around 0 96.1%
if 5.00000000000023e-311 < (*.f64 x x) < 1e238Initial program 78.3%
if 1e238 < (*.f64 x x) Initial program 11.8%
Taylor expanded in x around inf 73.1%
associate--l+73.1%
unpow273.1%
associate-*r/73.1%
*-commutative73.1%
unpow273.1%
associate-*r*73.1%
unpow273.1%
associate-*r/73.1%
*-commutative73.1%
unpow273.1%
associate-*r*73.1%
Simplified73.1%
Taylor expanded in y around 0 73.1%
unpow273.1%
unpow273.1%
times-frac83.6%
unpow283.6%
Simplified83.6%
unpow283.6%
clear-num83.6%
un-div-inv83.6%
Applied egg-rr83.6%
Final simplification83.6%
(FPCore (x y) :precision binary64 (if (<= y 4.7e+60) 1.0 (if (<= y 5.3e+106) -1.0 (if (<= y 2.2e+139) 1.0 -1.0))))
double code(double x, double y) {
double tmp;
if (y <= 4.7e+60) {
tmp = 1.0;
} else if (y <= 5.3e+106) {
tmp = -1.0;
} else if (y <= 2.2e+139) {
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 (y <= 4.7d+60) then
tmp = 1.0d0
else if (y <= 5.3d+106) then
tmp = -1.0d0
else if (y <= 2.2d+139) 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 (y <= 4.7e+60) {
tmp = 1.0;
} else if (y <= 5.3e+106) {
tmp = -1.0;
} else if (y <= 2.2e+139) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.7e+60: tmp = 1.0 elif y <= 5.3e+106: tmp = -1.0 elif y <= 2.2e+139: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 4.7e+60) tmp = 1.0; elseif (y <= 5.3e+106) tmp = -1.0; elseif (y <= 2.2e+139) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.7e+60) tmp = 1.0; elseif (y <= 5.3e+106) tmp = -1.0; elseif (y <= 2.2e+139) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.7e+60], 1.0, If[LessEqual[y, 5.3e+106], -1.0, If[LessEqual[y, 2.2e+139], 1.0, -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.7 \cdot 10^{+60}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.3 \cdot 10^{+106}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+139}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 4.6999999999999998e60 or 5.3e106 < y < 2.1999999999999999e139Initial program 55.8%
Taylor expanded in x around inf 62.4%
if 4.6999999999999998e60 < y < 5.3e106 or 2.1999999999999999e139 < y Initial program 24.0%
Taylor expanded in x around 0 82.3%
Final simplification66.3%
(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 49.6%
Taylor expanded in x around 0 46.4%
Final simplification46.4%
(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 2023293
(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))))