
(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 10 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 (hypot x (* y_m 2.0)))) (* (/ 1.0 (/ t_0 (fma y_m 2.0 x))) (/ (+ x (* y_m -2.0)) t_0))))
y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = hypot(x, (y_m * 2.0));
return (1.0 / (t_0 / fma(y_m, 2.0, x))) * ((x + (y_m * -2.0)) / t_0);
}
y_m = abs(y) function code(x, y_m) t_0 = hypot(x, Float64(y_m * 2.0)) return Float64(Float64(1.0 / Float64(t_0 / fma(y_m, 2.0, x))) * Float64(Float64(x + Float64(y_m * -2.0)) / t_0)) end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(1.0 / N[(t$95$0 / N[(y$95$m * 2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\
\frac{1}{\frac{t\_0}{\mathsf{fma}\left(y\_m, 2, x\right)}} \cdot \frac{x + y\_m \cdot -2}{t\_0}
\end{array}
\end{array}
Initial program 49.9%
*-commutative49.9%
fma-define49.9%
*-commutative49.9%
Simplified49.9%
*-commutative49.9%
add-sqr-sqrt49.9%
difference-of-squares49.9%
*-commutative49.9%
associate-*r*49.9%
sqrt-prod49.9%
sqrt-unprod24.7%
add-sqr-sqrt38.7%
metadata-eval38.7%
*-commutative38.7%
associate-*r*38.6%
sqrt-prod38.6%
sqrt-unprod24.7%
add-sqr-sqrt49.9%
metadata-eval49.9%
Applied egg-rr49.9%
add-sqr-sqrt49.8%
times-frac51.3%
+-commutative51.3%
fma-define51.3%
fma-undefine51.3%
add-sqr-sqrt51.3%
hypot-define51.3%
sqrt-prod25.5%
sqrt-prod25.5%
metadata-eval25.5%
associate-*l*25.5%
add-sqr-sqrt51.3%
Applied egg-rr99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
Applied egg-rr99.9%
Final simplification99.9%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (let* ((t_0 (hypot x (* y_m 2.0)))) (* (/ (+ x (* y_m -2.0)) t_0) (/ (fma y_m 2.0 x) t_0))))
y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = hypot(x, (y_m * 2.0));
return ((x + (y_m * -2.0)) / t_0) * (fma(y_m, 2.0, x) / t_0);
}
y_m = abs(y) function code(x, y_m) t_0 = hypot(x, Float64(y_m * 2.0)) return Float64(Float64(Float64(x + Float64(y_m * -2.0)) / t_0) * Float64(fma(y_m, 2.0, x) / t_0)) end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(y$95$m * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\
\frac{x + y\_m \cdot -2}{t\_0} \cdot \frac{\mathsf{fma}\left(y\_m, 2, x\right)}{t\_0}
\end{array}
\end{array}
Initial program 49.9%
*-commutative49.9%
fma-define49.9%
*-commutative49.9%
Simplified49.9%
*-commutative49.9%
add-sqr-sqrt49.9%
difference-of-squares49.9%
*-commutative49.9%
associate-*r*49.9%
sqrt-prod49.9%
sqrt-unprod24.7%
add-sqr-sqrt38.7%
metadata-eval38.7%
*-commutative38.7%
associate-*r*38.6%
sqrt-prod38.6%
sqrt-unprod24.7%
add-sqr-sqrt49.9%
metadata-eval49.9%
Applied egg-rr49.9%
add-sqr-sqrt49.8%
times-frac51.3%
+-commutative51.3%
fma-define51.3%
fma-undefine51.3%
add-sqr-sqrt51.3%
hypot-define51.3%
sqrt-prod25.5%
sqrt-prod25.5%
metadata-eval25.5%
associate-*l*25.5%
add-sqr-sqrt51.3%
Applied egg-rr99.9%
Final simplification99.9%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (- (* x x) t_0)))
(if (<= y_m 4.5e-107)
(+ 1.0 (* -8.0 (* 2.0 (log (hypot 1.0 (/ y_m x))))))
(if (<= y_m 1.6e+26)
(/ t_1 (+ (* x x) t_0))
(if (<= y_m 4.1e+38)
1.0
(if (<= y_m 1e+150)
(/ t_1 (fma x x t_0))
(+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = (x * x) - t_0;
double tmp;
if (y_m <= 4.5e-107) {
tmp = 1.0 + (-8.0 * (2.0 * log(hypot(1.0, (y_m / x)))));
} else if (y_m <= 1.6e+26) {
tmp = t_1 / ((x * x) + t_0);
} else if (y_m <= 4.1e+38) {
tmp = 1.0;
} else if (y_m <= 1e+150) {
tmp = t_1 / fma(x, x, t_0);
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
}
return tmp;
}
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(Float64(x * x) - t_0) tmp = 0.0 if (y_m <= 4.5e-107) tmp = Float64(1.0 + Float64(-8.0 * Float64(2.0 * log(hypot(1.0, Float64(y_m / x)))))); elseif (y_m <= 1.6e+26) tmp = Float64(t_1 / Float64(Float64(x * x) + t_0)); elseif (y_m <= 4.1e+38) tmp = 1.0; elseif (y_m <= 1e+150) tmp = Float64(t_1 / fma(x, x, t_0)); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -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]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[y$95$m, 4.5e-107], N[(1.0 + N[(-8.0 * N[(2.0 * N[Log[N[Sqrt[1.0 ^ 2 + N[(y$95$m / x), $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.6e+26], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 4.1e+38], 1.0, If[LessEqual[y$95$m, 1e+150], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $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)\\
t_1 := x \cdot x - t\_0\\
\mathbf{if}\;y\_m \leq 4.5 \cdot 10^{-107}:\\
\;\;\;\;1 + -8 \cdot \left(2 \cdot \log \left(\mathsf{hypot}\left(1, \frac{y\_m}{x}\right)\right)\right)\\
\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;\frac{t\_1}{x \cdot x + t\_0}\\
\mathbf{elif}\;y\_m \leq 4.1 \cdot 10^{+38}:\\
\;\;\;\;1\\
\mathbf{elif}\;y\_m \leq 10^{+150}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(x, x, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\
\end{array}
\end{array}
if y < 4.50000000000000016e-107Initial program 51.0%
*-commutative51.0%
fma-define51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in y around 0 52.3%
add-log-exp52.1%
add-sqr-sqrt52.1%
pow252.1%
sqrt-div52.1%
unpow252.1%
sqrt-prod17.5%
add-sqr-sqrt54.2%
unpow254.2%
sqrt-prod30.3%
add-sqr-sqrt58.6%
Applied egg-rr58.6%
Taylor expanded in y around 0 52.7%
unpow252.7%
unpow252.7%
times-frac60.3%
unpow260.3%
Simplified60.3%
add-sqr-sqrt60.3%
log-prod60.3%
unpow260.3%
hypot-1-def60.3%
unpow260.3%
hypot-1-def61.9%
Applied egg-rr61.9%
count-261.9%
Simplified61.9%
if 4.50000000000000016e-107 < y < 1.60000000000000014e26Initial program 76.6%
if 1.60000000000000014e26 < y < 4.1000000000000003e38Initial program 0.0%
*-commutative0.0%
fma-define0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in x around inf 100.0%
if 4.1000000000000003e38 < y < 9.99999999999999981e149Initial program 90.7%
*-commutative90.7%
fma-define90.9%
*-commutative90.9%
Simplified90.9%
if 9.99999999999999981e149 < y Initial program 5.0%
*-commutative5.0%
fma-define5.0%
*-commutative5.0%
Simplified5.0%
Taylor expanded in x around 0 67.5%
Taylor expanded in x around 0 77.6%
unpow277.6%
unpow277.6%
times-frac90.8%
unpow290.8%
Simplified90.8%
pow290.8%
clear-num90.8%
un-div-inv90.8%
Applied egg-rr90.8%
Final simplification70.9%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (- (* x x) t_0)))
(if (<= y_m 9e-107)
(+ 1.0 (* -8.0 (log (+ 1.0 (/ (/ y_m x) (/ x y_m))))))
(if (<= y_m 1.45e+26)
(/ t_1 (+ (* x x) t_0))
(if (<= y_m 6.6e+38)
1.0
(if (<= y_m 1.58e+150)
(/ t_1 (fma x x t_0))
(+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = (x * x) - t_0;
double tmp;
if (y_m <= 9e-107) {
tmp = 1.0 + (-8.0 * log((1.0 + ((y_m / x) / (x / y_m)))));
} else if (y_m <= 1.45e+26) {
tmp = t_1 / ((x * x) + t_0);
} else if (y_m <= 6.6e+38) {
tmp = 1.0;
} else if (y_m <= 1.58e+150) {
tmp = t_1 / fma(x, x, t_0);
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
}
return tmp;
}
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(Float64(x * x) - t_0) tmp = 0.0 if (y_m <= 9e-107) tmp = Float64(1.0 + Float64(-8.0 * log(Float64(1.0 + Float64(Float64(y_m / x) / Float64(x / y_m)))))); elseif (y_m <= 1.45e+26) tmp = Float64(t_1 / Float64(Float64(x * x) + t_0)); elseif (y_m <= 6.6e+38) tmp = 1.0; elseif (y_m <= 1.58e+150) tmp = Float64(t_1 / fma(x, x, t_0)); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -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]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[y$95$m, 9e-107], N[(1.0 + N[(-8.0 * N[Log[N[(1.0 + N[(N[(y$95$m / x), $MachinePrecision] / N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.45e+26], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 6.6e+38], 1.0, If[LessEqual[y$95$m, 1.58e+150], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $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)\\
t_1 := x \cdot x - t\_0\\
\mathbf{if}\;y\_m \leq 9 \cdot 10^{-107}:\\
\;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y\_m}{x}}{\frac{x}{y\_m}}\right)\\
\mathbf{elif}\;y\_m \leq 1.45 \cdot 10^{+26}:\\
\;\;\;\;\frac{t\_1}{x \cdot x + t\_0}\\
\mathbf{elif}\;y\_m \leq 6.6 \cdot 10^{+38}:\\
\;\;\;\;1\\
\mathbf{elif}\;y\_m \leq 1.58 \cdot 10^{+150}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(x, x, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\
\end{array}
\end{array}
if y < 9.00000000000000032e-107Initial program 51.0%
*-commutative51.0%
fma-define51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in y around 0 52.3%
add-log-exp52.1%
add-sqr-sqrt52.1%
pow252.1%
sqrt-div52.1%
unpow252.1%
sqrt-prod17.5%
add-sqr-sqrt54.2%
unpow254.2%
sqrt-prod30.3%
add-sqr-sqrt58.6%
Applied egg-rr58.6%
Taylor expanded in y around 0 52.7%
unpow252.7%
unpow252.7%
times-frac60.3%
unpow260.3%
Simplified60.3%
unpow260.3%
clear-num60.3%
div-inv60.3%
Applied egg-rr60.3%
if 9.00000000000000032e-107 < y < 1.45e26Initial program 76.6%
if 1.45e26 < y < 6.5999999999999998e38Initial program 0.0%
*-commutative0.0%
fma-define0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in x around inf 100.0%
if 6.5999999999999998e38 < y < 1.57999999999999993e150Initial program 90.7%
*-commutative90.7%
fma-define90.9%
*-commutative90.9%
Simplified90.9%
if 1.57999999999999993e150 < y Initial program 5.0%
*-commutative5.0%
fma-define5.0%
*-commutative5.0%
Simplified5.0%
Taylor expanded in x around 0 67.5%
Taylor expanded in x around 0 77.6%
unpow277.6%
unpow277.6%
times-frac90.8%
unpow290.8%
Simplified90.8%
pow290.8%
clear-num90.8%
un-div-inv90.8%
Applied egg-rr90.8%
Final simplification69.9%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= y_m 1.65e-105)
(+ 1.0 (* -8.0 (log (+ 1.0 (/ (/ y_m x) (/ x y_m))))))
(if (<= y_m 1.6e+26)
t_1
(if (<= y_m 8e+38)
1.0
(if (<= y_m 1.58e+150)
t_1
(+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if (y_m <= 1.65e-105) {
tmp = 1.0 + (-8.0 * log((1.0 + ((y_m / x) / (x / y_m)))));
} else if (y_m <= 1.6e+26) {
tmp = t_1;
} else if (y_m <= 8e+38) {
tmp = 1.0;
} else if (y_m <= 1.58e+150) {
tmp = t_1;
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -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) :: t_1
real(8) :: tmp
t_0 = y_m * (y_m * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
if (y_m <= 1.65d-105) then
tmp = 1.0d0 + ((-8.0d0) * log((1.0d0 + ((y_m / x) / (x / y_m)))))
else if (y_m <= 1.6d+26) then
tmp = t_1
else if (y_m <= 8d+38) then
tmp = 1.0d0
else if (y_m <= 1.58d+150) then
tmp = t_1
else
tmp = (0.5d0 * ((x / y_m) / (y_m / x))) + (-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 t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if (y_m <= 1.65e-105) {
tmp = 1.0 + (-8.0 * Math.log((1.0 + ((y_m / x) / (x / y_m)))));
} else if (y_m <= 1.6e+26) {
tmp = t_1;
} else if (y_m <= 8e+38) {
tmp = 1.0;
} else if (y_m <= 1.58e+150) {
tmp = t_1;
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) tmp = 0 if y_m <= 1.65e-105: tmp = 1.0 + (-8.0 * math.log((1.0 + ((y_m / x) / (x / y_m))))) elif y_m <= 1.6e+26: tmp = t_1 elif y_m <= 8e+38: tmp = 1.0 elif y_m <= 1.58e+150: tmp = t_1 else: tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0 return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) tmp = 0.0 if (y_m <= 1.65e-105) tmp = Float64(1.0 + Float64(-8.0 * log(Float64(1.0 + Float64(Float64(y_m / x) / Float64(x / y_m)))))); elseif (y_m <= 1.6e+26) tmp = t_1; elseif (y_m <= 8e+38) tmp = 1.0; elseif (y_m <= 1.58e+150) tmp = t_1; else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -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); t_1 = ((x * x) - t_0) / ((x * x) + t_0); tmp = 0.0; if (y_m <= 1.65e-105) tmp = 1.0 + (-8.0 * log((1.0 + ((y_m / x) / (x / y_m))))); elseif (y_m <= 1.6e+26) tmp = t_1; elseif (y_m <= 8e+38) tmp = 1.0; elseif (y_m <= 1.58e+150) tmp = t_1; else tmp = (0.5 * ((x / y_m) / (y_m / x))) + -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]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 1.65e-105], N[(1.0 + N[(-8.0 * N[Log[N[(1.0 + N[(N[(y$95$m / x), $MachinePrecision] / N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.6e+26], t$95$1, If[LessEqual[y$95$m, 8e+38], 1.0, If[LessEqual[y$95$m, 1.58e+150], t$95$1, N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $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)\\
t_1 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\
\mathbf{if}\;y\_m \leq 1.65 \cdot 10^{-105}:\\
\;\;\;\;1 + -8 \cdot \log \left(1 + \frac{\frac{y\_m}{x}}{\frac{x}{y\_m}}\right)\\
\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y\_m \leq 8 \cdot 10^{+38}:\\
\;\;\;\;1\\
\mathbf{elif}\;y\_m \leq 1.58 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\
\end{array}
\end{array}
if y < 1.6499999999999999e-105Initial program 51.0%
*-commutative51.0%
fma-define51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in y around 0 52.3%
add-log-exp52.1%
add-sqr-sqrt52.1%
pow252.1%
sqrt-div52.1%
unpow252.1%
sqrt-prod17.5%
add-sqr-sqrt54.2%
unpow254.2%
sqrt-prod30.3%
add-sqr-sqrt58.6%
Applied egg-rr58.6%
Taylor expanded in y around 0 52.7%
unpow252.7%
unpow252.7%
times-frac60.3%
unpow260.3%
Simplified60.3%
unpow260.3%
clear-num60.3%
div-inv60.3%
Applied egg-rr60.3%
if 1.6499999999999999e-105 < y < 1.60000000000000014e26 or 7.99999999999999982e38 < y < 1.57999999999999993e150Initial program 82.6%
if 1.60000000000000014e26 < y < 7.99999999999999982e38Initial program 0.0%
*-commutative0.0%
fma-define0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in x around inf 100.0%
if 1.57999999999999993e150 < y Initial program 5.0%
*-commutative5.0%
fma-define5.0%
*-commutative5.0%
Simplified5.0%
Taylor expanded in x around 0 67.5%
Taylor expanded in x around 0 77.6%
unpow277.6%
unpow277.6%
times-frac90.8%
unpow290.8%
Simplified90.8%
pow290.8%
clear-num90.8%
un-div-inv90.8%
Applied egg-rr90.8%
Final simplification69.9%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= y_m 4.8e-107)
(+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x))))
(if (<= y_m 1.6e+26)
t_1
(if (<= y_m 3.8e+38)
1.0
(if (<= y_m 1.32e+150)
t_1
(+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if (y_m <= 4.8e-107) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else if (y_m <= 1.6e+26) {
tmp = t_1;
} else if (y_m <= 3.8e+38) {
tmp = 1.0;
} else if (y_m <= 1.32e+150) {
tmp = t_1;
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -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) :: t_1
real(8) :: tmp
t_0 = y_m * (y_m * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
if (y_m <= 4.8d-107) then
tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
else if (y_m <= 1.6d+26) then
tmp = t_1
else if (y_m <= 3.8d+38) then
tmp = 1.0d0
else if (y_m <= 1.32d+150) then
tmp = t_1
else
tmp = (0.5d0 * ((x / y_m) / (y_m / x))) + (-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 t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if (y_m <= 4.8e-107) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else if (y_m <= 1.6e+26) {
tmp = t_1;
} else if (y_m <= 3.8e+38) {
tmp = 1.0;
} else if (y_m <= 1.32e+150) {
tmp = t_1;
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) tmp = 0 if y_m <= 4.8e-107: tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))) elif y_m <= 1.6e+26: tmp = t_1 elif y_m <= 3.8e+38: tmp = 1.0 elif y_m <= 1.32e+150: tmp = t_1 else: tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0 return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) tmp = 0.0 if (y_m <= 4.8e-107) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y_m / x) * Float64(y_m / x)))); elseif (y_m <= 1.6e+26) tmp = t_1; elseif (y_m <= 3.8e+38) tmp = 1.0; elseif (y_m <= 1.32e+150) tmp = t_1; else tmp = Float64(Float64(0.5 * Float64(Float64(x / y_m) / Float64(y_m / x))) + -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); t_1 = ((x * x) - t_0) / ((x * x) + t_0); tmp = 0.0; if (y_m <= 4.8e-107) tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))); elseif (y_m <= 1.6e+26) tmp = t_1; elseif (y_m <= 3.8e+38) tmp = 1.0; elseif (y_m <= 1.32e+150) tmp = t_1; else tmp = (0.5 * ((x / y_m) / (y_m / x))) + -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]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 4.8e-107], 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, 1.6e+26], t$95$1, If[LessEqual[y$95$m, 3.8e+38], 1.0, If[LessEqual[y$95$m, 1.32e+150], t$95$1, N[(N[(0.5 * N[(N[(x / y$95$m), $MachinePrecision] / N[(y$95$m / x), $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)\\
t_1 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-107}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y\_m \leq 3.8 \cdot 10^{+38}:\\
\;\;\;\;1\\
\mathbf{elif}\;y\_m \leq 1.32 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\
\end{array}
\end{array}
if y < 4.79999999999999989e-107Initial program 51.0%
*-commutative51.0%
fma-define51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in y around 0 52.3%
unpow252.3%
unpow252.3%
times-frac59.1%
Applied egg-rr59.1%
if 4.79999999999999989e-107 < y < 1.60000000000000014e26 or 3.7999999999999998e38 < y < 1.32e150Initial program 82.6%
if 1.60000000000000014e26 < y < 3.7999999999999998e38Initial program 0.0%
*-commutative0.0%
fma-define0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in x around inf 100.0%
if 1.32e150 < y Initial program 5.0%
*-commutative5.0%
fma-define5.0%
*-commutative5.0%
Simplified5.0%
Taylor expanded in x around 0 67.5%
Taylor expanded in x around 0 77.6%
unpow277.6%
unpow277.6%
times-frac90.8%
unpow290.8%
Simplified90.8%
pow290.8%
clear-num90.8%
un-div-inv90.8%
Applied egg-rr90.8%
Final simplification69.2%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (or (<= y_m 1.7e-43) (and (not (<= y_m 3.2e+25)) (<= y_m 4.5e+56))) (+ 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.7e-43) || (!(y_m <= 3.2e+25) && (y_m <= 4.5e+56))) {
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.7d-43) .or. (.not. (y_m <= 3.2d+25)) .and. (y_m <= 4.5d+56)) 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.7e-43) || (!(y_m <= 3.2e+25) && (y_m <= 4.5e+56))) {
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.7e-43) or (not (y_m <= 3.2e+25) and (y_m <= 4.5e+56)): 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.7e-43) || (!(y_m <= 3.2e+25) && (y_m <= 4.5e+56))) 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.7e-43) || (~((y_m <= 3.2e+25)) && (y_m <= 4.5e+56))) 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.7e-43], And[N[Not[LessEqual[y$95$m, 3.2e+25]], $MachinePrecision], LessEqual[y$95$m, 4.5e+56]]], 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.7 \cdot 10^{-43} \lor \neg \left(y\_m \leq 3.2 \cdot 10^{+25}\right) \land y\_m \leq 4.5 \cdot 10^{+56}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 1.7e-43 or 3.1999999999999999e25 < y < 4.5000000000000003e56Initial program 54.4%
*-commutative54.4%
fma-define54.4%
*-commutative54.4%
Simplified54.4%
Taylor expanded in y around 0 53.3%
unpow253.3%
unpow253.3%
times-frac59.3%
Applied egg-rr59.3%
if 1.7e-43 < y < 3.1999999999999999e25 or 4.5000000000000003e56 < y Initial program 38.0%
*-commutative38.0%
fma-define38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in x around 0 81.3%
Final simplification65.4%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (or (<= y_m 2e-43) (and (not (<= y_m 1.55e+25)) (<= y_m 5.5e+56))) (+ 1.0 (* -8.0 (* (/ y_m x) (/ y_m x)))) (+ (* 0.5 (/ (/ x y_m) (/ y_m x))) -1.0)))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if ((y_m <= 2e-43) || (!(y_m <= 1.55e+25) && (y_m <= 5.5e+56))) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -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 <= 2d-43) .or. (.not. (y_m <= 1.55d+25)) .and. (y_m <= 5.5d+56)) then
tmp = 1.0d0 + ((-8.0d0) * ((y_m / x) * (y_m / x)))
else
tmp = (0.5d0 * ((x / y_m) / (y_m / x))) + (-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 <= 2e-43) || (!(y_m <= 1.55e+25) && (y_m <= 5.5e+56))) {
tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x)));
} else {
tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if (y_m <= 2e-43) or (not (y_m <= 1.55e+25) and (y_m <= 5.5e+56)): tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))) else: tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0 return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if ((y_m <= 2e-43) || (!(y_m <= 1.55e+25) && (y_m <= 5.5e+56))) 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(y_m / x))) + -1.0); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if ((y_m <= 2e-43) || (~((y_m <= 1.55e+25)) && (y_m <= 5.5e+56))) tmp = 1.0 + (-8.0 * ((y_m / x) * (y_m / x))); else tmp = (0.5 * ((x / y_m) / (y_m / x))) + -1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[Or[LessEqual[y$95$m, 2e-43], And[N[Not[LessEqual[y$95$m, 1.55e+25]], $MachinePrecision], LessEqual[y$95$m, 5.5e+56]]], 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[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2 \cdot 10^{-43} \lor \neg \left(y\_m \leq 1.55 \cdot 10^{+25}\right) \land y\_m \leq 5.5 \cdot 10^{+56}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y\_m}{x} \cdot \frac{y\_m}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y\_m}}{\frac{y\_m}{x}} + -1\\
\end{array}
\end{array}
if y < 2.00000000000000015e-43 or 1.5499999999999999e25 < y < 5.5000000000000002e56Initial program 54.4%
*-commutative54.4%
fma-define54.4%
*-commutative54.4%
Simplified54.4%
Taylor expanded in y around 0 53.3%
unpow253.3%
unpow253.3%
times-frac59.3%
Applied egg-rr59.3%
if 2.00000000000000015e-43 < y < 1.5499999999999999e25 or 5.5000000000000002e56 < y Initial program 38.0%
*-commutative38.0%
fma-define38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in x around 0 66.2%
Taylor expanded in x around 0 75.2%
unpow275.2%
unpow275.2%
times-frac82.7%
unpow282.7%
Simplified82.7%
pow282.7%
clear-num82.7%
un-div-inv82.7%
Applied egg-rr82.7%
Final simplification65.8%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= y_m 1.3e-43) 1.0 (if (<= y_m 5e+25) -1.0 (if (<= y_m 5e+56) 1.0 -1.0))))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (y_m <= 1.3e-43) {
tmp = 1.0;
} else if (y_m <= 5e+25) {
tmp = -1.0;
} else if (y_m <= 5e+56) {
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 <= 1.3d-43) then
tmp = 1.0d0
else if (y_m <= 5d+25) then
tmp = -1.0d0
else if (y_m <= 5d+56) 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 <= 1.3e-43) {
tmp = 1.0;
} else if (y_m <= 5e+25) {
tmp = -1.0;
} else if (y_m <= 5e+56) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if y_m <= 1.3e-43: tmp = 1.0 elif y_m <= 5e+25: tmp = -1.0 elif y_m <= 5e+56: tmp = 1.0 else: tmp = -1.0 return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if (y_m <= 1.3e-43) tmp = 1.0; elseif (y_m <= 5e+25) tmp = -1.0; elseif (y_m <= 5e+56) 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 <= 1.3e-43) tmp = 1.0; elseif (y_m <= 5e+25) tmp = -1.0; elseif (y_m <= 5e+56) 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, 1.3e-43], 1.0, If[LessEqual[y$95$m, 5e+25], -1.0, If[LessEqual[y$95$m, 5e+56], 1.0, -1.0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.3 \cdot 10^{-43}:\\
\;\;\;\;1\\
\mathbf{elif}\;y\_m \leq 5 \cdot 10^{+25}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y\_m \leq 5 \cdot 10^{+56}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 1.3e-43 or 5.00000000000000024e25 < y < 5.00000000000000024e56Initial program 54.4%
*-commutative54.4%
fma-define54.4%
*-commutative54.4%
Simplified54.4%
Taylor expanded in x around inf 57.7%
if 1.3e-43 < y < 5.00000000000000024e25 or 5.00000000000000024e56 < y Initial program 38.0%
*-commutative38.0%
fma-define38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in x around 0 81.3%
Final simplification64.2%
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 49.9%
*-commutative49.9%
fma-define49.9%
*-commutative49.9%
Simplified49.9%
Taylor expanded in x around 0 52.5%
Final simplification52.5%
(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 2024041
(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))))