
(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) (+ t_0 (* x x)))))
(if (<= t_0 2e-280)
1.0
(if (<= t_0 1e-235)
t_1
(if (<= t_0 2e-174)
(+ 1.0 (- (* -4.0 (/ (* y y) (* x x))) (/ t_0 (* x x))))
(if (<= t_0 1e+255) t_1 (+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / (t_0 + (x * x));
double tmp;
if (t_0 <= 2e-280) {
tmp = 1.0;
} else if (t_0 <= 1e-235) {
tmp = t_1;
} else if (t_0 <= 2e-174) {
tmp = 1.0 + ((-4.0 * ((y * y) / (x * x))) - (t_0 / (x * x)));
} else if (t_0 <= 1e+255) {
tmp = t_1;
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -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 = ((x * x) - t_0) / (t_0 + (x * x))
if (t_0 <= 2d-280) then
tmp = 1.0d0
else if (t_0 <= 1d-235) then
tmp = t_1
else if (t_0 <= 2d-174) then
tmp = 1.0d0 + (((-4.0d0) * ((y * y) / (x * x))) - (t_0 / (x * x)))
else if (t_0 <= 1d+255) then
tmp = t_1
else
tmp = (((x / y) / (y / x)) / 4.0d0) + (-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 = ((x * x) - t_0) / (t_0 + (x * x));
double tmp;
if (t_0 <= 2e-280) {
tmp = 1.0;
} else if (t_0 <= 1e-235) {
tmp = t_1;
} else if (t_0 <= 2e-174) {
tmp = 1.0 + ((-4.0 * ((y * y) / (x * x))) - (t_0 / (x * x)));
} else if (t_0 <= 1e+255) {
tmp = t_1;
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / (t_0 + (x * x)) tmp = 0 if t_0 <= 2e-280: tmp = 1.0 elif t_0 <= 1e-235: tmp = t_1 elif t_0 <= 2e-174: tmp = 1.0 + ((-4.0 * ((y * y) / (x * x))) - (t_0 / (x * x))) elif t_0 <= 1e+255: tmp = t_1 else: tmp = (((x / y) / (y / x)) / 4.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(t_0 + Float64(x * x))) tmp = 0.0 if (t_0 <= 2e-280) tmp = 1.0; elseif (t_0 <= 1e-235) tmp = t_1; elseif (t_0 <= 2e-174) tmp = Float64(1.0 + Float64(Float64(-4.0 * Float64(Float64(y * y) / Float64(x * x))) - Float64(t_0 / Float64(x * x)))); elseif (t_0 <= 1e+255) tmp = t_1; else tmp = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = ((x * x) - t_0) / (t_0 + (x * x)); tmp = 0.0; if (t_0 <= 2e-280) tmp = 1.0; elseif (t_0 <= 1e-235) tmp = t_1; elseif (t_0 <= 2e-174) tmp = 1.0 + ((-4.0 * ((y * y) / (x * x))) - (t_0 / (x * x))); elseif (t_0 <= 1e+255) tmp = t_1; else tmp = (((x / y) / (y / x)) / 4.0) + -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[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-280], 1.0, If[LessEqual[t$95$0, 1e-235], t$95$1, If[LessEqual[t$95$0, 2e-174], N[(1.0 + N[(N[(-4.0 * N[(N[(y * y), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+255], t$95$1, N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -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}{t_0 + x \cdot x}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-280}:\\
\;\;\;\;1\\
\mathbf{elif}\;t_0 \leq 10^{-235}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;1 + \left(-4 \cdot \frac{y \cdot y}{x \cdot x} - \frac{t_0}{x \cdot x}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+255}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 1.9999999999999999e-280Initial program 57.4%
*-commutative57.4%
fma-def57.4%
*-commutative57.4%
Simplified57.4%
Taylor expanded in x around inf 86.7%
if 1.9999999999999999e-280 < (*.f64 (*.f64 y 4) y) < 9.9999999999999996e-236 or 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254Initial program 82.9%
if 9.9999999999999996e-236 < (*.f64 (*.f64 y 4) y) < 2e-174Initial program 54.5%
*-commutative54.5%
fma-def54.5%
*-commutative54.5%
Simplified54.5%
Taylor expanded in x around inf 91.6%
associate--l+91.6%
unpow291.6%
unpow291.6%
unpow291.6%
unpow291.6%
associate-*r/91.6%
*-commutative91.6%
associate-*r*91.6%
Simplified91.6%
if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y) Initial program 13.3%
Taylor expanded in x around 0 13.3%
unpow213.3%
*-commutative13.3%
associate-*r*13.3%
Simplified13.3%
div-sub13.3%
associate-*r*13.3%
associate-/r*13.3%
frac-times13.4%
pow213.4%
*-commutative13.4%
*-inverses88.6%
Applied egg-rr88.6%
unpow288.6%
clear-num88.6%
un-div-inv88.6%
Applied egg-rr88.6%
Final simplification86.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 2e-174)
(fma (* (/ y x) (/ y x)) -8.0 1.0)
(if (<= t_0 1e+255)
(/ (- (* x x) t_0) (fma x x t_0))
(+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 2e-174) {
tmp = fma(((y / x) * (y / x)), -8.0, 1.0);
} else if (t_0 <= 1e+255) {
tmp = ((x * x) - t_0) / fma(x, x, t_0);
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 2e-174) tmp = fma(Float64(Float64(y / x) * Float64(y / x)), -8.0, 1.0); elseif (t_0 <= 1e+255) tmp = Float64(Float64(Float64(x * x) - t_0) / fma(x, x, t_0)); else tmp = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-174], N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0 + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1e+255], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
\mathbf{elif}\;t_0 \leq 10^{+255}:\\
\;\;\;\;\frac{x \cdot x - t_0}{\mathsf{fma}\left(x, x, t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 2e-174Initial program 60.9%
*-commutative60.9%
fma-def60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in x around inf 77.3%
associate--l+77.3%
distribute-rgt-out--77.3%
metadata-eval77.3%
*-commutative77.3%
+-commutative77.3%
*-commutative77.3%
fma-def77.3%
unpow277.3%
unpow277.3%
times-frac84.8%
Simplified84.8%
if 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254Initial program 81.4%
*-commutative81.4%
fma-def81.4%
*-commutative81.4%
Simplified81.4%
if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y) Initial program 13.3%
Taylor expanded in x around 0 13.3%
unpow213.3%
*-commutative13.3%
associate-*r*13.3%
Simplified13.3%
div-sub13.3%
associate-*r*13.3%
associate-/r*13.3%
frac-times13.4%
pow213.4%
*-commutative13.4%
*-inverses88.6%
Applied egg-rr88.6%
unpow288.6%
clear-num88.6%
un-div-inv88.6%
Applied egg-rr88.6%
Final simplification84.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 2e-174)
(fma (* (/ y x) (/ y x)) -8.0 1.0)
(if (<= t_0 1e+255)
(/ (- (* x x) t_0) (+ t_0 (* x x)))
(+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 2e-174) {
tmp = fma(((y / x) * (y / x)), -8.0, 1.0);
} else if (t_0 <= 1e+255) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 2e-174) tmp = fma(Float64(Float64(y / x) * Float64(y / x)), -8.0, 1.0); elseif (t_0 <= 1e+255) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-174], N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0 + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1e+255], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
\mathbf{elif}\;t_0 \leq 10^{+255}:\\
\;\;\;\;\frac{x \cdot x - t_0}{t_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 2e-174Initial program 60.9%
*-commutative60.9%
fma-def60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in x around inf 77.3%
associate--l+77.3%
distribute-rgt-out--77.3%
metadata-eval77.3%
*-commutative77.3%
+-commutative77.3%
*-commutative77.3%
fma-def77.3%
unpow277.3%
unpow277.3%
times-frac84.8%
Simplified84.8%
if 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254Initial program 81.4%
if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y) Initial program 13.3%
Taylor expanded in x around 0 13.3%
unpow213.3%
*-commutative13.3%
associate-*r*13.3%
Simplified13.3%
div-sub13.3%
associate-*r*13.3%
associate-/r*13.3%
frac-times13.4%
pow213.4%
*-commutative13.4%
*-inverses88.6%
Applied egg-rr88.6%
unpow288.6%
clear-num88.6%
un-div-inv88.6%
Applied egg-rr88.6%
Final simplification84.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ t_0 (* x x)))))
(if (<= t_0 2e-280)
1.0
(if (<= t_0 1e-235)
t_1
(if (<= t_0 2e-174)
1.0
(if (<= t_0 1e+255) t_1 (+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / (t_0 + (x * x));
double tmp;
if (t_0 <= 2e-280) {
tmp = 1.0;
} else if (t_0 <= 1e-235) {
tmp = t_1;
} else if (t_0 <= 2e-174) {
tmp = 1.0;
} else if (t_0 <= 1e+255) {
tmp = t_1;
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -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 = ((x * x) - t_0) / (t_0 + (x * x))
if (t_0 <= 2d-280) then
tmp = 1.0d0
else if (t_0 <= 1d-235) then
tmp = t_1
else if (t_0 <= 2d-174) then
tmp = 1.0d0
else if (t_0 <= 1d+255) then
tmp = t_1
else
tmp = (((x / y) / (y / x)) / 4.0d0) + (-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 = ((x * x) - t_0) / (t_0 + (x * x));
double tmp;
if (t_0 <= 2e-280) {
tmp = 1.0;
} else if (t_0 <= 1e-235) {
tmp = t_1;
} else if (t_0 <= 2e-174) {
tmp = 1.0;
} else if (t_0 <= 1e+255) {
tmp = t_1;
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / (t_0 + (x * x)) tmp = 0 if t_0 <= 2e-280: tmp = 1.0 elif t_0 <= 1e-235: tmp = t_1 elif t_0 <= 2e-174: tmp = 1.0 elif t_0 <= 1e+255: tmp = t_1 else: tmp = (((x / y) / (y / x)) / 4.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(t_0 + Float64(x * x))) tmp = 0.0 if (t_0 <= 2e-280) tmp = 1.0; elseif (t_0 <= 1e-235) tmp = t_1; elseif (t_0 <= 2e-174) tmp = 1.0; elseif (t_0 <= 1e+255) tmp = t_1; else tmp = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = ((x * x) - t_0) / (t_0 + (x * x)); tmp = 0.0; if (t_0 <= 2e-280) tmp = 1.0; elseif (t_0 <= 1e-235) tmp = t_1; elseif (t_0 <= 2e-174) tmp = 1.0; elseif (t_0 <= 1e+255) tmp = t_1; else tmp = (((x / y) / (y / x)) / 4.0) + -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[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-280], 1.0, If[LessEqual[t$95$0, 1e-235], t$95$1, If[LessEqual[t$95$0, 2e-174], 1.0, If[LessEqual[t$95$0, 1e+255], t$95$1, N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -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}{t_0 + x \cdot x}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-280}:\\
\;\;\;\;1\\
\mathbf{elif}\;t_0 \leq 10^{-235}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;1\\
\mathbf{elif}\;t_0 \leq 10^{+255}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 1.9999999999999999e-280 or 9.9999999999999996e-236 < (*.f64 (*.f64 y 4) y) < 2e-174Initial program 57.0%
*-commutative57.0%
fma-def57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in x around inf 87.3%
if 1.9999999999999999e-280 < (*.f64 (*.f64 y 4) y) < 9.9999999999999996e-236 or 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254Initial program 82.9%
if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y) Initial program 13.3%
Taylor expanded in x around 0 13.3%
unpow213.3%
*-commutative13.3%
associate-*r*13.3%
Simplified13.3%
div-sub13.3%
associate-*r*13.3%
associate-/r*13.3%
frac-times13.4%
pow213.4%
*-commutative13.4%
*-inverses88.6%
Applied egg-rr88.6%
unpow288.6%
clear-num88.6%
un-div-inv88.6%
Applied egg-rr88.6%
Final simplification86.1%
(FPCore (x y) :precision binary64 (if (<= y 9.2e-88) 1.0 (+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))
double code(double x, double y) {
double tmp;
if (y <= 9.2e-88) {
tmp = 1.0;
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -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 <= 9.2d-88) then
tmp = 1.0d0
else
tmp = (((x / y) / (y / x)) / 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9.2e-88) {
tmp = 1.0;
} else {
tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9.2e-88: tmp = 1.0 else: tmp = (((x / y) / (y / x)) / 4.0) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 9.2e-88) tmp = 1.0; else tmp = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9.2e-88) tmp = 1.0; else tmp = (((x / y) / (y / x)) / 4.0) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9.2e-88], 1.0, N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.2 \cdot 10^{-88}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\
\end{array}
\end{array}
if y < 9.19999999999999945e-88Initial program 55.0%
*-commutative55.0%
fma-def55.0%
*-commutative55.0%
Simplified55.0%
Taylor expanded in x around inf 55.1%
if 9.19999999999999945e-88 < y Initial program 47.1%
Taylor expanded in x around 0 37.7%
unpow237.7%
*-commutative37.7%
associate-*r*37.7%
Simplified37.7%
div-sub37.7%
associate-*r*37.7%
associate-/r*37.7%
frac-times37.8%
pow237.8%
*-commutative37.8%
*-inverses75.9%
Applied egg-rr75.9%
unpow275.9%
clear-num75.9%
un-div-inv75.9%
Applied egg-rr75.9%
Final simplification62.2%
(FPCore (x y) :precision binary64 (if (<= y 1.65e-87) 1.0 -1.0))
double code(double x, double y) {
double tmp;
if (y <= 1.65e-87) {
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 <= 1.65d-87) 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 <= 1.65e-87) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.65e-87: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 1.65e-87) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.65e-87) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.65e-87], 1.0, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{-87}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 1.65e-87Initial program 55.0%
*-commutative55.0%
fma-def55.0%
*-commutative55.0%
Simplified55.0%
Taylor expanded in x around inf 55.1%
if 1.65e-87 < y Initial program 47.1%
*-commutative47.1%
fma-def47.1%
*-commutative47.1%
Simplified47.1%
Taylor expanded in x around 0 75.1%
Final simplification61.9%
(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 52.3%
*-commutative52.3%
fma-def52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in x around 0 55.4%
Final simplification55.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 2023290
(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))))