
(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}
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= (* x x) 1e-270)
-1.0
(if (<= (* x x) 2e+47)
t_1
(if (<= (* x x) 5e+102)
(fma 0.5 (/ (* x x) (* y y)) -1.0)
(if (<= (* x x) 5e+247) t_1 (fma (* (/ y x) (/ y x)) -8.0 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 tmp;
if ((x * x) <= 1e-270) {
tmp = -1.0;
} else if ((x * x) <= 2e+47) {
tmp = t_1;
} else if ((x * x) <= 5e+102) {
tmp = fma(0.5, ((x * x) / (y * y)), -1.0);
} else if ((x * x) <= 5e+247) {
tmp = t_1;
} else {
tmp = fma(((y / x) * (y / x)), -8.0, 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)) tmp = 0.0 if (Float64(x * x) <= 1e-270) tmp = -1.0; elseif (Float64(x * x) <= 2e+47) tmp = t_1; elseif (Float64(x * x) <= 5e+102) tmp = fma(0.5, Float64(Float64(x * x) / Float64(y * y)), -1.0); elseif (Float64(x * x) <= 5e+247) tmp = t_1; else tmp = fma(Float64(Float64(y / x) * Float64(y / x)), -8.0, 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]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e-270], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 2e+47], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e+102], N[(0.5 * N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+247], t$95$1, N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0 + 1.0), $MachinePrecision]]]]]]]
\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}\\
\mathbf{if}\;x \cdot x \leq 10^{-270}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+47}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot x}{y \cdot y}, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+247}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1e-270Initial program 55.7%
*-commutative55.7%
fma-def55.7%
*-commutative55.7%
Simplified55.7%
Taylor expanded in x around 0 87.8%
if 1e-270 < (*.f64 x x) < 2.0000000000000001e47 or 5e102 < (*.f64 x x) < 5.00000000000000023e247Initial program 78.6%
if 2.0000000000000001e47 < (*.f64 x x) < 5e102Initial program 29.8%
*-commutative29.8%
fma-def30.0%
*-commutative30.0%
Simplified30.0%
Taylor expanded in x around 0 81.6%
fma-neg81.6%
unpow281.6%
unpow281.6%
metadata-eval81.6%
Simplified81.6%
if 5.00000000000000023e247 < (*.f64 x x) Initial program 13.0%
*-commutative13.0%
fma-def13.0%
*-commutative13.0%
Simplified13.0%
Taylor expanded in x around inf 79.9%
associate--l+79.9%
distribute-rgt-out--79.9%
metadata-eval79.9%
*-commutative79.9%
+-commutative79.9%
*-commutative79.9%
fma-def79.9%
unpow279.9%
unpow279.9%
times-frac93.1%
Simplified93.1%
Final simplification85.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= (* x x) 8e-270)
-1.0
(if (<= (* x x) 1.25e+51)
t_1
(if (<= (* x x) 3.9e+102)
(fma 0.5 (/ (* x x) (* y y)) -1.0)
(if (<= (* x x) 3.2e+247) t_1 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 tmp;
if ((x * x) <= 8e-270) {
tmp = -1.0;
} else if ((x * x) <= 1.25e+51) {
tmp = t_1;
} else if ((x * x) <= 3.9e+102) {
tmp = fma(0.5, ((x * x) / (y * y)), -1.0);
} else if ((x * x) <= 3.2e+247) {
tmp = t_1;
} 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)) tmp = 0.0 if (Float64(x * x) <= 8e-270) tmp = -1.0; elseif (Float64(x * x) <= 1.25e+51) tmp = t_1; elseif (Float64(x * x) <= 3.9e+102) tmp = fma(0.5, Float64(Float64(x * x) / Float64(y * y)), -1.0); elseif (Float64(x * x) <= 3.2e+247) tmp = t_1; 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]}, If[LessEqual[N[(x * x), $MachinePrecision], 8e-270], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1.25e+51], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 3.9e+102], N[(0.5 * N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 3.2e+247], t$95$1, 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}\\
\mathbf{if}\;x \cdot x \leq 8 \cdot 10^{-270}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 1.25 \cdot 10^{+51}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 3.9 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot x}{y \cdot y}, -1\right)\\
\mathbf{elif}\;x \cdot x \leq 3.2 \cdot 10^{+247}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 8.0000000000000003e-270Initial program 55.7%
*-commutative55.7%
fma-def55.7%
*-commutative55.7%
Simplified55.7%
Taylor expanded in x around 0 87.8%
if 8.0000000000000003e-270 < (*.f64 x x) < 1.25e51 or 3.8999999999999998e102 < (*.f64 x x) < 3.20000000000000022e247Initial program 78.6%
if 1.25e51 < (*.f64 x x) < 3.8999999999999998e102Initial program 29.8%
*-commutative29.8%
fma-def30.0%
*-commutative30.0%
Simplified30.0%
Taylor expanded in x around 0 81.6%
fma-neg81.6%
unpow281.6%
unpow281.6%
metadata-eval81.6%
Simplified81.6%
if 3.20000000000000022e247 < (*.f64 x x) Initial program 13.0%
*-commutative13.0%
fma-def13.0%
*-commutative13.0%
Simplified13.0%
Taylor expanded in x around inf 92.6%
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))))
(if (<= (* x x) 3.4e-270)
-1.0
(if (<= (* x x) 1.5e+49)
t_1
(if (<= (* x x) 3.5e+102) -1.0 (if (<= (* x x) 6e+247) t_1 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 tmp;
if ((x * x) <= 3.4e-270) {
tmp = -1.0;
} else if ((x * x) <= 1.5e+49) {
tmp = t_1;
} else if ((x * x) <= 3.5e+102) {
tmp = -1.0;
} else if ((x * x) <= 6e+247) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = y * (y * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
if ((x * x) <= 3.4d-270) then
tmp = -1.0d0
else if ((x * x) <= 1.5d+49) then
tmp = t_1
else if ((x * x) <= 3.5d+102) then
tmp = -1.0d0
else if ((x * x) <= 6d+247) then
tmp = t_1
else
tmp = 1.0d0
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) / ((x * x) + t_0);
double tmp;
if ((x * x) <= 3.4e-270) {
tmp = -1.0;
} else if ((x * x) <= 1.5e+49) {
tmp = t_1;
} else if ((x * x) <= 3.5e+102) {
tmp = -1.0;
} else if ((x * x) <= 6e+247) {
tmp = t_1;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) tmp = 0 if (x * x) <= 3.4e-270: tmp = -1.0 elif (x * x) <= 1.5e+49: tmp = t_1 elif (x * x) <= 3.5e+102: tmp = -1.0 elif (x * x) <= 6e+247: tmp = t_1 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)) tmp = 0.0 if (Float64(x * x) <= 3.4e-270) tmp = -1.0; elseif (Float64(x * x) <= 1.5e+49) tmp = t_1; elseif (Float64(x * x) <= 3.5e+102) tmp = -1.0; elseif (Float64(x * x) <= 6e+247) tmp = t_1; else tmp = 1.0; end return tmp end
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 * x) <= 3.4e-270) tmp = -1.0; elseif ((x * x) <= 1.5e+49) tmp = t_1; elseif ((x * x) <= 3.5e+102) tmp = -1.0; elseif ((x * x) <= 6e+247) tmp = t_1; else tmp = 1.0; end tmp_2 = 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]}, If[LessEqual[N[(x * x), $MachinePrecision], 3.4e-270], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1.5e+49], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 3.5e+102], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 6e+247], t$95$1, 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}\\
\mathbf{if}\;x \cdot x \leq 3.4 \cdot 10^{-270}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 1.5 \cdot 10^{+49}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 3.5 \cdot 10^{+102}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 6 \cdot 10^{+247}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 3.4000000000000001e-270 or 1.5000000000000001e49 < (*.f64 x x) < 3.50000000000000011e102Initial program 52.8%
*-commutative52.8%
fma-def52.8%
*-commutative52.8%
Simplified52.8%
Taylor expanded in x around 0 86.9%
if 3.4000000000000001e-270 < (*.f64 x x) < 1.5000000000000001e49 or 3.50000000000000011e102 < (*.f64 x x) < 6e247Initial program 78.6%
if 6e247 < (*.f64 x x) Initial program 13.0%
*-commutative13.0%
fma-def13.0%
*-commutative13.0%
Simplified13.0%
Taylor expanded in x around inf 92.6%
Final simplification85.3%
(FPCore (x y)
:precision binary64
(if (<= (* x x) 5e-64)
-1.0
(if (<= (* x x) 5e+26)
1.0
(if (<= (* x x) 5e+102)
-1.0
(if (<= (* x x) 1.75e+223) 1.0 (if (<= (* x x) 8.5e+247) -1.0 1.0))))))
double code(double x, double y) {
double tmp;
if ((x * x) <= 5e-64) {
tmp = -1.0;
} else if ((x * x) <= 5e+26) {
tmp = 1.0;
} else if ((x * x) <= 5e+102) {
tmp = -1.0;
} else if ((x * x) <= 1.75e+223) {
tmp = 1.0;
} else if ((x * x) <= 8.5e+247) {
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 * x) <= 5d-64) then
tmp = -1.0d0
else if ((x * x) <= 5d+26) then
tmp = 1.0d0
else if ((x * x) <= 5d+102) then
tmp = -1.0d0
else if ((x * x) <= 1.75d+223) then
tmp = 1.0d0
else if ((x * x) <= 8.5d+247) 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 * x) <= 5e-64) {
tmp = -1.0;
} else if ((x * x) <= 5e+26) {
tmp = 1.0;
} else if ((x * x) <= 5e+102) {
tmp = -1.0;
} else if ((x * x) <= 1.75e+223) {
tmp = 1.0;
} else if ((x * x) <= 8.5e+247) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x * x) <= 5e-64: tmp = -1.0 elif (x * x) <= 5e+26: tmp = 1.0 elif (x * x) <= 5e+102: tmp = -1.0 elif (x * x) <= 1.75e+223: tmp = 1.0 elif (x * x) <= 8.5e+247: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(x * x) <= 5e-64) tmp = -1.0; elseif (Float64(x * x) <= 5e+26) tmp = 1.0; elseif (Float64(x * x) <= 5e+102) tmp = -1.0; elseif (Float64(x * x) <= 1.75e+223) tmp = 1.0; elseif (Float64(x * x) <= 8.5e+247) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x * x) <= 5e-64) tmp = -1.0; elseif ((x * x) <= 5e+26) tmp = 1.0; elseif ((x * x) <= 5e+102) tmp = -1.0; elseif ((x * x) <= 1.75e+223) tmp = 1.0; elseif ((x * x) <= 8.5e+247) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-64], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 5e+26], 1.0, If[LessEqual[N[(x * x), $MachinePrecision], 5e+102], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1.75e+223], 1.0, If[LessEqual[N[(x * x), $MachinePrecision], 8.5e+247], -1.0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-64}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+26}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+102}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 1.75 \cdot 10^{+223}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \cdot x \leq 8.5 \cdot 10^{+247}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000000033e-64 or 5.0000000000000001e26 < (*.f64 x x) < 5e102 or 1.75000000000000005e223 < (*.f64 x x) < 8.4999999999999998e247Initial program 63.0%
*-commutative63.0%
fma-def63.0%
*-commutative63.0%
Simplified63.0%
Taylor expanded in x around 0 77.5%
if 5.00000000000000033e-64 < (*.f64 x x) < 5.0000000000000001e26 or 5e102 < (*.f64 x x) < 1.75000000000000005e223 or 8.4999999999999998e247 < (*.f64 x x) Initial program 37.3%
*-commutative37.3%
fma-def37.3%
*-commutative37.3%
Simplified37.3%
Taylor expanded in x around inf 83.6%
Final simplification80.1%
(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 51.9%
*-commutative51.9%
fma-def51.9%
*-commutative51.9%
Simplified51.9%
Taylor expanded in x around 0 51.8%
Final simplification51.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 2023193
(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))))