
(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))))
(if (<= (* x x) 5e-284)
(fma 0.5 (* (/ x y) (/ x y)) -1.0)
(if (<= (* x x) 2e+182)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-284) {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
} else if ((x * x) <= 2e+182) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (Float64(x * x) <= 5e-284) tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); elseif (Float64(x * x) <= 2e+182) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); 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]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-284], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+182], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$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}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-284}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+182}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\end{array}
\end{array}
if (*.f64 x x) < 4.99999999999999973e-284Initial program 50.0%
Taylor expanded in x around 0 75.1%
fma-neg75.1%
unpow275.1%
unpow275.1%
times-frac87.2%
metadata-eval87.2%
Simplified87.2%
if 4.99999999999999973e-284 < (*.f64 x x) < 2.0000000000000001e182Initial program 74.2%
if 2.0000000000000001e182 < (*.f64 x x) Initial program 18.1%
Taylor expanded in x around inf 18.3%
unpow218.3%
Simplified18.3%
Taylor expanded in x around inf 76.1%
unpow276.1%
unpow276.1%
times-frac86.2%
unpow286.2%
Simplified86.2%
unpow286.2%
clear-num86.2%
un-div-inv86.2%
Applied egg-rr86.2%
Final simplification82.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= (* x x) 5e-284)
(+ -1.0 (/ (/ x (/ y x)) (* y 4.0)))
(if (<= (* x x) 2e+182)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 5e-284) {
tmp = -1.0 + ((x / (y / x)) / (y * 4.0));
} else if ((x * x) <= 2e+182) {
tmp = ((x * x) - t_0) / ((x * x) + t_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) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if ((x * x) <= 5d-284) then
tmp = (-1.0d0) + ((x / (y / x)) / (y * 4.0d0))
else if ((x * x) <= 2d+182) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
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 tmp;
if ((x * x) <= 5e-284) {
tmp = -1.0 + ((x / (y / x)) / (y * 4.0));
} else if ((x * x) <= 2e+182) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if (x * x) <= 5e-284: tmp = -1.0 + ((x / (y / x)) / (y * 4.0)) elif (x * x) <= 2e+182: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = 1.0 + (-4.0 * ((y / x) / (x / y))) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (Float64(x * x) <= 5e-284) tmp = Float64(-1.0 + Float64(Float64(x / Float64(y / x)) / Float64(y * 4.0))); elseif (Float64(x * x) <= 2e+182) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_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) t_0 = y * (y * 4.0); tmp = 0.0; if ((x * x) <= 5e-284) tmp = -1.0 + ((x / (y / x)) / (y * 4.0)); elseif ((x * x) <= 2e+182) tmp = ((x * x) - t_0) / ((x * x) + t_0); 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]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-284], N[(-1.0 + N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+182], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$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}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-284}:\\
\;\;\;\;-1 + \frac{\frac{x}{\frac{y}{x}}}{y \cdot 4}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+182}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\end{array}
\end{array}
if (*.f64 x x) < 4.99999999999999973e-284Initial program 50.0%
Taylor expanded in x around 0 46.4%
*-commutative46.4%
unpow246.4%
associate-*r*46.4%
Simplified46.4%
div-sub46.3%
associate-*r*46.3%
times-frac46.3%
*-commutative46.3%
pow146.3%
pow146.3%
pow-div75.5%
metadata-eval75.5%
metadata-eval75.5%
Applied egg-rr75.5%
*-commutative75.5%
associate-/r*86.9%
frac-times87.0%
clear-num87.0%
div-inv87.0%
Applied egg-rr87.0%
if 4.99999999999999973e-284 < (*.f64 x x) < 2.0000000000000001e182Initial program 74.2%
if 2.0000000000000001e182 < (*.f64 x x) Initial program 18.1%
Taylor expanded in x around inf 18.3%
unpow218.3%
Simplified18.3%
Taylor expanded in x around inf 76.1%
unpow276.1%
unpow276.1%
times-frac86.2%
unpow286.2%
Simplified86.2%
unpow286.2%
clear-num86.2%
un-div-inv86.2%
Applied egg-rr86.2%
Final simplification82.1%
(FPCore (x y)
:precision binary64
(if (<= (* x x) 4e-40)
(+ -1.0 (/ (/ x (/ y x)) (* y 4.0)))
(if (or (<= (* x x) 0.001) (not (<= (* x x) 1e+73)))
(+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))
(+ -1.0 (* (/ x (* y y)) (/ x 4.0))))))
double code(double x, double y) {
double tmp;
if ((x * x) <= 4e-40) {
tmp = -1.0 + ((x / (y / x)) / (y * 4.0));
} else if (((x * x) <= 0.001) || !((x * x) <= 1e+73)) {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
} else {
tmp = -1.0 + ((x / (y * y)) * (x / 4.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x * x) <= 4d-40) then
tmp = (-1.0d0) + ((x / (y / x)) / (y * 4.0d0))
else if (((x * x) <= 0.001d0) .or. (.not. ((x * x) <= 1d+73))) then
tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
else
tmp = (-1.0d0) + ((x / (y * y)) * (x / 4.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x * x) <= 4e-40) {
tmp = -1.0 + ((x / (y / x)) / (y * 4.0));
} else if (((x * x) <= 0.001) || !((x * x) <= 1e+73)) {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
} else {
tmp = -1.0 + ((x / (y * y)) * (x / 4.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (x * x) <= 4e-40: tmp = -1.0 + ((x / (y / x)) / (y * 4.0)) elif ((x * x) <= 0.001) or not ((x * x) <= 1e+73): tmp = 1.0 + (-4.0 * ((y / x) / (x / y))) else: tmp = -1.0 + ((x / (y * y)) * (x / 4.0)) return tmp
function code(x, y) tmp = 0.0 if (Float64(x * x) <= 4e-40) tmp = Float64(-1.0 + Float64(Float64(x / Float64(y / x)) / Float64(y * 4.0))); elseif ((Float64(x * x) <= 0.001) || !(Float64(x * x) <= 1e+73)) tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))); else tmp = Float64(-1.0 + Float64(Float64(x / Float64(y * y)) * Float64(x / 4.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x * x) <= 4e-40) tmp = -1.0 + ((x / (y / x)) / (y * 4.0)); elseif (((x * x) <= 0.001) || ~(((x * x) <= 1e+73))) tmp = 1.0 + (-4.0 * ((y / x) / (x / y))); else tmp = -1.0 + ((x / (y * y)) * (x / 4.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x * x), $MachinePrecision], 4e-40], N[(-1.0 + N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(x * x), $MachinePrecision], 0.001], N[Not[LessEqual[N[(x * x), $MachinePrecision], 1e+73]], $MachinePrecision]], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(x / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-40}:\\
\;\;\;\;-1 + \frac{\frac{x}{\frac{y}{x}}}{y \cdot 4}\\
\mathbf{elif}\;x \cdot x \leq 0.001 \lor \neg \left(x \cdot x \leq 10^{+73}\right):\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{x}{y \cdot y} \cdot \frac{x}{4}\\
\end{array}
\end{array}
if (*.f64 x x) < 3.9999999999999997e-40Initial program 60.2%
Taylor expanded in x around 0 45.2%
*-commutative45.2%
unpow245.2%
associate-*r*45.2%
Simplified45.2%
div-sub44.9%
associate-*r*44.9%
times-frac44.9%
*-commutative44.9%
pow144.9%
pow144.9%
pow-div72.0%
metadata-eval72.0%
metadata-eval72.0%
Applied egg-rr72.0%
*-commutative72.0%
associate-/r*79.2%
frac-times79.2%
clear-num79.2%
div-inv79.2%
Applied egg-rr79.2%
if 3.9999999999999997e-40 < (*.f64 x x) < 1e-3 or 9.99999999999999983e72 < (*.f64 x x) Initial program 33.6%
Taylor expanded in x around inf 31.0%
unpow231.0%
Simplified31.0%
Taylor expanded in x around inf 73.6%
unpow273.6%
unpow273.6%
times-frac81.1%
unpow281.1%
Simplified81.1%
unpow281.1%
clear-num81.1%
un-div-inv81.1%
Applied egg-rr81.1%
if 1e-3 < (*.f64 x x) < 9.99999999999999983e72Initial program 60.0%
Taylor expanded in x around 0 24.6%
*-commutative24.6%
unpow224.6%
associate-*r*24.6%
Simplified24.6%
div-sub23.9%
associate-*r*23.9%
times-frac23.9%
*-commutative23.9%
pow123.9%
pow123.9%
pow-div64.6%
metadata-eval64.6%
metadata-eval64.6%
Applied egg-rr64.6%
Final simplification79.2%
(FPCore (x y)
:precision binary64
(if (or (<= x -1.72e+115)
(not (or (<= x -5e+86) (and (not (<= x -5.2e+38)) (<= x 2.9e-80)))))
(+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))
-1.0))
double code(double x, double y) {
double tmp;
if ((x <= -1.72e+115) || !((x <= -5e+86) || (!(x <= -5.2e+38) && (x <= 2.9e-80)))) {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
} 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 <= (-1.72d+115)) .or. (.not. (x <= (-5d+86)) .or. (.not. (x <= (-5.2d+38))) .and. (x <= 2.9d-80))) then
tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.72e+115) || !((x <= -5e+86) || (!(x <= -5.2e+38) && (x <= 2.9e-80)))) {
tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.72e+115) or not ((x <= -5e+86) or (not (x <= -5.2e+38) and (x <= 2.9e-80))): tmp = 1.0 + (-4.0 * ((y / x) / (x / y))) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.72e+115) || !((x <= -5e+86) || (!(x <= -5.2e+38) && (x <= 2.9e-80)))) tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.72e+115) || ~(((x <= -5e+86) || (~((x <= -5.2e+38)) && (x <= 2.9e-80))))) tmp = 1.0 + (-4.0 * ((y / x) / (x / y))); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.72e+115], N[Not[Or[LessEqual[x, -5e+86], And[N[Not[LessEqual[x, -5.2e+38]], $MachinePrecision], LessEqual[x, 2.9e-80]]]], $MachinePrecision]], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72 \cdot 10^{+115} \lor \neg \left(x \leq -5 \cdot 10^{+86} \lor \neg \left(x \leq -5.2 \cdot 10^{+38}\right) \land x \leq 2.9 \cdot 10^{-80}\right):\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.72e115 or -4.9999999999999998e86 < x < -5.1999999999999998e38 or 2.89999999999999998e-80 < x Initial program 37.7%
Taylor expanded in x around inf 33.7%
unpow233.7%
Simplified33.7%
Taylor expanded in x around inf 73.2%
unpow273.2%
unpow273.2%
times-frac80.0%
unpow280.0%
Simplified80.0%
unpow280.0%
clear-num80.0%
un-div-inv80.0%
Applied egg-rr80.0%
if -1.72e115 < x < -4.9999999999999998e86 or -5.1999999999999998e38 < x < 2.89999999999999998e-80Initial program 58.2%
Taylor expanded in x around 0 79.6%
Final simplification79.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))
(if (<= x -1.72e+115)
t_0
(if (<= x -6.5e+87)
(+ -1.0 (* (/ x (* y y)) (/ x 4.0)))
(if (or (<= x -4.7e+38) (not (<= x 1.35e-79))) t_0 -1.0)))))
double code(double x, double y) {
double t_0 = 1.0 + (-4.0 * ((y / x) / (x / y)));
double tmp;
if (x <= -1.72e+115) {
tmp = t_0;
} else if (x <= -6.5e+87) {
tmp = -1.0 + ((x / (y * y)) * (x / 4.0));
} else if ((x <= -4.7e+38) || !(x <= 1.35e-79)) {
tmp = t_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 = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
if (x <= (-1.72d+115)) then
tmp = t_0
else if (x <= (-6.5d+87)) then
tmp = (-1.0d0) + ((x / (y * y)) * (x / 4.0d0))
else if ((x <= (-4.7d+38)) .or. (.not. (x <= 1.35d-79))) then
tmp = t_0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (-4.0 * ((y / x) / (x / y)));
double tmp;
if (x <= -1.72e+115) {
tmp = t_0;
} else if (x <= -6.5e+87) {
tmp = -1.0 + ((x / (y * y)) * (x / 4.0));
} else if ((x <= -4.7e+38) || !(x <= 1.35e-79)) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-4.0 * ((y / x) / (x / y))) tmp = 0 if x <= -1.72e+115: tmp = t_0 elif x <= -6.5e+87: tmp = -1.0 + ((x / (y * y)) * (x / 4.0)) elif (x <= -4.7e+38) or not (x <= 1.35e-79): tmp = t_0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y)))) tmp = 0.0 if (x <= -1.72e+115) tmp = t_0; elseif (x <= -6.5e+87) tmp = Float64(-1.0 + Float64(Float64(x / Float64(y * y)) * Float64(x / 4.0))); elseif ((x <= -4.7e+38) || !(x <= 1.35e-79)) tmp = t_0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-4.0 * ((y / x) / (x / y))); tmp = 0.0; if (x <= -1.72e+115) tmp = t_0; elseif (x <= -6.5e+87) tmp = -1.0 + ((x / (y * y)) * (x / 4.0)); elseif ((x <= -4.7e+38) || ~((x <= 1.35e-79))) tmp = t_0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.72e+115], t$95$0, If[LessEqual[x, -6.5e+87], N[(-1.0 + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(x / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -4.7e+38], N[Not[LessEqual[x, 1.35e-79]], $MachinePrecision]], t$95$0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\mathbf{if}\;x \leq -1.72 \cdot 10^{+115}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{+87}:\\
\;\;\;\;-1 + \frac{x}{y \cdot y} \cdot \frac{x}{4}\\
\mathbf{elif}\;x \leq -4.7 \cdot 10^{+38} \lor \neg \left(x \leq 1.35 \cdot 10^{-79}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.72e115 or -6.5000000000000002e87 < x < -4.6999999999999999e38 or 1.3500000000000001e-79 < x Initial program 37.7%
Taylor expanded in x around inf 33.7%
unpow233.7%
Simplified33.7%
Taylor expanded in x around inf 73.2%
unpow273.2%
unpow273.2%
times-frac80.0%
unpow280.0%
Simplified80.0%
unpow280.0%
clear-num80.0%
un-div-inv80.0%
Applied egg-rr80.0%
if -1.72e115 < x < -6.5000000000000002e87Initial program 42.9%
Taylor expanded in x around 0 29.0%
*-commutative29.0%
unpow229.0%
associate-*r*29.0%
Simplified29.0%
div-sub28.6%
associate-*r*28.6%
times-frac28.6%
*-commutative28.6%
pow128.6%
pow128.6%
pow-div86.2%
metadata-eval86.2%
metadata-eval86.2%
Applied egg-rr86.2%
if -4.6999999999999999e38 < x < 1.3500000000000001e-79Initial program 59.1%
Taylor expanded in x around 0 79.3%
Final simplification79.8%
(FPCore (x y)
:precision binary64
(if (<= x -1.72e+115)
1.0
(if (<= x -5e+88)
-1.0
(if (<= x -4.7e+38) 1.0 (if (<= x 1.5e-79) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.72e+115) {
tmp = 1.0;
} else if (x <= -5e+88) {
tmp = -1.0;
} else if (x <= -4.7e+38) {
tmp = 1.0;
} else if (x <= 1.5e-79) {
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 <= (-1.72d+115)) then
tmp = 1.0d0
else if (x <= (-5d+88)) then
tmp = -1.0d0
else if (x <= (-4.7d+38)) then
tmp = 1.0d0
else if (x <= 1.5d-79) 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 <= -1.72e+115) {
tmp = 1.0;
} else if (x <= -5e+88) {
tmp = -1.0;
} else if (x <= -4.7e+38) {
tmp = 1.0;
} else if (x <= 1.5e-79) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.72e+115: tmp = 1.0 elif x <= -5e+88: tmp = -1.0 elif x <= -4.7e+38: tmp = 1.0 elif x <= 1.5e-79: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.72e+115) tmp = 1.0; elseif (x <= -5e+88) tmp = -1.0; elseif (x <= -4.7e+38) tmp = 1.0; elseif (x <= 1.5e-79) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.72e+115) tmp = 1.0; elseif (x <= -5e+88) tmp = -1.0; elseif (x <= -4.7e+38) tmp = 1.0; elseif (x <= 1.5e-79) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.72e+115], 1.0, If[LessEqual[x, -5e+88], -1.0, If[LessEqual[x, -4.7e+38], 1.0, If[LessEqual[x, 1.5e-79], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72 \cdot 10^{+115}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -5 \cdot 10^{+88}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -4.7 \cdot 10^{+38}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-79}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.72e115 or -4.99999999999999997e88 < x < -4.6999999999999999e38 or 1.5e-79 < x Initial program 37.7%
Taylor expanded in x around inf 79.5%
if -1.72e115 < x < -4.99999999999999997e88 or -4.6999999999999999e38 < x < 1.5e-79Initial program 58.2%
Taylor expanded in x around 0 79.6%
Final simplification79.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 48.4%
Taylor expanded in x around 0 51.9%
Final simplification51.9%
(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 2023174
(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))))