
(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
(FPCore (x y)
:precision binary64
(if (<= x 5.8e-112)
(+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))
(if (<= x 5.8e+139)
(/ (- (* x x) (* y (* y 4.0))) (pow (hypot x (* y 2.0)) 2.0))
(+ (* (pow (/ y x) 2.0) -8.0) 1.0))))x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 5.8e-112) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if (x <= 5.8e+139) {
tmp = ((x * x) - (y * (y * 4.0))) / pow(hypot(x, (y * 2.0)), 2.0);
} else {
tmp = (pow((y / x), 2.0) * -8.0) + 1.0;
}
return tmp;
}
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 5.8e-112) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if (x <= 5.8e+139) {
tmp = ((x * x) - (y * (y * 4.0))) / Math.pow(Math.hypot(x, (y * 2.0)), 2.0);
} else {
tmp = (Math.pow((y / x), 2.0) * -8.0) + 1.0;
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 5.8e-112: tmp = -1.0 + (0.5 / ((y / x) * (y / x))) elif x <= 5.8e+139: tmp = ((x * x) - (y * (y * 4.0))) / math.pow(math.hypot(x, (y * 2.0)), 2.0) else: tmp = (math.pow((y / x), 2.0) * -8.0) + 1.0 return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 5.8e-112) tmp = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))); elseif (x <= 5.8e+139) tmp = Float64(Float64(Float64(x * x) - Float64(y * Float64(y * 4.0))) / (hypot(x, Float64(y * 2.0)) ^ 2.0)); else tmp = Float64(Float64((Float64(y / x) ^ 2.0) * -8.0) + 1.0); end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.8e-112) tmp = -1.0 + (0.5 / ((y / x) * (y / x))); elseif (x <= 5.8e+139) tmp = ((x * x) - (y * (y * 4.0))) / (hypot(x, (y * 2.0)) ^ 2.0); else tmp = (((y / x) ^ 2.0) * -8.0) + 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 5.8e-112], N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e+139], N[(N[(N[(x * x), $MachinePrecision] - N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-112}:\\
\;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+139}:\\
\;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, y \cdot 2\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\
\end{array}
\end{array}
if x < 5.79999999999999985e-112Initial program 51.7%
+-commutative51.7%
fma-def51.7%
Applied egg-rr51.7%
Taylor expanded in x around 0 56.4%
sub-neg56.4%
metadata-eval56.4%
+-commutative56.4%
unpow256.4%
associate-*r/56.4%
associate-/l*56.4%
unpow256.4%
times-frac61.7%
unpow261.7%
Simplified61.7%
unpow261.7%
Applied egg-rr61.7%
if 5.79999999999999985e-112 < x < 5.7999999999999998e139Initial program 91.9%
*-commutative91.9%
fma-def91.9%
*-commutative91.9%
Simplified91.9%
fma-udef91.9%
*-commutative91.9%
add-sqr-sqrt91.9%
pow291.9%
add-sqr-sqrt91.9%
hypot-def91.9%
*-commutative91.9%
associate-*r*91.9%
sqrt-prod91.9%
sqrt-unprod37.9%
add-sqr-sqrt91.9%
metadata-eval91.9%
Applied egg-rr91.9%
if 5.7999999999999998e139 < x Initial program 9.4%
*-commutative9.4%
fma-def9.4%
*-commutative9.4%
Simplified9.4%
Taylor expanded in x around inf 71.9%
associate--l+71.9%
distribute-rgt-out--71.9%
metadata-eval71.9%
*-commutative71.9%
+-commutative71.9%
*-commutative71.9%
fma-def71.9%
unpow271.9%
unpow271.9%
times-frac88.8%
Simplified88.8%
fma-udef88.8%
pow288.8%
Applied egg-rr88.8%
Final simplification71.0%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= x 4.1e-112)
(+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))
(if (<= x 9.8e+138)
(/ (- (* x x) t_0) (fma x x t_0))
(+ (* (pow (/ y x) 2.0) -8.0) 1.0)))))x = abs(x);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x <= 4.1e-112) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if (x <= 9.8e+138) {
tmp = ((x * x) - t_0) / fma(x, x, t_0);
} else {
tmp = (pow((y / x), 2.0) * -8.0) + 1.0;
}
return tmp;
}
x = abs(x) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (x <= 4.1e-112) tmp = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))); elseif (x <= 9.8e+138) tmp = Float64(Float64(Float64(x * x) - t_0) / fma(x, x, t_0)); else tmp = Float64(Float64((Float64(y / x) ^ 2.0) * -8.0) + 1.0); end return tmp end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.1e-112], N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.8e+138], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \leq 4.1 \cdot 10^{-112}:\\
\;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{+138}:\\
\;\;\;\;\frac{x \cdot x - t_0}{\mathsf{fma}\left(x, x, t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\
\end{array}
\end{array}
if x < 4.09999999999999996e-112Initial program 51.7%
+-commutative51.7%
fma-def51.7%
Applied egg-rr51.7%
Taylor expanded in x around 0 56.4%
sub-neg56.4%
metadata-eval56.4%
+-commutative56.4%
unpow256.4%
associate-*r/56.4%
associate-/l*56.4%
unpow256.4%
times-frac61.7%
unpow261.7%
Simplified61.7%
unpow261.7%
Applied egg-rr61.7%
if 4.09999999999999996e-112 < x < 9.79999999999999966e138Initial program 91.9%
*-commutative91.9%
fma-def91.9%
*-commutative91.9%
Simplified91.9%
if 9.79999999999999966e138 < x Initial program 9.4%
*-commutative9.4%
fma-def9.4%
*-commutative9.4%
Simplified9.4%
Taylor expanded in x around inf 71.9%
associate--l+71.9%
distribute-rgt-out--71.9%
metadata-eval71.9%
*-commutative71.9%
+-commutative71.9%
*-commutative71.9%
fma-def71.9%
unpow271.9%
unpow271.9%
times-frac88.8%
Simplified88.8%
fma-udef88.8%
pow288.8%
Applied egg-rr88.8%
Final simplification70.9%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= (* x x) 2e-223)
(+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))
(if (<= (* x x) 2e+276)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ (* (pow (/ y x) 2.0) -8.0) 1.0)))))x = abs(x);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 2e-223) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if ((x * x) <= 2e+276) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (pow((y / x), 2.0) * -8.0) + 1.0;
}
return tmp;
}
NOTE: x 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 = y * (y * 4.0d0)
if ((x * x) <= 2d-223) then
tmp = (-1.0d0) + (0.5d0 / ((y / x) * (y / x)))
else if ((x * x) <= 2d+276) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
else
tmp = (((y / x) ** 2.0d0) * (-8.0d0)) + 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 2e-223) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if ((x * x) <= 2e+276) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = (Math.pow((y / x), 2.0) * -8.0) + 1.0;
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if (x * x) <= 2e-223: tmp = -1.0 + (0.5 / ((y / x) * (y / x))) elif (x * x) <= 2e+276: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = (math.pow((y / x), 2.0) * -8.0) + 1.0 return tmp
x = abs(x) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (Float64(x * x) <= 2e-223) tmp = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))); elseif (Float64(x * x) <= 2e+276) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(Float64((Float64(y / x) ^ 2.0) * -8.0) + 1.0); end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if ((x * x) <= 2e-223) tmp = -1.0 + (0.5 / ((y / x) * (y / x))); elseif ((x * x) <= 2e+276) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = (((y / x) ^ 2.0) * -8.0) + 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2e-223], N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+276], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-223}:\\
\;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+276}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\
\end{array}
\end{array}
if (*.f64 x x) < 1.9999999999999999e-223Initial program 59.3%
+-commutative59.3%
fma-def59.3%
Applied egg-rr59.3%
Taylor expanded in x around 0 79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
unpow279.5%
associate-*r/79.5%
associate-/l*79.5%
unpow279.5%
times-frac88.0%
unpow288.0%
Simplified88.0%
unpow288.0%
Applied egg-rr88.0%
if 1.9999999999999999e-223 < (*.f64 x x) < 2.0000000000000001e276Initial program 81.3%
if 2.0000000000000001e276 < (*.f64 x x) Initial program 7.4%
*-commutative7.4%
fma-def7.4%
*-commutative7.4%
Simplified7.4%
Taylor expanded in x around inf 67.7%
associate--l+67.7%
distribute-rgt-out--67.7%
metadata-eval67.7%
*-commutative67.7%
+-commutative67.7%
*-commutative67.7%
fma-def67.7%
unpow267.7%
unpow267.7%
times-frac90.5%
Simplified90.5%
fma-udef90.5%
pow290.5%
Applied egg-rr90.5%
Final simplification86.0%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))))
(if (<= (* x x) 5e-26)
t_0
(if (<= (* x x) 5e-8)
(+ 1.0 (/ (* -8.0 (* y y)) (* x x)))
(if (<= (* x x) 5e+149) t_0 1.0)))))x = abs(x);
double code(double x, double y) {
double t_0 = -1.0 + (0.5 / ((y / x) * (y / x)));
double tmp;
if ((x * x) <= 5e-26) {
tmp = t_0;
} else if ((x * x) <= 5e-8) {
tmp = 1.0 + ((-8.0 * (y * y)) / (x * x));
} else if ((x * x) <= 5e+149) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x 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 = (-1.0d0) + (0.5d0 / ((y / x) * (y / x)))
if ((x * x) <= 5d-26) then
tmp = t_0
else if ((x * x) <= 5d-8) then
tmp = 1.0d0 + (((-8.0d0) * (y * y)) / (x * x))
else if ((x * x) <= 5d+149) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = -1.0 + (0.5 / ((y / x) * (y / x)));
double tmp;
if ((x * x) <= 5e-26) {
tmp = t_0;
} else if ((x * x) <= 5e-8) {
tmp = 1.0 + ((-8.0 * (y * y)) / (x * x));
} else if ((x * x) <= 5e+149) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = -1.0 + (0.5 / ((y / x) * (y / x))) tmp = 0 if (x * x) <= 5e-26: tmp = t_0 elif (x * x) <= 5e-8: tmp = 1.0 + ((-8.0 * (y * y)) / (x * x)) elif (x * x) <= 5e+149: tmp = t_0 else: tmp = 1.0 return tmp
x = abs(x) function code(x, y) t_0 = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))) tmp = 0.0 if (Float64(x * x) <= 5e-26) tmp = t_0; elseif (Float64(x * x) <= 5e-8) tmp = Float64(1.0 + Float64(Float64(-8.0 * Float64(y * y)) / Float64(x * x))); elseif (Float64(x * x) <= 5e+149) tmp = t_0; else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = -1.0 + (0.5 / ((y / x) * (y / x))); tmp = 0.0; if ((x * x) <= 5e-26) tmp = t_0; elseif ((x * x) <= 5e-8) tmp = 1.0 + ((-8.0 * (y * y)) / (x * x)); elseif ((x * x) <= 5e+149) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-26], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 5e-8], N[(1.0 + N[(N[(-8.0 * N[(y * y), $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+149], t$95$0, 1.0]]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := -1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-8}:\\
\;\;\;\;1 + \frac{-8 \cdot \left(y \cdot y\right)}{x \cdot x}\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000000019e-26 or 4.9999999999999998e-8 < (*.f64 x x) < 4.9999999999999999e149Initial program 68.3%
+-commutative68.3%
fma-def68.3%
Applied egg-rr68.3%
Taylor expanded in x around 0 73.0%
sub-neg73.0%
metadata-eval73.0%
+-commutative73.0%
unpow273.0%
associate-*r/73.0%
associate-/l*73.0%
unpow273.0%
times-frac77.7%
unpow277.7%
Simplified77.7%
unpow277.7%
Applied egg-rr77.7%
if 5.00000000000000019e-26 < (*.f64 x x) < 4.9999999999999998e-8Initial program 85.7%
*-commutative85.7%
fma-def85.7%
*-commutative85.7%
Simplified85.7%
fma-udef85.7%
*-commutative85.7%
add-sqr-sqrt85.7%
pow285.7%
add-sqr-sqrt85.7%
hypot-def85.7%
*-commutative85.7%
associate-*r*85.7%
sqrt-prod85.7%
sqrt-unprod28.6%
add-sqr-sqrt85.7%
metadata-eval85.7%
Applied egg-rr85.7%
Taylor expanded in x around inf 86.2%
associate--l+86.2%
*-commutative86.2%
unpow286.2%
unpow286.2%
times-frac86.2%
unpow286.2%
*-commutative86.2%
unpow286.2%
times-frac86.2%
associate-*r/86.2%
unpow286.2%
unpow286.2%
unpow286.2%
associate-*r/86.2%
unpow286.2%
div-sub86.2%
Simplified86.2%
if 4.9999999999999999e149 < (*.f64 x x) Initial program 27.5%
*-commutative27.5%
fma-def27.5%
*-commutative27.5%
Simplified27.5%
Taylor expanded in x around inf 87.0%
Final simplification81.2%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= x 5.2e-112)
(+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))
(if (<= x 2.35e+139)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(+ 1.0 (* (/ 1.0 x) (* -8.0 (* y (/ y x)))))))))x = abs(x);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x <= 5.2e-112) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if (x <= 2.35e+139) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x))));
}
return tmp;
}
NOTE: x 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 = y * (y * 4.0d0)
if (x <= 5.2d-112) then
tmp = (-1.0d0) + (0.5d0 / ((y / x) * (y / x)))
else if (x <= 2.35d+139) then
tmp = ((x * x) - t_0) / ((x * x) + t_0)
else
tmp = 1.0d0 + ((1.0d0 / x) * ((-8.0d0) * (y * (y / x))))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x <= 5.2e-112) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else if (x <= 2.35e+139) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x))));
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if x <= 5.2e-112: tmp = -1.0 + (0.5 / ((y / x) * (y / x))) elif x <= 2.35e+139: tmp = ((x * x) - t_0) / ((x * x) + t_0) else: tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x)))) return tmp
x = abs(x) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (x <= 5.2e-112) tmp = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))); elseif (x <= 2.35e+139) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)); else tmp = Float64(1.0 + Float64(Float64(1.0 / x) * Float64(-8.0 * Float64(y * Float64(y / x))))); end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (x <= 5.2e-112) tmp = -1.0 + (0.5 / ((y / x) * (y / x))); elseif (x <= 2.35e+139) tmp = ((x * x) - t_0) / ((x * x) + t_0); else tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.2e-112], N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.35e+139], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(1.0 / x), $MachinePrecision] * N[(-8.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \leq 5.2 \cdot 10^{-112}:\\
\;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+139}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1}{x} \cdot \left(-8 \cdot \left(y \cdot \frac{y}{x}\right)\right)\\
\end{array}
\end{array}
if x < 5.19999999999999983e-112Initial program 51.7%
+-commutative51.7%
fma-def51.7%
Applied egg-rr51.7%
Taylor expanded in x around 0 56.4%
sub-neg56.4%
metadata-eval56.4%
+-commutative56.4%
unpow256.4%
associate-*r/56.4%
associate-/l*56.4%
unpow256.4%
times-frac61.7%
unpow261.7%
Simplified61.7%
unpow261.7%
Applied egg-rr61.7%
if 5.19999999999999983e-112 < x < 2.35e139Initial program 91.9%
if 2.35e139 < x Initial program 9.4%
*-commutative9.4%
fma-def9.4%
*-commutative9.4%
Simplified9.4%
fma-udef9.4%
*-commutative9.4%
add-sqr-sqrt9.4%
pow29.4%
add-sqr-sqrt9.4%
hypot-def9.4%
*-commutative9.4%
associate-*r*9.4%
sqrt-prod9.4%
sqrt-unprod6.3%
add-sqr-sqrt9.4%
metadata-eval9.4%
Applied egg-rr9.4%
Taylor expanded in x around inf 71.9%
associate--l+71.9%
*-commutative71.9%
unpow271.9%
unpow271.9%
times-frac71.9%
unpow271.9%
*-commutative71.9%
unpow271.9%
times-frac71.9%
associate-*r/71.9%
unpow271.9%
unpow271.9%
unpow271.9%
associate-*r/71.9%
unpow271.9%
div-sub71.9%
Simplified71.9%
clear-num71.9%
inv-pow71.9%
associate-*l*71.9%
Applied egg-rr71.9%
unpow-171.9%
associate-/l*72.3%
associate-*r*72.3%
unpow272.3%
associate-*r/72.3%
associate-/r/72.3%
associate-*r/72.3%
associate-*l/72.3%
unpow272.3%
*-commutative72.3%
associate-*r/88.5%
Simplified88.5%
Final simplification70.9%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))))
(if (<= x 7.9e-13)
t_0
(if (<= x 0.000425)
(+ 1.0 (/ (* -8.0 (* y y)) (* x x)))
(if (<= x 6e+74) t_0 (+ 1.0 (* (/ 1.0 x) (* -8.0 (* y (/ y x))))))))))x = abs(x);
double code(double x, double y) {
double t_0 = -1.0 + (0.5 / ((y / x) * (y / x)));
double tmp;
if (x <= 7.9e-13) {
tmp = t_0;
} else if (x <= 0.000425) {
tmp = 1.0 + ((-8.0 * (y * y)) / (x * x));
} else if (x <= 6e+74) {
tmp = t_0;
} else {
tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x))));
}
return tmp;
}
NOTE: x 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 = (-1.0d0) + (0.5d0 / ((y / x) * (y / x)))
if (x <= 7.9d-13) then
tmp = t_0
else if (x <= 0.000425d0) then
tmp = 1.0d0 + (((-8.0d0) * (y * y)) / (x * x))
else if (x <= 6d+74) then
tmp = t_0
else
tmp = 1.0d0 + ((1.0d0 / x) * ((-8.0d0) * (y * (y / x))))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = -1.0 + (0.5 / ((y / x) * (y / x)));
double tmp;
if (x <= 7.9e-13) {
tmp = t_0;
} else if (x <= 0.000425) {
tmp = 1.0 + ((-8.0 * (y * y)) / (x * x));
} else if (x <= 6e+74) {
tmp = t_0;
} else {
tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x))));
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = -1.0 + (0.5 / ((y / x) * (y / x))) tmp = 0 if x <= 7.9e-13: tmp = t_0 elif x <= 0.000425: tmp = 1.0 + ((-8.0 * (y * y)) / (x * x)) elif x <= 6e+74: tmp = t_0 else: tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x)))) return tmp
x = abs(x) function code(x, y) t_0 = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))) tmp = 0.0 if (x <= 7.9e-13) tmp = t_0; elseif (x <= 0.000425) tmp = Float64(1.0 + Float64(Float64(-8.0 * Float64(y * y)) / Float64(x * x))); elseif (x <= 6e+74) tmp = t_0; else tmp = Float64(1.0 + Float64(Float64(1.0 / x) * Float64(-8.0 * Float64(y * Float64(y / x))))); end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = -1.0 + (0.5 / ((y / x) * (y / x))); tmp = 0.0; if (x <= 7.9e-13) tmp = t_0; elseif (x <= 0.000425) tmp = 1.0 + ((-8.0 * (y * y)) / (x * x)); elseif (x <= 6e+74) tmp = t_0; else tmp = 1.0 + ((1.0 / x) * (-8.0 * (y * (y / x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 7.9e-13], t$95$0, If[LessEqual[x, 0.000425], N[(1.0 + N[(N[(-8.0 * N[(y * y), $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6e+74], t$95$0, N[(1.0 + N[(N[(1.0 / x), $MachinePrecision] * N[(-8.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := -1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{if}\;x \leq 7.9 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.000425:\\
\;\;\;\;1 + \frac{-8 \cdot \left(y \cdot y\right)}{x \cdot x}\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+74}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1}{x} \cdot \left(-8 \cdot \left(y \cdot \frac{y}{x}\right)\right)\\
\end{array}
\end{array}
if x < 7.89999999999999966e-13 or 4.24999999999999976e-4 < x < 6e74Initial program 58.1%
+-commutative58.1%
fma-def58.1%
Applied egg-rr58.1%
Taylor expanded in x around 0 58.3%
sub-neg58.3%
metadata-eval58.3%
+-commutative58.3%
unpow258.3%
associate-*r/58.3%
associate-/l*58.3%
unpow258.3%
times-frac62.7%
unpow262.7%
Simplified62.7%
unpow262.7%
Applied egg-rr62.7%
if 7.89999999999999966e-13 < x < 4.24999999999999976e-4Initial program 100.0%
*-commutative100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
fma-udef100.0%
*-commutative100.0%
add-sqr-sqrt100.0%
pow2100.0%
add-sqr-sqrt100.0%
hypot-def100.0%
*-commutative100.0%
associate-*r*100.0%
sqrt-prod100.0%
sqrt-unprod20.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
associate--l+100.0%
*-commutative100.0%
unpow2100.0%
unpow2100.0%
times-frac100.0%
unpow2100.0%
*-commutative100.0%
unpow2100.0%
times-frac100.0%
associate-*r/100.0%
unpow2100.0%
unpow2100.0%
unpow2100.0%
associate-*r/100.0%
unpow2100.0%
div-sub100.0%
Simplified100.0%
if 6e74 < x Initial program 29.3%
*-commutative29.3%
fma-def29.3%
*-commutative29.3%
Simplified29.3%
fma-udef29.3%
*-commutative29.3%
add-sqr-sqrt29.3%
pow229.3%
add-sqr-sqrt29.3%
hypot-def29.3%
*-commutative29.3%
associate-*r*29.3%
sqrt-prod29.3%
sqrt-unprod19.5%
add-sqr-sqrt29.3%
metadata-eval29.3%
Applied egg-rr29.3%
Taylor expanded in x around inf 73.7%
associate--l+73.7%
*-commutative73.7%
unpow273.7%
unpow273.7%
times-frac73.7%
unpow273.7%
*-commutative73.7%
unpow273.7%
times-frac73.7%
associate-*r/73.7%
unpow273.7%
unpow273.7%
unpow273.7%
associate-*r/73.7%
unpow273.7%
div-sub73.7%
Simplified73.7%
clear-num73.7%
inv-pow73.7%
associate-*l*73.7%
Applied egg-rr73.7%
unpow-173.7%
associate-/l*74.0%
associate-*r*74.0%
unpow274.0%
associate-*r/74.0%
associate-/r/74.0%
associate-*r/74.0%
associate-*l/74.0%
unpow274.0%
*-commutative74.0%
associate-*r/86.7%
Simplified86.7%
Final simplification67.2%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (or (<= x 1.55e-12) (and (not (<= x 0.00026)) (<= x 6.9e+74))) (+ -1.0 (/ 0.5 (* (/ y x) (/ y x)))) 1.0))
x = abs(x);
double code(double x, double y) {
double tmp;
if ((x <= 1.55e-12) || (!(x <= 0.00026) && (x <= 6.9e+74))) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x 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.55d-12) .or. (.not. (x <= 0.00026d0)) .and. (x <= 6.9d+74)) then
tmp = (-1.0d0) + (0.5d0 / ((y / x) * (y / x)))
else
tmp = 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if ((x <= 1.55e-12) || (!(x <= 0.00026) && (x <= 6.9e+74))) {
tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if (x <= 1.55e-12) or (not (x <= 0.00026) and (x <= 6.9e+74)): tmp = -1.0 + (0.5 / ((y / x) * (y / x))) else: tmp = 1.0 return tmp
x = abs(x) function code(x, y) tmp = 0.0 if ((x <= 1.55e-12) || (!(x <= 0.00026) && (x <= 6.9e+74))) tmp = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x)))); else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 1.55e-12) || (~((x <= 0.00026)) && (x <= 6.9e+74))) tmp = -1.0 + (0.5 / ((y / x) * (y / x))); else tmp = 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[Or[LessEqual[x, 1.55e-12], And[N[Not[LessEqual[x, 0.00026]], $MachinePrecision], LessEqual[x, 6.9e+74]]], N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55 \cdot 10^{-12} \lor \neg \left(x \leq 0.00026\right) \land x \leq 6.9 \cdot 10^{+74}:\\
\;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.5500000000000001e-12 or 2.59999999999999977e-4 < x < 6.8999999999999996e74Initial program 58.1%
+-commutative58.1%
fma-def58.1%
Applied egg-rr58.1%
Taylor expanded in x around 0 58.3%
sub-neg58.3%
metadata-eval58.3%
+-commutative58.3%
unpow258.3%
associate-*r/58.3%
associate-/l*58.3%
unpow258.3%
times-frac62.7%
unpow262.7%
Simplified62.7%
unpow262.7%
Applied egg-rr62.7%
if 1.5500000000000001e-12 < x < 2.59999999999999977e-4 or 6.8999999999999996e74 < x Initial program 37.0%
*-commutative37.0%
fma-def37.0%
*-commutative37.0%
Simplified37.0%
Taylor expanded in x around inf 87.6%
Final simplification67.1%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 2.6e-12) -1.0 (if (<= x 0.002) 1.0 (if (<= x 4.8e+56) -1.0 1.0))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 2.6e-12) {
tmp = -1.0;
} else if (x <= 0.002) {
tmp = 1.0;
} else if (x <= 4.8e+56) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x 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 <= 2.6d-12) then
tmp = -1.0d0
else if (x <= 0.002d0) then
tmp = 1.0d0
else if (x <= 4.8d+56) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 2.6e-12) {
tmp = -1.0;
} else if (x <= 0.002) {
tmp = 1.0;
} else if (x <= 4.8e+56) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 2.6e-12: tmp = -1.0 elif x <= 0.002: tmp = 1.0 elif x <= 4.8e+56: tmp = -1.0 else: tmp = 1.0 return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 2.6e-12) tmp = -1.0; elseif (x <= 0.002) tmp = 1.0; elseif (x <= 4.8e+56) tmp = -1.0; else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.6e-12) tmp = -1.0; elseif (x <= 0.002) tmp = 1.0; elseif (x <= 4.8e+56) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 2.6e-12], -1.0, If[LessEqual[x, 0.002], 1.0, If[LessEqual[x, 4.8e+56], -1.0, 1.0]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6 \cdot 10^{-12}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 0.002:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+56}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.59999999999999983e-12 or 2e-3 < x < 4.80000000000000027e56Initial program 57.7%
*-commutative57.7%
fma-def57.7%
*-commutative57.7%
Simplified57.7%
Taylor expanded in x around 0 61.6%
if 2.59999999999999983e-12 < x < 2e-3 or 4.80000000000000027e56 < x Initial program 39.6%
*-commutative39.6%
fma-def39.6%
*-commutative39.6%
Simplified39.6%
Taylor expanded in x around inf 88.1%
Final simplification66.6%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 -1.0)
x = abs(x);
double code(double x, double y) {
return -1.0;
}
NOTE: x 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);
public static double code(double x, double y) {
return -1.0;
}
x = abs(x) def code(x, y): return -1.0
x = abs(x) function code(x, y) return -1.0 end
x = abs(x) function tmp = code(x, y) tmp = -1.0; end
NOTE: x should be positive before calling this function code[x_, y_] := -1.0
\begin{array}{l}
x = |x|\\
\\
-1
\end{array}
Initial program 54.3%
*-commutative54.3%
fma-def54.3%
*-commutative54.3%
Simplified54.3%
Taylor expanded in x around 0 52.1%
Final simplification52.1%
(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 2023252
(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))))