
(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 6 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}
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))))
(if (<= y_m 1.85e-82)
(+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x))))
(if (<= y_m 2.1e+111)
(/ (- (* x x) t_0) (fma x x t_0))
(+ (* 0.5 (* (/ x y_m) (/ x y_m))) -1.0)))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if (y_m <= 1.85e-82) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else if (y_m <= 2.1e+111) {
tmp = ((x * x) - t_0) / fma(x, x, t_0);
} else {
tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0;
}
return tmp;
}
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) tmp = 0.0 if (y_m <= 1.85e-82) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x)))); elseif (y_m <= 2.1e+111) tmp = Float64(Float64(Float64(x * x) - t_0) / fma(x, x, t_0)); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) * Float64(x / y_m))) + -1.0); end return tmp end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 1.85e-82], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 2.1e+111], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;y\_m \leq 1.85 \cdot 10^{-82}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;y\_m \leq 2.1 \cdot 10^{+111}:\\
\;\;\;\;\frac{x \cdot x - t\_0}{\mathsf{fma}\left(x, x, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y\_m} \cdot \frac{x}{y\_m}\right) + -1\\
\end{array}
\end{array}
if y < 1.85e-82Initial program 48.0%
*-commutative48.0%
fma-define48.0%
*-commutative48.0%
Simplified48.0%
Taylor expanded in y around 0 52.6%
unpow252.6%
unpow252.6%
times-frac58.6%
Applied egg-rr58.6%
if 1.85e-82 < y < 2.09999999999999995e111Initial program 82.8%
*-commutative82.8%
fma-define82.8%
*-commutative82.8%
Simplified82.8%
if 2.09999999999999995e111 < y Initial program 22.5%
*-commutative22.5%
fma-define22.5%
*-commutative22.5%
Simplified22.5%
Taylor expanded in x around 0 77.7%
unpow277.7%
unpow277.7%
times-frac85.9%
Applied egg-rr85.9%
Final simplification66.2%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))))
(if (<= y_m 4.6e-83)
(+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x))))
(if (<= y_m 2.9e+111)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ (* 0.5 (* (/ x y_m) (/ x y_m))) -1.0)))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if (y_m <= 4.6e-83) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else if (y_m <= 2.9e+111) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: tmp
t_0 = y_m * (y_m * 4.0d0)
if (y_m <= 4.6d-83) then
tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
else if (y_m <= 2.9d+111) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
else
tmp = (0.5d0 * ((x / y_m) * (x / y_m))) + (-1.0d0)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if (y_m <= 4.6e-83) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else if (y_m <= 2.9e+111) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) tmp = 0 if y_m <= 4.6e-83: tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))) elif y_m <= 2.9e+111: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0 return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) tmp = 0.0 if (y_m <= 4.6e-83) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x)))); elseif (y_m <= 2.9e+111) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) * Float64(x / y_m))) + -1.0); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = y_m * (y_m * 4.0); tmp = 0.0; if (y_m <= 4.6e-83) tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))); elseif (y_m <= 2.9e+111) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 4.6e-83], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 2.9e+111], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;y\_m \leq 4.6 \cdot 10^{-83}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;y\_m \leq 2.9 \cdot 10^{+111}:\\
\;\;\;\;\frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y\_m} \cdot \frac{x}{y\_m}\right) + -1\\
\end{array}
\end{array}
if y < 4.59999999999999979e-83Initial program 48.0%
*-commutative48.0%
fma-define48.0%
*-commutative48.0%
Simplified48.0%
Taylor expanded in y around 0 52.6%
unpow252.6%
unpow252.6%
times-frac58.6%
Applied egg-rr58.6%
if 4.59999999999999979e-83 < y < 2.9e111Initial program 82.8%
if 2.9e111 < y Initial program 22.5%
*-commutative22.5%
fma-define22.5%
*-commutative22.5%
Simplified22.5%
Taylor expanded in x around 0 77.7%
unpow277.7%
unpow277.7%
times-frac85.9%
Applied egg-rr85.9%
Final simplification66.2%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (or (<= y_m 1.65e-59) (and (not (<= y_m 5.8e-17)) (<= y_m 2.9e+26))) (+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x)))) -1.0))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if ((y_m <= 1.65e-59) || (!(y_m <= 5.8e-17) && (y_m <= 2.9e+26))) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else {
tmp = -1.0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if ((y_m <= 1.65d-59) .or. (.not. (y_m <= 5.8d-17)) .and. (y_m <= 2.9d+26)) then
tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
else
tmp = -1.0d0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double tmp;
if ((y_m <= 1.65e-59) || (!(y_m <= 5.8e-17) && (y_m <= 2.9e+26))) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else {
tmp = -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if (y_m <= 1.65e-59) or (not (y_m <= 5.8e-17) and (y_m <= 2.9e+26)): tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))) else: tmp = -1.0 return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if ((y_m <= 1.65e-59) || (!(y_m <= 5.8e-17) && (y_m <= 2.9e+26))) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x)))); else tmp = -1.0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if ((y_m <= 1.65e-59) || (~((y_m <= 5.8e-17)) && (y_m <= 2.9e+26))) tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))); else tmp = -1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[Or[LessEqual[y$95$m, 1.65e-59], And[N[Not[LessEqual[y$95$m, 5.8e-17]], $MachinePrecision], LessEqual[y$95$m, 2.9e+26]]], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.65 \cdot 10^{-59} \lor \neg \left(y\_m \leq 5.8 \cdot 10^{-17}\right) \land y\_m \leq 2.9 \cdot 10^{+26}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 1.64999999999999991e-59 or 5.8000000000000006e-17 < y < 2.9e26Initial program 50.5%
*-commutative50.5%
fma-define50.5%
*-commutative50.5%
Simplified50.5%
Taylor expanded in y around 0 53.2%
unpow253.2%
unpow253.2%
times-frac58.7%
Applied egg-rr58.7%
if 1.64999999999999991e-59 < y < 5.8000000000000006e-17 or 2.9e26 < y Initial program 43.1%
*-commutative43.1%
fma-define43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in x around 0 81.3%
Final simplification63.8%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (or (<= y_m 3e-82) (and (not (<= y_m 9.8e-18)) (<= y_m 3.8e+27))) (+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x)))) (+ (* 0.5 (* (/ x y_m) (/ x y_m))) -1.0)))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if ((y_m <= 3e-82) || (!(y_m <= 9.8e-18) && (y_m <= 3.8e+27))) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else {
tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if ((y_m <= 3d-82) .or. (.not. (y_m <= 9.8d-18)) .and. (y_m <= 3.8d+27)) then
tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
else
tmp = (0.5d0 * ((x / y_m) * (x / y_m))) + (-1.0d0)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double tmp;
if ((y_m <= 3e-82) || (!(y_m <= 9.8e-18) && (y_m <= 3.8e+27))) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else {
tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if (y_m <= 3e-82) or (not (y_m <= 9.8e-18) and (y_m <= 3.8e+27)): tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))) else: tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0 return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if ((y_m <= 3e-82) || (!(y_m <= 9.8e-18) && (y_m <= 3.8e+27))) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x)))); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) * Float64(x / y_m))) + -1.0); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if ((y_m <= 3e-82) || (~((y_m <= 9.8e-18)) && (y_m <= 3.8e+27))) tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))); else tmp = (0.5 * ((x / y_m) * (x / y_m))) + -1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[Or[LessEqual[y$95$m, 3e-82], And[N[Not[LessEqual[y$95$m, 9.8e-18]], $MachinePrecision], LessEqual[y$95$m, 3.8e+27]]], N[(1.0 + N[(-8.0 * N[(N[(y$95$m / x), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3 \cdot 10^{-82} \lor \neg \left(y\_m \leq 9.8 \cdot 10^{-18}\right) \land y\_m \leq 3.8 \cdot 10^{+27}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y\_m} \cdot \frac{x}{y\_m}\right) + -1\\
\end{array}
\end{array}
if y < 2.9999999999999999e-82 or 9.8000000000000002e-18 < y < 3.80000000000000022e27Initial program 48.6%
*-commutative48.6%
fma-define48.7%
*-commutative48.7%
Simplified48.7%
Taylor expanded in y around 0 53.1%
unpow253.1%
unpow253.1%
times-frac58.8%
Applied egg-rr58.8%
if 2.9999999999999999e-82 < y < 9.8000000000000002e-18 or 3.80000000000000022e27 < y Initial program 49.3%
*-commutative49.3%
fma-define49.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in x around 0 72.4%
unpow272.4%
unpow272.4%
times-frac77.3%
Applied egg-rr77.3%
Final simplification63.6%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= y_m 2.2e-61) 1.0 (if (<= y_m 1e-17) -1.0 (if (<= y_m 1e+27) 1.0 -1.0))))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (y_m <= 2.2e-61) {
tmp = 1.0;
} else if (y_m <= 1e-17) {
tmp = -1.0;
} else if (y_m <= 1e+27) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if (y_m <= 2.2d-61) then
tmp = 1.0d0
else if (y_m <= 1d-17) then
tmp = -1.0d0
else if (y_m <= 1d+27) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double tmp;
if (y_m <= 2.2e-61) {
tmp = 1.0;
} else if (y_m <= 1e-17) {
tmp = -1.0;
} else if (y_m <= 1e+27) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if y_m <= 2.2e-61: tmp = 1.0 elif y_m <= 1e-17: tmp = -1.0 elif y_m <= 1e+27: tmp = 1.0 else: tmp = -1.0 return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if (y_m <= 2.2e-61) tmp = 1.0; elseif (y_m <= 1e-17) tmp = -1.0; elseif (y_m <= 1e+27) tmp = 1.0; else tmp = -1.0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if (y_m <= 2.2e-61) tmp = 1.0; elseif (y_m <= 1e-17) tmp = -1.0; elseif (y_m <= 1e+27) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[LessEqual[y$95$m, 2.2e-61], 1.0, If[LessEqual[y$95$m, 1e-17], -1.0, If[LessEqual[y$95$m, 1e+27], 1.0, -1.0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2.2 \cdot 10^{-61}:\\
\;\;\;\;1\\
\mathbf{elif}\;y\_m \leq 10^{-17}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y\_m \leq 10^{+27}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 2.20000000000000009e-61 or 1.00000000000000007e-17 < y < 1e27Initial program 50.5%
*-commutative50.5%
fma-define50.5%
*-commutative50.5%
Simplified50.5%
Taylor expanded in x around inf 56.8%
if 2.20000000000000009e-61 < y < 1.00000000000000007e-17 or 1e27 < y Initial program 43.1%
*-commutative43.1%
fma-define43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in x around 0 81.3%
Final simplification62.4%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 -1.0)
y_m = fabs(y);
double code(double x, double y_m) {
return -1.0;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = -1.0d0
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return -1.0;
}
y_m = math.fabs(y) def code(x, y_m): return -1.0
y_m = abs(y) function code(x, y_m) return -1.0 end
y_m = abs(y); function tmp = code(x, y_m) tmp = -1.0; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := -1.0
\begin{array}{l}
y_m = \left|y\right|
\\
-1
\end{array}
Initial program 48.8%
*-commutative48.8%
fma-define48.8%
*-commutative48.8%
Simplified48.8%
Taylor expanded in x around 0 51.8%
Final simplification51.8%
(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 2024067
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(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))))