
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(if (<= (* x x) 0.0)
(+ (fma -0.125 (pow (/ x y) 4.0) (* (pow (/ x y) 2.0) 0.5)) -1.0)
(if (<= (* x x) 1.6e+297)
(fma
x
(/ x (fma (pow y 2.0) 4.0 (pow x 2.0)))
(/ -4.0 (+ 4.0 (/ (pow x 2.0) (pow y 2.0)))))
(+ 1.0 (/ -8.0 (/ (/ x y) (/ y x)))))))
double code(double x, double y) {
double tmp;
if ((x * x) <= 0.0) {
tmp = fma(-0.125, pow((x / y), 4.0), (pow((x / y), 2.0) * 0.5)) + -1.0;
} else if ((x * x) <= 1.6e+297) {
tmp = fma(x, (x / fma(pow(y, 2.0), 4.0, pow(x, 2.0))), (-4.0 / (4.0 + (pow(x, 2.0) / pow(y, 2.0)))));
} else {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = Float64(fma(-0.125, (Float64(x / y) ^ 4.0), Float64((Float64(x / y) ^ 2.0) * 0.5)) + -1.0); elseif (Float64(x * x) <= 1.6e+297) tmp = fma(x, Float64(x / fma((y ^ 2.0), 4.0, (x ^ 2.0))), Float64(-4.0 / Float64(4.0 + Float64((x ^ 2.0) / (y ^ 2.0))))); else tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) / Float64(y / x)))); end return tmp end
code[x_, y_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(N[(-0.125 * N[Power[N[(x / y), $MachinePrecision], 4.0], $MachinePrecision] + N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1.6e+297], N[(x * N[(x / N[(N[Power[y, 2.0], $MachinePrecision] * 4.0 + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-4.0 / N[(4.0 + N[(N[Power[x, 2.0], $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, {\left(\frac{x}{y}\right)}^{2} \cdot 0.5\right) + -1\\
\mathbf{elif}\;x \cdot x \leq 1.6 \cdot 10^{+297}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{\mathsf{fma}\left({y}^{2}, 4, {x}^{2}\right)}, \frac{-4}{4 + \frac{{x}^{2}}{{y}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{\frac{\frac{x}{y}}{\frac{y}{x}}}\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 60.0%
add-cube-cbrt58.8%
*-un-lft-identity58.8%
times-frac58.9%
Applied egg-rr58.9%
expm1-log1p-u33.9%
Applied egg-rr33.9%
Taylor expanded in x around 0 65.5%
associate--l+65.5%
fma-def65.5%
metadata-eval65.5%
pow-sqr65.5%
metadata-eval65.5%
pow-sqr65.5%
times-frac83.6%
unpow283.6%
unpow283.6%
times-frac83.6%
unpow283.6%
unpow283.6%
unpow283.6%
times-frac83.6%
unpow283.6%
pow-sqr83.6%
metadata-eval83.6%
fma-neg83.6%
unpow283.6%
unpow283.6%
times-frac96.0%
unpow296.0%
metadata-eval96.0%
Simplified96.0%
fma-udef96.0%
fma-udef96.0%
associate-+r+96.0%
fma-def96.0%
*-commutative96.0%
Applied egg-rr96.0%
if 0.0 < (*.f64 x x) < 1.59999999999999997e297Initial program 75.7%
div-sub75.7%
sub-neg75.7%
pow275.7%
+-commutative75.7%
*-commutative75.7%
associate-*l*75.7%
fma-def75.7%
pow275.7%
pow275.7%
*-un-lft-identity75.7%
*-commutative75.7%
associate-*l*75.7%
pow275.7%
*-un-lft-identity75.7%
+-commutative75.7%
*-commutative75.7%
associate-*l*75.7%
Applied egg-rr75.7%
unpow275.7%
associate-*r/75.4%
fma-def75.4%
fma-udef75.4%
*-commutative75.4%
fma-def75.4%
associate-/l*75.4%
distribute-neg-frac75.4%
metadata-eval75.4%
fma-udef75.4%
*-commutative75.4%
fma-def75.4%
Simplified75.4%
Taylor expanded in y around 0 99.5%
if 1.59999999999999997e297 < (*.f64 x x) Initial program 4.7%
add-cube-cbrt4.5%
*-un-lft-identity4.5%
times-frac4.5%
Applied egg-rr4.5%
expm1-log1p-u4.5%
Applied egg-rr4.5%
Taylor expanded in y around 0 78.1%
associate-*r/78.1%
associate-/l*78.1%
unpow278.1%
unpow278.1%
times-frac89.8%
unpow289.8%
Simplified89.8%
unpow289.8%
clear-num89.8%
un-div-inv89.8%
Applied egg-rr89.8%
Final simplification96.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (/ x y) (/ y x))))
(if (<= (* x x) 1e-209)
(fma 0.5 t_1 -1.0)
(if (<= (* x x) 1e+284)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ 1.0 (/ -8.0 t_1))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = (x / y) / (y / x);
double tmp;
if ((x * x) <= 1e-209) {
tmp = fma(0.5, t_1, -1.0);
} else if ((x * x) <= 1e+284) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (-8.0 / t_1);
}
return tmp;
}
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64(Float64(x / y) / Float64(y / x)) tmp = 0.0 if (Float64(x * x) <= 1e-209) tmp = fma(0.5, t_1, -1.0); elseif (Float64(x * x) <= 1e+284) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(1.0 + Float64(-8.0 / t_1)); 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 / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e-209], N[(0.5 * t$95$1 + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+284], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 / t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{\frac{x}{y}}{\frac{y}{x}}\\
\mathbf{if}\;x \cdot x \leq 10^{-209}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t_1, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 10^{+284}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{t_1}\\
\end{array}
\end{array}
if (*.f64 x x) < 1e-209Initial program 62.2%
add-cube-cbrt61.0%
*-un-lft-identity61.0%
times-frac61.0%
Applied egg-rr61.0%
expm1-log1p-u37.3%
Applied egg-rr37.3%
Taylor expanded in x around 0 84.1%
fma-neg84.1%
unpow284.1%
unpow284.1%
times-frac93.2%
unpow293.2%
metadata-eval93.2%
Simplified93.2%
unpow210.2%
clear-num10.2%
un-div-inv10.2%
Applied egg-rr93.2%
if 1e-209 < (*.f64 x x) < 1.00000000000000008e284Initial program 77.7%
if 1.00000000000000008e284 < (*.f64 x x) Initial program 8.7%
add-cube-cbrt8.4%
*-un-lft-identity8.4%
times-frac8.4%
Applied egg-rr8.4%
expm1-log1p-u8.4%
Applied egg-rr8.4%
Taylor expanded in y around 0 76.9%
associate-*r/76.9%
associate-/l*76.9%
unpow276.9%
unpow276.9%
times-frac87.8%
unpow287.8%
Simplified87.8%
unpow287.8%
clear-num87.8%
un-div-inv87.8%
Applied egg-rr87.8%
Final simplification85.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= x 7.2e-105)
-1.0
(if (<= x 1.1e+142)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ 1.0 (/ -8.0 (/ (/ x y) (/ y x))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x <= 7.2e-105) {
tmp = -1.0;
} else if (x <= 1.1e+142) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (x <= 7.2d-105) then
tmp = -1.0d0
else if (x <= 1.1d+142) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
else
tmp = 1.0d0 + ((-8.0d0) / ((x / y) / (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x <= 7.2e-105) {
tmp = -1.0;
} else if (x <= 1.1e+142) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if x <= 7.2e-105: tmp = -1.0 elif x <= 1.1e+142: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = 1.0 + (-8.0 / ((x / y) / (y / x))) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (x <= 7.2e-105) tmp = -1.0; elseif (x <= 1.1e+142) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) / Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (x <= 7.2e-105) tmp = -1.0; elseif (x <= 1.1e+142) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = 1.0 + (-8.0 / ((x / y) / (y / x))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 7.2e-105], -1.0, If[LessEqual[x, 1.1e+142], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \leq 7.2 \cdot 10^{-105}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+142}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{-8}{\frac{\frac{x}{y}}{\frac{y}{x}}}\\
\end{array}
\end{array}
if x < 7.19999999999999929e-105Initial program 60.2%
Taylor expanded in x around 0 60.9%
if 7.19999999999999929e-105 < x < 1.09999999999999993e142Initial program 70.6%
if 1.09999999999999993e142 < x Initial program 5.6%
add-cube-cbrt5.4%
*-un-lft-identity5.4%
times-frac5.4%
Applied egg-rr5.4%
expm1-log1p-u5.4%
Applied egg-rr5.4%
Taylor expanded in y around 0 75.1%
associate-*r/75.1%
associate-/l*75.1%
unpow275.1%
unpow275.1%
times-frac84.5%
unpow284.5%
Simplified84.5%
unpow284.5%
clear-num84.5%
un-div-inv84.5%
Applied egg-rr84.5%
Final simplification66.1%
(FPCore (x y) :precision binary64 (if (<= y 2.8e+19) (+ 1.0 (/ -8.0 (/ (/ x y) (/ y x)))) -1.0))
double code(double x, double y) {
double tmp;
if (y <= 2.8e+19) {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
} 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 (y <= 2.8d+19) then
tmp = 1.0d0 + ((-8.0d0) / ((x / y) / (y / x)))
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.8e+19) {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.8e+19: tmp = 1.0 + (-8.0 / ((x / y) / (y / x))) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 2.8e+19) tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) / Float64(y / x)))); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.8e+19) tmp = 1.0 + (-8.0 / ((x / y) / (y / x))); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.8e+19], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+19}:\\
\;\;\;\;1 + \frac{-8}{\frac{\frac{x}{y}}{\frac{y}{x}}}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 2.8e19Initial program 56.8%
add-cube-cbrt55.5%
*-un-lft-identity55.5%
times-frac55.5%
Applied egg-rr55.5%
expm1-log1p-u43.3%
Applied egg-rr43.3%
Taylor expanded in y around 0 53.9%
associate-*r/53.9%
associate-/l*53.9%
unpow253.9%
unpow253.9%
times-frac58.4%
unpow258.4%
Simplified58.4%
unpow258.4%
clear-num58.4%
un-div-inv58.4%
Applied egg-rr58.4%
if 2.8e19 < y Initial program 44.7%
Taylor expanded in x around 0 89.5%
Final simplification64.1%
(FPCore (x y) :precision binary64 (if (<= y 500000.0) 1.0 -1.0))
double code(double x, double y) {
double tmp;
if (y <= 500000.0) {
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 (y <= 500000.0d0) 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 (y <= 500000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 500000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 500000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 500000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 500000.0], 1.0, -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 500000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 5e5Initial program 56.9%
Taylor expanded in x around inf 56.6%
if 5e5 < y Initial program 45.1%
Taylor expanded in x around 0 84.6%
Final simplification62.2%
(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 54.6%
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 2024020
(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))))