
(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}
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (/ (* (fma y 2.0 x) (/ (fma y -2.0 x) t_0)) t_0)))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return (fma(y, 2.0, x) * (fma(y, -2.0, x) / t_0)) / t_0;
}
x = abs(x) y = abs(y) function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64(Float64(fma(y, 2.0, x) * Float64(fma(y, -2.0, x) / t_0)) / t_0) end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * 2.0 + x), $MachinePrecision] * N[(N[(y * -2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 48.8%
add-sqr-sqrt48.8%
difference-of-squares48.8%
*-commutative48.8%
associate-*r*48.4%
sqrt-prod48.4%
sqrt-unprod23.3%
add-sqr-sqrt34.8%
metadata-eval34.8%
*-commutative34.8%
associate-*r*34.8%
sqrt-prod34.8%
sqrt-unprod23.3%
add-sqr-sqrt48.8%
metadata-eval48.8%
Applied egg-rr48.8%
add-sqr-sqrt48.8%
times-frac50.0%
+-commutative50.0%
fma-def50.0%
add-sqr-sqrt50.0%
hypot-def50.0%
*-commutative50.0%
associate-*r*50.0%
metadata-eval50.0%
swap-sqr50.0%
sqrt-unprod24.2%
add-sqr-sqrt50.0%
Applied egg-rr100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (* (/ (fma y -2.0 x) t_0) (/ (fma y 2.0 x) t_0))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return (fma(y, -2.0, x) / t_0) * (fma(y, 2.0, x) / t_0);
}
x = abs(x) y = abs(y) function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64(Float64(fma(y, -2.0, x) / t_0) * Float64(fma(y, 2.0, x) / t_0)) end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * -2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(y * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, -2, x\right)}{t_0} \cdot \frac{\mathsf{fma}\left(y, 2, x\right)}{t_0}
\end{array}
\end{array}
Initial program 48.8%
add-sqr-sqrt48.8%
difference-of-squares48.8%
*-commutative48.8%
associate-*r*48.4%
sqrt-prod48.4%
sqrt-unprod23.3%
add-sqr-sqrt34.8%
metadata-eval34.8%
*-commutative34.8%
associate-*r*34.8%
sqrt-prod34.8%
sqrt-unprod23.3%
add-sqr-sqrt48.8%
metadata-eval48.8%
Applied egg-rr48.8%
add-sqr-sqrt48.8%
times-frac50.0%
+-commutative50.0%
fma-def50.0%
add-sqr-sqrt50.0%
hypot-def50.0%
*-commutative50.0%
associate-*r*50.0%
metadata-eval50.0%
swap-sqr50.0%
sqrt-unprod24.2%
add-sqr-sqrt50.0%
Applied egg-rr100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (fma y -2.0 (* (* x (/ x y)) 0.75)) (hypot x (* y 2.0))))
(t_1 (* y (* y 4.0)))
(t_2 (/ (- (* x x) t_1) (+ (* x x) t_1))))
(if (<= (* x x) 1e-155)
t_0
(if (<= (* x x) 2e-102)
t_2
(if (<= (* x x) 5e-50)
t_0
(if (<= (* x x) 1e+28)
t_2
(if (<= (* x x) 5e+81)
t_0
(if (<= (* x x) 5e+250)
t_2
(- 1.0 (* (* (/ y x) (/ y x)) 8.0))))))))))x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = fma(y, -2.0, ((x * (x / y)) * 0.75)) / hypot(x, (y * 2.0));
double t_1 = y * (y * 4.0);
double t_2 = ((x * x) - t_1) / ((x * x) + t_1);
double tmp;
if ((x * x) <= 1e-155) {
tmp = t_0;
} else if ((x * x) <= 2e-102) {
tmp = t_2;
} else if ((x * x) <= 5e-50) {
tmp = t_0;
} else if ((x * x) <= 1e+28) {
tmp = t_2;
} else if ((x * x) <= 5e+81) {
tmp = t_0;
} else if ((x * x) <= 5e+250) {
tmp = t_2;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
x = abs(x) y = abs(y) function code(x, y) t_0 = Float64(fma(y, -2.0, Float64(Float64(x * Float64(x / y)) * 0.75)) / hypot(x, Float64(y * 2.0))) t_1 = Float64(y * Float64(y * 4.0)) t_2 = Float64(Float64(Float64(x * x) - t_1) / Float64(Float64(x * x) + t_1)) tmp = 0.0 if (Float64(x * x) <= 1e-155) tmp = t_0; elseif (Float64(x * x) <= 2e-102) tmp = t_2; elseif (Float64(x * x) <= 5e-50) tmp = t_0; elseif (Float64(x * x) <= 1e+28) tmp = t_2; elseif (Float64(x * x) <= 5e+81) tmp = t_0; elseif (Float64(x * x) <= 5e+250) tmp = t_2; else tmp = Float64(1.0 - Float64(Float64(Float64(y / x) * Float64(y / x)) * 8.0)); end return tmp end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(y * -2.0 + N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] * 0.75), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * x), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e-155], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 2e-102], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e-50], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+28], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e+81], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 5e+250], t$95$2, N[(1.0 - N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y, -2, \left(x \cdot \frac{x}{y}\right) \cdot 0.75\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}\\
t_1 := y \cdot \left(y \cdot 4\right)\\
t_2 := \frac{x \cdot x - t_1}{x \cdot x + t_1}\\
\mathbf{if}\;x \cdot x \leq 10^{-155}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-102}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-50}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 10^{+28}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+250}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot 8\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000001e-155 or 1.99999999999999987e-102 < (*.f64 x x) < 4.99999999999999968e-50 or 9.99999999999999958e27 < (*.f64 x x) < 4.9999999999999998e81Initial program 54.6%
add-sqr-sqrt54.6%
difference-of-squares54.6%
*-commutative54.6%
associate-*r*53.7%
sqrt-prod53.7%
sqrt-unprod24.1%
add-sqr-sqrt31.1%
metadata-eval31.1%
*-commutative31.1%
associate-*r*31.1%
sqrt-prod31.1%
sqrt-unprod24.1%
add-sqr-sqrt54.6%
metadata-eval54.6%
Applied egg-rr54.6%
add-sqr-sqrt54.6%
times-frac55.2%
+-commutative55.2%
fma-def55.2%
add-sqr-sqrt55.2%
hypot-def55.2%
*-commutative55.2%
associate-*r*55.1%
metadata-eval55.1%
swap-sqr55.2%
sqrt-unprod24.9%
add-sqr-sqrt55.2%
Applied egg-rr100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 41.1%
associate--l+41.1%
*-commutative41.1%
fma-def41.1%
+-commutative41.1%
distribute-rgt-out41.1%
metadata-eval41.1%
mul0-rgt41.1%
metadata-eval41.1%
associate--l+41.1%
Simplified41.5%
if 1.00000000000000001e-155 < (*.f64 x x) < 1.99999999999999987e-102 or 4.99999999999999968e-50 < (*.f64 x x) < 9.99999999999999958e27 or 4.9999999999999998e81 < (*.f64 x x) < 5.0000000000000002e250Initial program 83.6%
if 5.0000000000000002e250 < (*.f64 x x) Initial program 11.8%
add-sqr-sqrt11.8%
difference-of-squares11.8%
*-commutative11.8%
associate-*r*11.8%
sqrt-prod11.8%
sqrt-unprod6.6%
add-sqr-sqrt11.8%
metadata-eval11.8%
*-commutative11.8%
associate-*r*11.8%
sqrt-prod11.8%
sqrt-unprod6.6%
add-sqr-sqrt11.8%
metadata-eval11.8%
Applied egg-rr11.8%
Taylor expanded in x around -inf 80.3%
associate-+r+80.3%
distribute-rgt-out80.3%
metadata-eval80.3%
mul0-rgt80.3%
+-lft-identity80.3%
mul-1-neg80.3%
unsub-neg80.3%
unpow280.3%
div-sub80.3%
associate-*r/80.3%
unpow280.3%
associate-*r/80.3%
unpow280.3%
Simplified90.2%
Final simplification66.0%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (fma 0.5 (* (/ x y) (/ x y)) -1.0)))
(if (<= (* x x) 1e-155)
t_2
(if (<= (* x x) 2e-102)
t_1
(if (<= (* x x) 5e-50)
t_2
(if (<= (* x x) 1e+28)
t_1
(if (<= (* x x) 5e+81)
t_2
(if (<= (* x x) 5e+250)
t_1
(- 1.0 (* (* (/ y x) (/ y x)) 8.0))))))))))x = abs(x);
y = abs(y);
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 = fma(0.5, ((x / y) * (x / y)), -1.0);
double tmp;
if ((x * x) <= 1e-155) {
tmp = t_2;
} else if ((x * x) <= 2e-102) {
tmp = t_1;
} else if ((x * x) <= 5e-50) {
tmp = t_2;
} else if ((x * x) <= 1e+28) {
tmp = t_1;
} else if ((x * x) <= 5e+81) {
tmp = t_2;
} else if ((x * x) <= 5e+250) {
tmp = t_1;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
x = abs(x) y = abs(y) 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 = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0) tmp = 0.0 if (Float64(x * x) <= 1e-155) tmp = t_2; elseif (Float64(x * x) <= 2e-102) tmp = t_1; elseif (Float64(x * x) <= 5e-50) tmp = t_2; elseif (Float64(x * x) <= 1e+28) tmp = t_1; elseif (Float64(x * x) <= 5e+81) tmp = t_2; elseif (Float64(x * x) <= 5e+250) tmp = t_1; else tmp = Float64(1.0 - Float64(Float64(Float64(y / x) * Float64(y / x)) * 8.0)); end return tmp end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
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[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e-155], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 2e-102], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e-50], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+28], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e+81], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e+250], t$95$1, N[(1.0 - N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\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 := \mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\mathbf{if}\;x \cdot x \leq 10^{-155}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-102}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-50}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+28}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+81}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+250}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot 8\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000001e-155 or 1.99999999999999987e-102 < (*.f64 x x) < 4.99999999999999968e-50 or 9.99999999999999958e27 < (*.f64 x x) < 4.9999999999999998e81Initial program 54.6%
Taylor expanded in x around 0 77.8%
fma-neg77.8%
unpow277.8%
unpow277.8%
times-frac86.4%
metadata-eval86.4%
Simplified86.4%
if 1.00000000000000001e-155 < (*.f64 x x) < 1.99999999999999987e-102 or 4.99999999999999968e-50 < (*.f64 x x) < 9.99999999999999958e27 or 4.9999999999999998e81 < (*.f64 x x) < 5.0000000000000002e250Initial program 83.6%
if 5.0000000000000002e250 < (*.f64 x x) Initial program 11.8%
add-sqr-sqrt11.8%
difference-of-squares11.8%
*-commutative11.8%
associate-*r*11.8%
sqrt-prod11.8%
sqrt-unprod6.6%
add-sqr-sqrt11.8%
metadata-eval11.8%
*-commutative11.8%
associate-*r*11.8%
sqrt-prod11.8%
sqrt-unprod6.6%
add-sqr-sqrt11.8%
metadata-eval11.8%
Applied egg-rr11.8%
Taylor expanded in x around -inf 80.3%
associate-+r+80.3%
distribute-rgt-out80.3%
metadata-eval80.3%
mul0-rgt80.3%
+-lft-identity80.3%
mul-1-neg80.3%
unsub-neg80.3%
unpow280.3%
div-sub80.3%
associate-*r/80.3%
unpow280.3%
associate-*r/80.3%
unpow280.3%
Simplified90.2%
Final simplification86.8%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (/ (* y -2.0) (hypot x (* y 2.0)))))
(if (<= (* x x) 1e-155)
t_2
(if (<= (* x x) 2e-102)
t_1
(if (<= (* x x) 5e-50)
t_2
(if (<= (* x x) 1e+28)
t_1
(if (<= (* x x) 5e+81)
t_2
(if (<= (* x x) 5e+250)
t_1
(- 1.0 (* (* (/ y x) (/ y x)) 8.0))))))))))x = abs(x);
y = abs(y);
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 = (y * -2.0) / hypot(x, (y * 2.0));
double tmp;
if ((x * x) <= 1e-155) {
tmp = t_2;
} else if ((x * x) <= 2e-102) {
tmp = t_1;
} else if ((x * x) <= 5e-50) {
tmp = t_2;
} else if ((x * x) <= 1e+28) {
tmp = t_1;
} else if ((x * x) <= 5e+81) {
tmp = t_2;
} else if ((x * x) <= 5e+250) {
tmp = t_1;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
x = Math.abs(x);
y = Math.abs(y);
public static 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 = (y * -2.0) / Math.hypot(x, (y * 2.0));
double tmp;
if ((x * x) <= 1e-155) {
tmp = t_2;
} else if ((x * x) <= 2e-102) {
tmp = t_1;
} else if ((x * x) <= 5e-50) {
tmp = t_2;
} else if ((x * x) <= 1e+28) {
tmp = t_1;
} else if ((x * x) <= 5e+81) {
tmp = t_2;
} else if ((x * x) <= 5e+250) {
tmp = t_1;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) t_2 = (y * -2.0) / math.hypot(x, (y * 2.0)) tmp = 0 if (x * x) <= 1e-155: tmp = t_2 elif (x * x) <= 2e-102: tmp = t_1 elif (x * x) <= 5e-50: tmp = t_2 elif (x * x) <= 1e+28: tmp = t_1 elif (x * x) <= 5e+81: tmp = t_2 elif (x * x) <= 5e+250: tmp = t_1 else: tmp = 1.0 - (((y / x) * (y / x)) * 8.0) return tmp
x = abs(x) y = abs(y) 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(Float64(y * -2.0) / hypot(x, Float64(y * 2.0))) tmp = 0.0 if (Float64(x * x) <= 1e-155) tmp = t_2; elseif (Float64(x * x) <= 2e-102) tmp = t_1; elseif (Float64(x * x) <= 5e-50) tmp = t_2; elseif (Float64(x * x) <= 1e+28) tmp = t_1; elseif (Float64(x * x) <= 5e+81) tmp = t_2; elseif (Float64(x * x) <= 5e+250) tmp = t_1; else tmp = Float64(1.0 - Float64(Float64(Float64(y / x) * Float64(y / x)) * 8.0)); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = ((x * x) - t_0) / ((x * x) + t_0); t_2 = (y * -2.0) / hypot(x, (y * 2.0)); tmp = 0.0; if ((x * x) <= 1e-155) tmp = t_2; elseif ((x * x) <= 2e-102) tmp = t_1; elseif ((x * x) <= 5e-50) tmp = t_2; elseif ((x * x) <= 1e+28) tmp = t_1; elseif ((x * x) <= 5e+81) tmp = t_2; elseif ((x * x) <= 5e+250) tmp = t_1; else tmp = 1.0 - (((y / x) * (y / x)) * 8.0); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
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[(N[(y * -2.0), $MachinePrecision] / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e-155], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 2e-102], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e-50], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+28], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e+81], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e+250], t$95$1, N[(1.0 - N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\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 := \frac{y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\\
\mathbf{if}\;x \cdot x \leq 10^{-155}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-102}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-50}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+28}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+81}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+250}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot 8\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000001e-155 or 1.99999999999999987e-102 < (*.f64 x x) < 4.99999999999999968e-50 or 9.99999999999999958e27 < (*.f64 x x) < 4.9999999999999998e81Initial program 54.6%
add-sqr-sqrt54.6%
difference-of-squares54.6%
*-commutative54.6%
associate-*r*53.7%
sqrt-prod53.7%
sqrt-unprod24.1%
add-sqr-sqrt31.1%
metadata-eval31.1%
*-commutative31.1%
associate-*r*31.1%
sqrt-prod31.1%
sqrt-unprod24.1%
add-sqr-sqrt54.6%
metadata-eval54.6%
Applied egg-rr54.6%
add-sqr-sqrt54.6%
times-frac55.2%
+-commutative55.2%
fma-def55.2%
add-sqr-sqrt55.2%
hypot-def55.2%
*-commutative55.2%
associate-*r*55.1%
metadata-eval55.1%
swap-sqr55.2%
sqrt-unprod24.9%
add-sqr-sqrt55.2%
Applied egg-rr100.0%
associate-*l/100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 41.3%
*-commutative41.3%
Simplified41.3%
if 1.00000000000000001e-155 < (*.f64 x x) < 1.99999999999999987e-102 or 4.99999999999999968e-50 < (*.f64 x x) < 9.99999999999999958e27 or 4.9999999999999998e81 < (*.f64 x x) < 5.0000000000000002e250Initial program 83.6%
if 5.0000000000000002e250 < (*.f64 x x) Initial program 11.8%
add-sqr-sqrt11.8%
difference-of-squares11.8%
*-commutative11.8%
associate-*r*11.8%
sqrt-prod11.8%
sqrt-unprod6.6%
add-sqr-sqrt11.8%
metadata-eval11.8%
*-commutative11.8%
associate-*r*11.8%
sqrt-prod11.8%
sqrt-unprod6.6%
add-sqr-sqrt11.8%
metadata-eval11.8%
Applied egg-rr11.8%
Taylor expanded in x around -inf 80.3%
associate-+r+80.3%
distribute-rgt-out80.3%
metadata-eval80.3%
mul0-rgt80.3%
+-lft-identity80.3%
mul-1-neg80.3%
unsub-neg80.3%
unpow280.3%
div-sub80.3%
associate-*r/80.3%
unpow280.3%
associate-*r/80.3%
unpow280.3%
Simplified90.2%
Final simplification65.9%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= x 3.1e-78)
-1.0
(if (<= x 4.4e-51)
t_1
(if (<= x 2.8e-24)
-1.0
(if (<= x 2.4e+14)
t_1
(if (<= x 6e+40)
-1.0
(if (<= x 6.8e+126)
t_1
(- 1.0 (* (* (/ y x) (/ y x)) 8.0))))))))))x = abs(x);
y = abs(y);
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 tmp;
if (x <= 3.1e-78) {
tmp = -1.0;
} else if (x <= 4.4e-51) {
tmp = t_1;
} else if (x <= 2.8e-24) {
tmp = -1.0;
} else if (x <= 2.4e+14) {
tmp = t_1;
} else if (x <= 6e+40) {
tmp = -1.0;
} else if (x <= 6.8e+126) {
tmp = t_1;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * (y * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
if (x <= 3.1d-78) then
tmp = -1.0d0
else if (x <= 4.4d-51) then
tmp = t_1
else if (x <= 2.8d-24) then
tmp = -1.0d0
else if (x <= 2.4d+14) then
tmp = t_1
else if (x <= 6d+40) then
tmp = -1.0d0
else if (x <= 6.8d+126) then
tmp = t_1
else
tmp = 1.0d0 - (((y / x) * (y / x)) * 8.0d0)
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static 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 tmp;
if (x <= 3.1e-78) {
tmp = -1.0;
} else if (x <= 4.4e-51) {
tmp = t_1;
} else if (x <= 2.8e-24) {
tmp = -1.0;
} else if (x <= 2.4e+14) {
tmp = t_1;
} else if (x <= 6e+40) {
tmp = -1.0;
} else if (x <= 6.8e+126) {
tmp = t_1;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) tmp = 0 if x <= 3.1e-78: tmp = -1.0 elif x <= 4.4e-51: tmp = t_1 elif x <= 2.8e-24: tmp = -1.0 elif x <= 2.4e+14: tmp = t_1 elif x <= 6e+40: tmp = -1.0 elif x <= 6.8e+126: tmp = t_1 else: tmp = 1.0 - (((y / x) * (y / x)) * 8.0) return tmp
x = abs(x) y = abs(y) 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)) tmp = 0.0 if (x <= 3.1e-78) tmp = -1.0; elseif (x <= 4.4e-51) tmp = t_1; elseif (x <= 2.8e-24) tmp = -1.0; elseif (x <= 2.4e+14) tmp = t_1; elseif (x <= 6e+40) tmp = -1.0; elseif (x <= 6.8e+126) tmp = t_1; else tmp = Float64(1.0 - Float64(Float64(Float64(y / x) * Float64(y / x)) * 8.0)); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = ((x * x) - t_0) / ((x * x) + t_0); tmp = 0.0; if (x <= 3.1e-78) tmp = -1.0; elseif (x <= 4.4e-51) tmp = t_1; elseif (x <= 2.8e-24) tmp = -1.0; elseif (x <= 2.4e+14) tmp = t_1; elseif (x <= 6e+40) tmp = -1.0; elseif (x <= 6.8e+126) tmp = t_1; else tmp = 1.0 - (((y / x) * (y / x)) * 8.0); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
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]}, If[LessEqual[x, 3.1e-78], -1.0, If[LessEqual[x, 4.4e-51], t$95$1, If[LessEqual[x, 2.8e-24], -1.0, If[LessEqual[x, 2.4e+14], t$95$1, If[LessEqual[x, 6e+40], -1.0, If[LessEqual[x, 6.8e+126], t$95$1, N[(1.0 - N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\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}\\
\mathbf{if}\;x \leq 3.1 \cdot 10^{-78}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-51}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-24}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+14}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+40}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+126}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot 8\\
\end{array}
\end{array}
if x < 3.10000000000000018e-78 or 4.4e-51 < x < 2.8000000000000002e-24 or 2.4e14 < x < 6.0000000000000004e40Initial program 47.5%
Taylor expanded in x around 0 65.4%
if 3.10000000000000018e-78 < x < 4.4e-51 or 2.8000000000000002e-24 < x < 2.4e14 or 6.0000000000000004e40 < x < 6.79999999999999979e126Initial program 89.4%
if 6.79999999999999979e126 < x Initial program 13.5%
add-sqr-sqrt13.5%
difference-of-squares13.5%
*-commutative13.5%
associate-*r*13.5%
sqrt-prod13.5%
sqrt-unprod8.1%
add-sqr-sqrt13.5%
metadata-eval13.5%
*-commutative13.5%
associate-*r*13.5%
sqrt-prod13.5%
sqrt-unprod8.1%
add-sqr-sqrt13.5%
metadata-eval13.5%
Applied egg-rr13.5%
Taylor expanded in x around -inf 75.7%
associate-+r+75.7%
distribute-rgt-out75.7%
metadata-eval75.7%
mul0-rgt75.7%
+-lft-identity75.7%
mul-1-neg75.7%
unsub-neg75.7%
unpow275.7%
div-sub75.7%
associate-*r/75.7%
unpow275.7%
associate-*r/75.7%
unpow275.7%
Simplified92.5%
Final simplification72.8%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.92e+56) -1.0 (- 1.0 (* (* (/ y x) (/ y x)) 8.0))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 1.92e+56) {
tmp = -1.0;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.92d+56) then
tmp = -1.0d0
else
tmp = 1.0d0 - (((y / x) * (y / x)) * 8.0d0)
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (x <= 1.92e+56) {
tmp = -1.0;
} else {
tmp = 1.0 - (((y / x) * (y / x)) * 8.0);
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): tmp = 0 if x <= 1.92e+56: tmp = -1.0 else: tmp = 1.0 - (((y / x) * (y / x)) * 8.0) return tmp
x = abs(x) y = abs(y) function code(x, y) tmp = 0.0 if (x <= 1.92e+56) tmp = -1.0; else tmp = Float64(1.0 - Float64(Float64(Float64(y / x) * Float64(y / x)) * 8.0)); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.92e+56) tmp = -1.0; else tmp = 1.0 - (((y / x) * (y / x)) * 8.0); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.92e+56], -1.0, N[(1.0 - N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.92 \cdot 10^{+56}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot 8\\
\end{array}
\end{array}
if x < 1.9199999999999999e56Initial program 51.8%
Taylor expanded in x around 0 63.0%
if 1.9199999999999999e56 < x Initial program 38.6%
add-sqr-sqrt38.6%
difference-of-squares38.6%
*-commutative38.6%
associate-*r*38.6%
sqrt-prod38.6%
sqrt-unprod21.0%
add-sqr-sqrt36.8%
metadata-eval36.8%
*-commutative36.8%
associate-*r*36.8%
sqrt-prod36.8%
sqrt-unprod21.0%
add-sqr-sqrt38.6%
metadata-eval38.6%
Applied egg-rr38.6%
Taylor expanded in x around -inf 77.1%
associate-+r+77.1%
distribute-rgt-out77.1%
metadata-eval77.1%
mul0-rgt77.1%
+-lft-identity77.1%
mul-1-neg77.1%
unsub-neg77.1%
unpow277.1%
div-sub77.1%
associate-*r/77.1%
unpow277.1%
associate-*r/77.1%
unpow277.1%
Simplified88.0%
Final simplification68.6%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1e+55) -1.0 1.0))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 1e+55) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1d+55) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (x <= 1e+55) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): tmp = 0 if x <= 1e+55: tmp = -1.0 else: tmp = 1.0 return tmp
x = abs(x) y = abs(y) function code(x, y) tmp = 0.0 if (x <= 1e+55) tmp = -1.0; else tmp = 1.0; end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e+55) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1e+55], -1.0, 1.0]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+55}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.00000000000000001e55Initial program 51.8%
Taylor expanded in x around 0 63.0%
if 1.00000000000000001e55 < x Initial program 38.6%
Taylor expanded in x around inf 87.0%
Final simplification68.4%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 -1.0)
x = abs(x);
y = abs(y);
double code(double x, double y) {
return -1.0;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
return -1.0;
}
x = abs(x) y = abs(y) def code(x, y): return -1.0
x = abs(x) y = abs(y) function code(x, y) return -1.0 end
x = abs(x) y = abs(y) function tmp = code(x, y) tmp = -1.0; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := -1.0
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
-1
\end{array}
Initial program 48.8%
Taylor expanded in x around 0 52.0%
Final simplification52.0%
(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 2023202
(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))))