
(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 5 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: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (/ x y) (/ y x))))
(if (<= y 4.8e-68)
(+ 1.0 (/ -8.0 t_1))
(if (<= y 3.05e+81)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ (* t_1 0.5) -1.0)))))y = abs(y);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = (x / y) / (y / x);
double tmp;
if (y <= 4.8e-68) {
tmp = 1.0 + (-8.0 / t_1);
} else if (y <= 3.05e+81) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (t_1 * 0.5) + -1.0;
}
return tmp;
}
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 / y) / (y / x)
if (y <= 4.8d-68) then
tmp = 1.0d0 + ((-8.0d0) / t_1)
else if (y <= 3.05d+81) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
else
tmp = (t_1 * 0.5d0) + (-1.0d0)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = (x / y) / (y / x);
double tmp;
if (y <= 4.8e-68) {
tmp = 1.0 + (-8.0 / t_1);
} else if (y <= 3.05e+81) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (t_1 * 0.5) + -1.0;
}
return tmp;
}
y = abs(y) def code(x, y): t_0 = y * (y * 4.0) t_1 = (x / y) / (y / x) tmp = 0 if y <= 4.8e-68: tmp = 1.0 + (-8.0 / t_1) elif y <= 3.05e+81: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = (t_1 * 0.5) + -1.0 return tmp
y = abs(y) 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 (y <= 4.8e-68) tmp = Float64(1.0 + Float64(-8.0 / t_1)); elseif (y <= 3.05e+81) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(Float64(t_1 * 0.5) + -1.0); end return tmp end
y = abs(y) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = (x / y) / (y / x); tmp = 0.0; if (y <= 4.8e-68) tmp = 1.0 + (-8.0 / t_1); elseif (y <= 3.05e+81) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = (t_1 * 0.5) + -1.0; end tmp_2 = tmp; end
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[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 4.8e-68], N[(1.0 + N[(-8.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.05e+81], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{\frac{x}{y}}{\frac{y}{x}}\\
\mathbf{if}\;y \leq 4.8 \cdot 10^{-68}:\\
\;\;\;\;1 + \frac{-8}{t_1}\\
\mathbf{elif}\;y \leq 3.05 \cdot 10^{+81}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot 0.5 + -1\\
\end{array}
\end{array}
if y < 4.79999999999999982e-68Initial program 49.1%
frac-2neg49.1%
div-inv48.4%
*-commutative48.4%
neg-sub048.4%
+-commutative48.4%
associate--r+48.4%
neg-sub048.4%
distribute-lft-neg-in48.4%
*-commutative48.4%
distribute-rgt-neg-in48.4%
metadata-eval48.4%
pow248.4%
pow248.4%
*-commutative48.4%
associate-*l*48.4%
pow248.4%
Applied egg-rr48.4%
unpow248.4%
add-sqr-sqrt48.4%
difference-of-squares48.4%
*-commutative48.4%
sqrt-prod48.4%
unpow248.4%
sqrt-prod20.5%
add-sqr-sqrt29.0%
metadata-eval29.0%
*-commutative29.0%
sqrt-prod29.0%
unpow229.0%
sqrt-prod20.7%
add-sqr-sqrt48.4%
metadata-eval48.4%
Applied egg-rr48.4%
Taylor expanded in y around 0 50.6%
associate-*r/50.6%
associate-/l*50.6%
unpow250.6%
unpow250.6%
times-frac57.3%
unpow257.3%
Simplified57.3%
unpow257.3%
associate-*r/57.3%
associate-/l*57.3%
Applied egg-rr57.3%
if 4.79999999999999982e-68 < y < 3.05000000000000019e81Initial program 87.0%
if 3.05000000000000019e81 < y Initial program 19.2%
Taylor expanded in x around 0 71.2%
unpow271.2%
unpow271.2%
times-frac71.2%
Applied egg-rr71.2%
Taylor expanded in x around 0 79.0%
unpow279.0%
unpow279.0%
times-frac85.5%
unpow285.5%
Simplified85.5%
unpow218.5%
associate-*r/18.5%
associate-/l*18.5%
Applied egg-rr85.5%
Final simplification66.6%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (or (<= y 4.6e-68) (and (not (<= y 0.000162)) (<= y 3.25e+35))) (+ 1.0 (/ -8.0 (/ (/ x y) (/ y x)))) -1.0))
y = abs(y);
double code(double x, double y) {
double tmp;
if ((y <= 4.6e-68) || (!(y <= 0.000162) && (y <= 3.25e+35))) {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
} else {
tmp = -1.0;
}
return tmp;
}
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 ((y <= 4.6d-68) .or. (.not. (y <= 0.000162d0)) .and. (y <= 3.25d+35)) then
tmp = 1.0d0 + ((-8.0d0) / ((x / y) / (y / x)))
else
tmp = -1.0d0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if ((y <= 4.6e-68) || (!(y <= 0.000162) && (y <= 3.25e+35))) {
tmp = 1.0 + (-8.0 / ((x / y) / (y / x)));
} else {
tmp = -1.0;
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if (y <= 4.6e-68) or (not (y <= 0.000162) and (y <= 3.25e+35)): tmp = 1.0 + (-8.0 / ((x / y) / (y / x))) else: tmp = -1.0 return tmp
y = abs(y) function code(x, y) tmp = 0.0 if ((y <= 4.6e-68) || (!(y <= 0.000162) && (y <= 3.25e+35))) tmp = Float64(1.0 + Float64(-8.0 / Float64(Float64(x / y) / Float64(y / x)))); else tmp = -1.0; end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 4.6e-68) || (~((y <= 0.000162)) && (y <= 3.25e+35))) tmp = 1.0 + (-8.0 / ((x / y) / (y / x))); else tmp = -1.0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[Or[LessEqual[y, 4.6e-68], And[N[Not[LessEqual[y, 0.000162]], $MachinePrecision], LessEqual[y, 3.25e+35]]], N[(1.0 + N[(-8.0 / N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{-68} \lor \neg \left(y \leq 0.000162\right) \land y \leq 3.25 \cdot 10^{+35}:\\
\;\;\;\;1 + \frac{-8}{\frac{\frac{x}{y}}{\frac{y}{x}}}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 4.59999999999999994e-68 or 1.62000000000000007e-4 < y < 3.2500000000000002e35Initial program 49.4%
frac-2neg49.4%
div-inv48.8%
*-commutative48.8%
neg-sub048.8%
+-commutative48.8%
associate--r+48.8%
neg-sub048.8%
distribute-lft-neg-in48.8%
*-commutative48.8%
distribute-rgt-neg-in48.8%
metadata-eval48.8%
pow248.8%
pow248.8%
*-commutative48.8%
associate-*l*48.8%
pow248.8%
Applied egg-rr48.8%
unpow248.8%
add-sqr-sqrt48.8%
difference-of-squares48.8%
*-commutative48.8%
sqrt-prod48.8%
unpow248.8%
sqrt-prod21.7%
add-sqr-sqrt29.8%
metadata-eval29.8%
*-commutative29.8%
sqrt-prod29.8%
unpow229.8%
sqrt-prod21.8%
add-sqr-sqrt48.8%
metadata-eval48.8%
Applied egg-rr48.8%
Taylor expanded in y around 0 51.4%
associate-*r/51.4%
associate-/l*51.4%
unpow251.4%
unpow251.4%
times-frac58.0%
unpow258.0%
Simplified58.0%
unpow258.0%
associate-*r/57.9%
associate-/l*58.0%
Applied egg-rr58.0%
if 4.59999999999999994e-68 < y < 1.62000000000000007e-4 or 3.2500000000000002e35 < y Initial program 43.6%
Taylor expanded in x around 0 81.0%
Final simplification65.0%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (/ x y) (/ y x))))
(if (<= y 1.65e-67)
(+ 1.0 (/ -8.0 t_0))
(if (or (<= y 0.000175) (not (<= y 4000.0))) (+ (* t_0 0.5) -1.0) 1.0))))y = abs(y);
double code(double x, double y) {
double t_0 = (x / y) / (y / x);
double tmp;
if (y <= 1.65e-67) {
tmp = 1.0 + (-8.0 / t_0);
} else if ((y <= 0.000175) || !(y <= 4000.0)) {
tmp = (t_0 * 0.5) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
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) :: tmp
t_0 = (x / y) / (y / x)
if (y <= 1.65d-67) then
tmp = 1.0d0 + ((-8.0d0) / t_0)
else if ((y <= 0.000175d0) .or. (.not. (y <= 4000.0d0))) then
tmp = (t_0 * 0.5d0) + (-1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double t_0 = (x / y) / (y / x);
double tmp;
if (y <= 1.65e-67) {
tmp = 1.0 + (-8.0 / t_0);
} else if ((y <= 0.000175) || !(y <= 4000.0)) {
tmp = (t_0 * 0.5) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
y = abs(y) def code(x, y): t_0 = (x / y) / (y / x) tmp = 0 if y <= 1.65e-67: tmp = 1.0 + (-8.0 / t_0) elif (y <= 0.000175) or not (y <= 4000.0): tmp = (t_0 * 0.5) + -1.0 else: tmp = 1.0 return tmp
y = abs(y) function code(x, y) t_0 = Float64(Float64(x / y) / Float64(y / x)) tmp = 0.0 if (y <= 1.65e-67) tmp = Float64(1.0 + Float64(-8.0 / t_0)); elseif ((y <= 0.000175) || !(y <= 4000.0)) tmp = Float64(Float64(t_0 * 0.5) + -1.0); else tmp = 1.0; end return tmp end
y = abs(y) function tmp_2 = code(x, y) t_0 = (x / y) / (y / x); tmp = 0.0; if (y <= 1.65e-67) tmp = 1.0 + (-8.0 / t_0); elseif ((y <= 0.000175) || ~((y <= 4000.0))) tmp = (t_0 * 0.5) + -1.0; else tmp = 1.0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.65e-67], N[(1.0 + N[(-8.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 0.000175], N[Not[LessEqual[y, 4000.0]], $MachinePrecision]], N[(N[(t$95$0 * 0.5), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{\frac{x}{y}}{\frac{y}{x}}\\
\mathbf{if}\;y \leq 1.65 \cdot 10^{-67}:\\
\;\;\;\;1 + \frac{-8}{t_0}\\
\mathbf{elif}\;y \leq 0.000175 \lor \neg \left(y \leq 4000\right):\\
\;\;\;\;t_0 \cdot 0.5 + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < 1.6500000000000001e-67Initial program 49.1%
frac-2neg49.1%
div-inv48.4%
*-commutative48.4%
neg-sub048.4%
+-commutative48.4%
associate--r+48.4%
neg-sub048.4%
distribute-lft-neg-in48.4%
*-commutative48.4%
distribute-rgt-neg-in48.4%
metadata-eval48.4%
pow248.4%
pow248.4%
*-commutative48.4%
associate-*l*48.4%
pow248.4%
Applied egg-rr48.4%
unpow248.4%
add-sqr-sqrt48.4%
difference-of-squares48.4%
*-commutative48.4%
sqrt-prod48.4%
unpow248.4%
sqrt-prod20.5%
add-sqr-sqrt29.0%
metadata-eval29.0%
*-commutative29.0%
sqrt-prod29.0%
unpow229.0%
sqrt-prod20.7%
add-sqr-sqrt48.4%
metadata-eval48.4%
Applied egg-rr48.4%
Taylor expanded in y around 0 50.6%
associate-*r/50.6%
associate-/l*50.6%
unpow250.6%
unpow250.6%
times-frac57.3%
unpow257.3%
Simplified57.3%
unpow257.3%
associate-*r/57.3%
associate-/l*57.3%
Applied egg-rr57.3%
if 1.6500000000000001e-67 < y < 1.74999999999999998e-4 or 4e3 < y Initial program 44.4%
Taylor expanded in x around 0 71.7%
unpow271.7%
unpow271.7%
times-frac71.7%
Applied egg-rr71.7%
Taylor expanded in x around 0 76.9%
unpow276.9%
unpow276.9%
times-frac81.1%
unpow281.1%
Simplified81.1%
unpow222.8%
associate-*r/22.8%
associate-/l*22.8%
Applied egg-rr81.1%
if 1.74999999999999998e-4 < y < 4e3Initial program 50.0%
Taylor expanded in x around inf 100.0%
Final simplification65.2%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.6e-67) 1.0 (if (<= y 8e-5) -1.0 (if (<= y 3.9e+35) 1.0 -1.0))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.6e-67) {
tmp = 1.0;
} else if (y <= 8e-5) {
tmp = -1.0;
} else if (y <= 3.9e+35) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
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 (y <= 1.6d-67) then
tmp = 1.0d0
else if (y <= 8d-5) then
tmp = -1.0d0
else if (y <= 3.9d+35) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.6e-67) {
tmp = 1.0;
} else if (y <= 8e-5) {
tmp = -1.0;
} else if (y <= 3.9e+35) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.6e-67: tmp = 1.0 elif y <= 8e-5: tmp = -1.0 elif y <= 3.9e+35: tmp = 1.0 else: tmp = -1.0 return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.6e-67) tmp = 1.0; elseif (y <= 8e-5) tmp = -1.0; elseif (y <= 3.9e+35) tmp = 1.0; else tmp = -1.0; end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.6e-67) tmp = 1.0; elseif (y <= 8e-5) tmp = -1.0; elseif (y <= 3.9e+35) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.6e-67], 1.0, If[LessEqual[y, 8e-5], -1.0, If[LessEqual[y, 3.9e+35], 1.0, -1.0]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-67}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-5}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 1.60000000000000011e-67 or 8.00000000000000065e-5 < y < 3.8999999999999999e35Initial program 49.4%
Taylor expanded in x around inf 56.7%
if 1.60000000000000011e-67 < y < 8.00000000000000065e-5 or 3.8999999999999999e35 < y Initial program 43.6%
Taylor expanded in x around 0 81.0%
Final simplification64.1%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 -1.0)
y = abs(y);
double code(double x, double y) {
return -1.0;
}
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
y = Math.abs(y);
public static double code(double x, double y) {
return -1.0;
}
y = abs(y) def code(x, y): return -1.0
y = abs(y) function code(x, y) return -1.0 end
y = abs(y) function tmp = code(x, y) tmp = -1.0; end
NOTE: y should be positive before calling this function code[x_, y_] := -1.0
\begin{array}{l}
y = |y|\\
\\
-1
\end{array}
Initial program 47.6%
Taylor expanded in x around 0 55.6%
Final simplification55.6%
(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 2023301
(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))))