
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0)))
(t_1 (* y (* y 4.0)))
(t_2 (- (* x x) t_1)))
(if (<= (* x x) 0.0)
(+
(fma (log (exp (pow (/ x y) 2.0))) 0.5 -1.0)
(* -0.125 (pow (/ x y) 4.0)))
(if (<= (* x x) 1e-17)
(/ t_2 (fma x x t_1))
(if (<= (* x x) 1e+105)
t_0
(if (<= (* x x) 1e+150)
(/ t_2 (+ (* x x) t_1))
(if (<= (* x x) 2e+193) t_0 1.0)))))))
double code(double x, double y) {
double t_0 = -1.0 + (((x / y) / (y / x)) / 4.0);
double t_1 = y * (y * 4.0);
double t_2 = (x * x) - t_1;
double tmp;
if ((x * x) <= 0.0) {
tmp = fma(log(exp(pow((x / y), 2.0))), 0.5, -1.0) + (-0.125 * pow((x / y), 4.0));
} else if ((x * x) <= 1e-17) {
tmp = t_2 / fma(x, x, t_1);
} else if ((x * x) <= 1e+105) {
tmp = t_0;
} else if ((x * x) <= 1e+150) {
tmp = t_2 / ((x * x) + t_1);
} else if ((x * x) <= 2e+193) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)) t_1 = Float64(y * Float64(y * 4.0)) t_2 = Float64(Float64(x * x) - t_1) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = Float64(fma(log(exp((Float64(x / y) ^ 2.0))), 0.5, -1.0) + Float64(-0.125 * (Float64(x / y) ^ 4.0))); elseif (Float64(x * x) <= 1e-17) tmp = Float64(t_2 / fma(x, x, t_1)); elseif (Float64(x * x) <= 1e+105) tmp = t_0; elseif (Float64(x * x) <= 1e+150) tmp = Float64(t_2 / Float64(Float64(x * x) + t_1)); elseif (Float64(x * x) <= 2e+193) tmp = t_0; else tmp = 1.0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * x), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(N[(N[Log[N[Exp[N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 0.5 + -1.0), $MachinePrecision] + N[(-0.125 * N[Power[N[(x / y), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], N[(t$95$2 / N[(x * x + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], N[(t$95$2 / N[(N[(x * x), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
t_1 := y \cdot \left(y \cdot 4\right)\\
t_2 := x \cdot x - t_1\\
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\log \left(e^{{\left(\frac{x}{y}\right)}^{2}}\right), 0.5, -1\right) + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4}\\
\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;\frac{t_2}{\mathsf{fma}\left(x, x, t_1\right)}\\
\mathbf{elif}\;x \cdot x \leq 10^{+105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 10^{+150}:\\
\;\;\;\;\frac{t_2}{x \cdot x + t_1}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 46.7%
*-commutative46.7%
fma-def46.7%
*-commutative46.7%
Simplified46.7%
Taylor expanded in x around 0 45.3%
unpow245.3%
unpow245.3%
*-commutative45.3%
associate-*r*46.7%
fma-def46.7%
Simplified46.7%
Taylor expanded in x around 0 55.0%
associate--l+55.0%
fma-def55.0%
metadata-eval55.0%
pow-plus55.0%
unpow355.0%
associate-*r*55.0%
metadata-eval55.0%
pow-sqr55.0%
unpow255.0%
unpow255.0%
times-frac73.3%
times-frac73.3%
times-frac73.3%
unpow273.3%
unpow273.3%
pow-sqr73.3%
metadata-eval73.3%
fma-neg73.3%
Simplified86.6%
fma-udef86.6%
+-commutative86.6%
fma-udef86.6%
*-commutative86.6%
fma-def86.6%
Applied egg-rr86.6%
add-log-exp86.7%
Applied egg-rr86.7%
if 0.0 < (*.f64 x x) < 1.00000000000000007e-17Initial program 83.8%
*-commutative83.8%
fma-def83.8%
*-commutative83.8%
Simplified83.8%
if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193Initial program 39.5%
*-commutative39.5%
fma-def39.5%
*-commutative39.5%
Simplified39.5%
Taylor expanded in x around 0 19.5%
unpow219.5%
*-commutative19.5%
associate-*r*19.5%
Simplified19.5%
div-sub19.4%
associate-*r*19.4%
associate-/r*19.4%
frac-times19.4%
pow219.4%
*-inverses80.0%
Applied egg-rr80.0%
unpow280.0%
clear-num80.0%
un-div-inv80.0%
Applied egg-rr80.0%
if 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149Initial program 92.9%
if 2.00000000000000013e193 < (*.f64 x x) Initial program 22.0%
*-commutative22.0%
fma-def22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in x around inf 86.8%
Final simplification85.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (- (* x x) t_0))
(t_2 (/ (/ x y) (/ y x)))
(t_3 (+ -1.0 (/ t_2 4.0))))
(if (<= (* x x) 0.0)
(+ (* -0.125 (pow (/ x y) 4.0)) (fma t_2 0.5 -1.0))
(if (<= (* x x) 1e-17)
(/ t_1 (fma x x t_0))
(if (<= (* x x) 1e+105)
t_3
(if (<= (* x x) 1e+150)
(/ t_1 (+ (* x x) t_0))
(if (<= (* x x) 2e+193) t_3 1.0)))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = (x * x) - t_0;
double t_2 = (x / y) / (y / x);
double t_3 = -1.0 + (t_2 / 4.0);
double tmp;
if ((x * x) <= 0.0) {
tmp = (-0.125 * pow((x / y), 4.0)) + fma(t_2, 0.5, -1.0);
} else if ((x * x) <= 1e-17) {
tmp = t_1 / fma(x, x, t_0);
} else if ((x * x) <= 1e+105) {
tmp = t_3;
} else if ((x * x) <= 1e+150) {
tmp = t_1 / ((x * x) + t_0);
} else if ((x * x) <= 2e+193) {
tmp = t_3;
} else {
tmp = 1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(Float64(x * x) - t_0) t_2 = Float64(Float64(x / y) / Float64(y / x)) t_3 = Float64(-1.0 + Float64(t_2 / 4.0)) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = Float64(Float64(-0.125 * (Float64(x / y) ^ 4.0)) + fma(t_2, 0.5, -1.0)); elseif (Float64(x * x) <= 1e-17) tmp = Float64(t_1 / fma(x, x, t_0)); elseif (Float64(x * x) <= 1e+105) tmp = t_3; elseif (Float64(x * x) <= 1e+150) tmp = Float64(t_1 / Float64(Float64(x * x) + t_0)); elseif (Float64(x * x) <= 2e+193) tmp = t_3; else tmp = 1.0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-1.0 + N[(t$95$2 / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(N[(-0.125 * N[Power[N[(x / y), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * 0.5 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$3, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$3, 1.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := x \cdot x - t_0\\
t_2 := \frac{\frac{x}{y}}{\frac{y}{x}}\\
t_3 := -1 + \frac{t_2}{4}\\
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;-0.125 \cdot {\left(\frac{x}{y}\right)}^{4} + \mathsf{fma}\left(t_2, 0.5, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, x, t_0\right)}\\
\mathbf{elif}\;x \cdot x \leq 10^{+105}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;x \cdot x \leq 10^{+150}:\\
\;\;\;\;\frac{t_1}{x \cdot x + t_0}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 46.7%
*-commutative46.7%
fma-def46.7%
*-commutative46.7%
Simplified46.7%
Taylor expanded in x around 0 45.3%
unpow245.3%
unpow245.3%
*-commutative45.3%
associate-*r*46.7%
fma-def46.7%
Simplified46.7%
Taylor expanded in x around 0 55.0%
associate--l+55.0%
fma-def55.0%
metadata-eval55.0%
pow-plus55.0%
unpow355.0%
associate-*r*55.0%
metadata-eval55.0%
pow-sqr55.0%
unpow255.0%
unpow255.0%
times-frac73.3%
times-frac73.3%
times-frac73.3%
unpow273.3%
unpow273.3%
pow-sqr73.3%
metadata-eval73.3%
fma-neg73.3%
Simplified86.6%
fma-udef86.6%
+-commutative86.6%
fma-udef86.6%
*-commutative86.6%
fma-def86.6%
Applied egg-rr86.6%
unpow285.1%
clear-num85.1%
un-div-inv85.1%
Applied egg-rr86.6%
if 0.0 < (*.f64 x x) < 1.00000000000000007e-17Initial program 83.8%
*-commutative83.8%
fma-def83.8%
*-commutative83.8%
Simplified83.8%
if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193Initial program 39.5%
*-commutative39.5%
fma-def39.5%
*-commutative39.5%
Simplified39.5%
Taylor expanded in x around 0 19.5%
unpow219.5%
*-commutative19.5%
associate-*r*19.5%
Simplified19.5%
div-sub19.4%
associate-*r*19.4%
associate-/r*19.4%
frac-times19.4%
pow219.4%
*-inverses80.0%
Applied egg-rr80.0%
unpow280.0%
clear-num80.0%
un-div-inv80.0%
Applied egg-rr80.0%
if 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149Initial program 92.9%
if 2.00000000000000013e193 < (*.f64 x x) Initial program 22.0%
*-commutative22.0%
fma-def22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in x around inf 86.8%
Final simplification85.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (- (* x x) t_0))
(t_2 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
(if (<= (* x x) 0.0)
(fma 0.5 (* (/ x y) (/ x y)) -1.0)
(if (<= (* x x) 1e-17)
(/ t_1 (fma x x t_0))
(if (<= (* x x) 1e+105)
t_2
(if (<= (* x x) 1e+150)
(/ t_1 (+ (* x x) t_0))
(if (<= (* x x) 2e+193) t_2 1.0)))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = (x * x) - t_0;
double t_2 = -1.0 + (((x / y) / (y / x)) / 4.0);
double tmp;
if ((x * x) <= 0.0) {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
} else if ((x * x) <= 1e-17) {
tmp = t_1 / fma(x, x, t_0);
} else if ((x * x) <= 1e+105) {
tmp = t_2;
} else if ((x * x) <= 1e+150) {
tmp = t_1 / ((x * x) + t_0);
} else if ((x * x) <= 2e+193) {
tmp = t_2;
} else {
tmp = 1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(Float64(x * x) - t_0) t_2 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); elseif (Float64(x * x) <= 1e-17) tmp = Float64(t_1 / fma(x, x, t_0)); elseif (Float64(x * x) <= 1e+105) tmp = t_2; elseif (Float64(x * x) <= 1e+150) tmp = Float64(t_1 / Float64(Float64(x * x) + t_0)); elseif (Float64(x * x) <= 2e+193) tmp = t_2; else tmp = 1.0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$2, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := x \cdot x - t_0\\
t_2 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, x, t_0\right)}\\
\mathbf{elif}\;x \cdot x \leq 10^{+105}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+150}:\\
\;\;\;\;\frac{t_1}{x \cdot x + t_0}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 46.7%
*-commutative46.7%
fma-def46.7%
*-commutative46.7%
Simplified46.7%
Taylor expanded in x around 0 73.3%
fma-neg73.3%
unpow273.3%
unpow273.3%
times-frac86.5%
metadata-eval86.5%
Simplified86.5%
if 0.0 < (*.f64 x x) < 1.00000000000000007e-17Initial program 83.8%
*-commutative83.8%
fma-def83.8%
*-commutative83.8%
Simplified83.8%
if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193Initial program 39.5%
*-commutative39.5%
fma-def39.5%
*-commutative39.5%
Simplified39.5%
Taylor expanded in x around 0 19.5%
unpow219.5%
*-commutative19.5%
associate-*r*19.5%
Simplified19.5%
div-sub19.4%
associate-*r*19.4%
associate-/r*19.4%
frac-times19.4%
pow219.4%
*-inverses80.0%
Applied egg-rr80.0%
unpow280.0%
clear-num80.0%
un-div-inv80.0%
Applied egg-rr80.0%
if 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149Initial program 92.9%
if 2.00000000000000013e193 < (*.f64 x x) Initial program 22.0%
*-commutative22.0%
fma-def22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in x around inf 86.8%
Final simplification85.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
(if (<= (* x x) 0.0)
(fma 0.5 (* (/ x y) (/ x y)) -1.0)
(if (<= (* x x) 1e-17)
t_1
(if (<= (* x x) 1e+105)
t_2
(if (<= (* x x) 1e+150) t_1 (if (<= (* x x) 2e+193) t_2 1.0)))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double t_2 = -1.0 + (((x / y) / (y / x)) / 4.0);
double tmp;
if ((x * x) <= 0.0) {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
} else if ((x * x) <= 1e-17) {
tmp = t_1;
} else if ((x * x) <= 1e+105) {
tmp = t_2;
} else if ((x * x) <= 1e+150) {
tmp = t_1;
} else if ((x * x) <= 2e+193) {
tmp = t_2;
} else {
tmp = 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(Float64(x * x) + t_0)) t_2 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); elseif (Float64(x * x) <= 1e-17) tmp = t_1; elseif (Float64(x * x) <= 1e+105) tmp = t_2; elseif (Float64(x * x) <= 1e+150) tmp = t_1; elseif (Float64(x * x) <= 2e+193) tmp = t_2; else tmp = 1.0; end return 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[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$2, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
t_2 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 10^{+105}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+150}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 46.7%
*-commutative46.7%
fma-def46.7%
*-commutative46.7%
Simplified46.7%
Taylor expanded in x around 0 73.3%
fma-neg73.3%
unpow273.3%
unpow273.3%
times-frac86.5%
metadata-eval86.5%
Simplified86.5%
if 0.0 < (*.f64 x x) < 1.00000000000000007e-17 or 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149Initial program 85.5%
if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193Initial program 39.5%
*-commutative39.5%
fma-def39.5%
*-commutative39.5%
Simplified39.5%
Taylor expanded in x around 0 19.5%
unpow219.5%
*-commutative19.5%
associate-*r*19.5%
Simplified19.5%
div-sub19.4%
associate-*r*19.4%
associate-/r*19.4%
frac-times19.4%
pow219.4%
*-inverses80.0%
Applied egg-rr80.0%
unpow280.0%
clear-num80.0%
un-div-inv80.0%
Applied egg-rr80.0%
if 2.00000000000000013e193 < (*.f64 x x) Initial program 22.0%
*-commutative22.0%
fma-def22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in x around inf 86.8%
Final simplification85.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (* -4.0 (/ (* y y) (* x x))))))
(if (<= (* x x) 3.9e-170)
-1.0
(if (<= (* x x) 1.2e-96)
t_0
(if (<= (* x x) 3.3e+109)
-1.0
(if (<= (* x x) 2.8e+150) t_0 (if (<= (* x x) 2e+193) -1.0 1.0)))))))
double code(double x, double y) {
double t_0 = 1.0 + (-4.0 * ((y * y) / (x * x)));
double tmp;
if ((x * x) <= 3.9e-170) {
tmp = -1.0;
} else if ((x * x) <= 1.2e-96) {
tmp = t_0;
} else if ((x * x) <= 3.3e+109) {
tmp = -1.0;
} else if ((x * x) <= 2.8e+150) {
tmp = t_0;
} else if ((x * x) <= 2e+193) {
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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + ((-4.0d0) * ((y * y) / (x * x)))
if ((x * x) <= 3.9d-170) then
tmp = -1.0d0
else if ((x * x) <= 1.2d-96) then
tmp = t_0
else if ((x * x) <= 3.3d+109) then
tmp = -1.0d0
else if ((x * x) <= 2.8d+150) then
tmp = t_0
else if ((x * x) <= 2d+193) then
tmp = -1.0d0
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 * y) / (x * x)));
double tmp;
if ((x * x) <= 3.9e-170) {
tmp = -1.0;
} else if ((x * x) <= 1.2e-96) {
tmp = t_0;
} else if ((x * x) <= 3.3e+109) {
tmp = -1.0;
} else if ((x * x) <= 2.8e+150) {
tmp = t_0;
} else if ((x * x) <= 2e+193) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-4.0 * ((y * y) / (x * x))) tmp = 0 if (x * x) <= 3.9e-170: tmp = -1.0 elif (x * x) <= 1.2e-96: tmp = t_0 elif (x * x) <= 3.3e+109: tmp = -1.0 elif (x * x) <= 2.8e+150: tmp = t_0 elif (x * x) <= 2e+193: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-4.0 * Float64(Float64(y * y) / Float64(x * x)))) tmp = 0.0 if (Float64(x * x) <= 3.9e-170) tmp = -1.0; elseif (Float64(x * x) <= 1.2e-96) tmp = t_0; elseif (Float64(x * x) <= 3.3e+109) tmp = -1.0; elseif (Float64(x * x) <= 2.8e+150) tmp = t_0; elseif (Float64(x * x) <= 2e+193) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-4.0 * ((y * y) / (x * x))); tmp = 0.0; if ((x * x) <= 3.9e-170) tmp = -1.0; elseif ((x * x) <= 1.2e-96) tmp = t_0; elseif ((x * x) <= 3.3e+109) tmp = -1.0; elseif ((x * x) <= 2.8e+150) tmp = t_0; elseif ((x * x) <= 2e+193) tmp = -1.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 * y), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 3.9e-170], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1.2e-96], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 3.3e+109], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 2.8e+150], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\
\mathbf{if}\;x \cdot x \leq 3.9 \cdot 10^{-170}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 1.2 \cdot 10^{-96}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 3.3 \cdot 10^{+109}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 2.8 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 3.90000000000000021e-170 or 1.2000000000000001e-96 < (*.f64 x x) < 3.2999999999999999e109 or 2.80000000000000009e150 < (*.f64 x x) < 2.00000000000000013e193Initial program 54.9%
*-commutative54.9%
fma-def54.9%
*-commutative54.9%
Simplified54.9%
Taylor expanded in x around 0 77.4%
if 3.90000000000000021e-170 < (*.f64 x x) < 1.2000000000000001e-96 or 3.2999999999999999e109 < (*.f64 x x) < 2.80000000000000009e150Initial program 93.7%
*-commutative93.7%
fma-def93.7%
*-commutative93.7%
Simplified93.7%
Taylor expanded in x around 0 93.7%
unpow293.7%
unpow293.7%
*-commutative93.7%
associate-*r*93.7%
fma-def93.8%
Simplified93.8%
Taylor expanded in y around 0 73.5%
unpow273.5%
Simplified73.5%
Taylor expanded in x around 0 73.5%
+-commutative73.5%
unpow273.5%
unpow273.5%
Simplified73.5%
if 2.00000000000000013e193 < (*.f64 x x) Initial program 22.0%
*-commutative22.0%
fma-def22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in x around inf 86.8%
Final simplification79.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= y 1e-162)
1.0
(if (<= y 2e+102)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (y <= 1e-162) {
tmp = 1.0;
} else if (y <= 2e+102) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} 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) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (y <= 1d-162) then
tmp = 1.0d0
else if (y <= 2d+102) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
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 t_0 = y * (y * 4.0);
double tmp;
if (y <= 1e-162) {
tmp = 1.0;
} else if (y <= 2e+102) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if y <= 1e-162: tmp = 1.0 elif y <= 2e+102: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = -1.0 + (((x / y) / (y / x)) / 4.0) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (y <= 1e-162) tmp = 1.0; elseif (y <= 2e+102) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (y <= 1e-162) tmp = 1.0; elseif (y <= 2e+102) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = -1.0 + (((x / y) / (y / x)) / 4.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1e-162], 1.0, If[LessEqual[y, 2e+102], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;y \leq 10^{-162}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+102}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\end{array}
\end{array}
if y < 9.99999999999999954e-163Initial program 53.7%
*-commutative53.7%
fma-def53.7%
*-commutative53.7%
Simplified53.7%
Taylor expanded in x around inf 54.0%
if 9.99999999999999954e-163 < y < 1.99999999999999995e102Initial program 76.6%
if 1.99999999999999995e102 < y Initial program 6.4%
*-commutative6.4%
fma-def6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in x around 0 6.6%
unpow26.6%
*-commutative6.6%
associate-*r*6.6%
Simplified6.6%
div-sub6.6%
associate-*r*6.6%
associate-/r*6.6%
frac-times6.7%
pow26.7%
*-inverses78.4%
Applied egg-rr78.4%
unpow278.4%
clear-num78.4%
un-div-inv78.4%
Applied egg-rr78.4%
Final simplification62.6%
(FPCore (x y) :precision binary64 (if (<= y 1.9e+14) 1.0 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
double code(double x, double y) {
double tmp;
if (y <= 1.9e+14) {
tmp = 1.0;
} 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 (y <= 1.9d+14) then
tmp = 1.0d0
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 (y <= 1.9e+14) {
tmp = 1.0;
} else {
tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.9e+14: tmp = 1.0 else: tmp = -1.0 + (((x / y) / (y / x)) / 4.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.9e+14) tmp = 1.0; else tmp = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.9e+14) tmp = 1.0; else tmp = -1.0 + (((x / y) / (y / x)) / 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.9e+14], 1.0, N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\
\end{array}
\end{array}
if y < 1.9e14Initial program 57.3%
*-commutative57.3%
fma-def57.3%
*-commutative57.3%
Simplified57.3%
Taylor expanded in x around inf 55.9%
if 1.9e14 < y Initial program 25.0%
*-commutative25.0%
fma-def25.0%
*-commutative25.0%
Simplified25.0%
Taylor expanded in x around 0 19.5%
unpow219.5%
*-commutative19.5%
associate-*r*19.5%
Simplified19.5%
div-sub19.5%
associate-*r*19.5%
associate-/r*19.5%
frac-times19.6%
pow219.6%
*-inverses72.3%
Applied egg-rr72.3%
unpow272.3%
clear-num72.3%
un-div-inv72.3%
Applied egg-rr72.3%
Final simplification60.0%
(FPCore (x y)
:precision binary64
(if (<= x 1.9e-85)
-1.0
(if (<= x 5e-50)
1.0
(if (<= x 3.3e+52)
-1.0
(if (<= x 1.35e+75) 1.0 (if (<= x 3.4e+96) -1.0 1.0))))))
double code(double x, double y) {
double tmp;
if (x <= 1.9e-85) {
tmp = -1.0;
} else if (x <= 5e-50) {
tmp = 1.0;
} else if (x <= 3.3e+52) {
tmp = -1.0;
} else if (x <= 1.35e+75) {
tmp = 1.0;
} else if (x <= 3.4e+96) {
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.9d-85) then
tmp = -1.0d0
else if (x <= 5d-50) then
tmp = 1.0d0
else if (x <= 3.3d+52) then
tmp = -1.0d0
else if (x <= 1.35d+75) then
tmp = 1.0d0
else if (x <= 3.4d+96) 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.9e-85) {
tmp = -1.0;
} else if (x <= 5e-50) {
tmp = 1.0;
} else if (x <= 3.3e+52) {
tmp = -1.0;
} else if (x <= 1.35e+75) {
tmp = 1.0;
} else if (x <= 3.4e+96) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.9e-85: tmp = -1.0 elif x <= 5e-50: tmp = 1.0 elif x <= 3.3e+52: tmp = -1.0 elif x <= 1.35e+75: tmp = 1.0 elif x <= 3.4e+96: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= 1.9e-85) tmp = -1.0; elseif (x <= 5e-50) tmp = 1.0; elseif (x <= 3.3e+52) tmp = -1.0; elseif (x <= 1.35e+75) tmp = 1.0; elseif (x <= 3.4e+96) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.9e-85) tmp = -1.0; elseif (x <= 5e-50) tmp = 1.0; elseif (x <= 3.3e+52) tmp = -1.0; elseif (x <= 1.35e+75) tmp = 1.0; elseif (x <= 3.4e+96) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.9e-85], -1.0, If[LessEqual[x, 5e-50], 1.0, If[LessEqual[x, 3.3e+52], -1.0, If[LessEqual[x, 1.35e+75], 1.0, If[LessEqual[x, 3.4e+96], -1.0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{-85}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-50}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+52}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+75}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+96}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.8999999999999999e-85 or 4.99999999999999968e-50 < x < 3.3e52 or 1.34999999999999999e75 < x < 3.4000000000000001e96Initial program 50.2%
*-commutative50.2%
fma-def50.2%
*-commutative50.2%
Simplified50.2%
Taylor expanded in x around 0 60.7%
if 1.8999999999999999e-85 < x < 4.99999999999999968e-50 or 3.3e52 < x < 1.34999999999999999e75 or 3.4000000000000001e96 < x Initial program 45.9%
*-commutative45.9%
fma-def45.9%
*-commutative45.9%
Simplified45.9%
Taylor expanded in x around inf 82.2%
Final simplification65.8%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 49.2%
*-commutative49.2%
fma-def49.2%
*-commutative49.2%
Simplified49.2%
Taylor expanded in x around 0 50.8%
Final simplification50.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 2023287
(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))))