
(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 12 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 (hypot (* y 2.0) x)) (t_1 (pow (/ (* y 2.0) t_0) 2.0))) (+ (* 0.0 t_1) (- (log (exp (pow (/ x t_0) 2.0))) t_1))))
double code(double x, double y) {
double t_0 = hypot((y * 2.0), x);
double t_1 = pow(((y * 2.0) / t_0), 2.0);
return (0.0 * t_1) + (log(exp(pow((x / t_0), 2.0))) - t_1);
}
public static double code(double x, double y) {
double t_0 = Math.hypot((y * 2.0), x);
double t_1 = Math.pow(((y * 2.0) / t_0), 2.0);
return (0.0 * t_1) + (Math.log(Math.exp(Math.pow((x / t_0), 2.0))) - t_1);
}
def code(x, y): t_0 = math.hypot((y * 2.0), x) t_1 = math.pow(((y * 2.0) / t_0), 2.0) return (0.0 * t_1) + (math.log(math.exp(math.pow((x / t_0), 2.0))) - t_1)
function code(x, y) t_0 = hypot(Float64(y * 2.0), x) t_1 = Float64(Float64(y * 2.0) / t_0) ^ 2.0 return Float64(Float64(0.0 * t_1) + Float64(log(exp((Float64(x / t_0) ^ 2.0))) - t_1)) end
function tmp = code(x, y) t_0 = hypot((y * 2.0), x); t_1 = ((y * 2.0) / t_0) ^ 2.0; tmp = (0.0 * t_1) + (log(exp(((x / t_0) ^ 2.0))) - t_1); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(y * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(y * 2.0), $MachinePrecision] / t$95$0), $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(0.0 * t$95$1), $MachinePrecision] + N[(N[Log[N[Exp[N[Power[N[(x / t$95$0), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y \cdot 2, x\right)\\
t_1 := {\left(\frac{y \cdot 2}{t\_0}\right)}^{2}\\
0 \cdot t\_1 + \left(\log \left(e^{{\left(\frac{x}{t\_0}\right)}^{2}}\right) - t\_1\right)
\end{array}
\end{array}
Initial program 51.5%
div-sub51.6%
associate-/l*51.9%
fma-neg51.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
pow251.9%
pow251.9%
*-commutative51.9%
associate-*l*51.9%
pow251.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
Applied egg-rr51.9%
Applied egg-rr34.5%
Simplified52.9%
add-log-exp53.0%
associate-*r/45.0%
frac-times39.0%
associate-*r*38.9%
add-sqr-sqrt74.2%
unpow274.2%
unpow274.2%
add-sqr-sqrt74.2%
pow274.2%
Applied egg-rr100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (hypot (* y 2.0) x)) (t_1 (/ t_0 y))) (+ (pow (/ x t_0) 2.0) (/ -1.0 (* 0.25 (* t_1 t_1))))))
double code(double x, double y) {
double t_0 = hypot((y * 2.0), x);
double t_1 = t_0 / y;
return pow((x / t_0), 2.0) + (-1.0 / (0.25 * (t_1 * t_1)));
}
public static double code(double x, double y) {
double t_0 = Math.hypot((y * 2.0), x);
double t_1 = t_0 / y;
return Math.pow((x / t_0), 2.0) + (-1.0 / (0.25 * (t_1 * t_1)));
}
def code(x, y): t_0 = math.hypot((y * 2.0), x) t_1 = t_0 / y return math.pow((x / t_0), 2.0) + (-1.0 / (0.25 * (t_1 * t_1)))
function code(x, y) t_0 = hypot(Float64(y * 2.0), x) t_1 = Float64(t_0 / y) return Float64((Float64(x / t_0) ^ 2.0) + Float64(-1.0 / Float64(0.25 * Float64(t_1 * t_1)))) end
function tmp = code(x, y) t_0 = hypot((y * 2.0), x); t_1 = t_0 / y; tmp = ((x / t_0) ^ 2.0) + (-1.0 / (0.25 * (t_1 * t_1))); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(y * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / y), $MachinePrecision]}, N[(N[Power[N[(x / t$95$0), $MachinePrecision], 2.0], $MachinePrecision] + N[(-1.0 / N[(0.25 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y \cdot 2, x\right)\\
t_1 := \frac{t\_0}{y}\\
{\left(\frac{x}{t\_0}\right)}^{2} + \frac{-1}{0.25 \cdot \left(t\_1 \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 51.5%
div-sub51.6%
associate-/l*51.9%
fma-neg51.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
pow251.9%
pow251.9%
*-commutative51.9%
associate-*l*51.9%
pow251.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
Applied egg-rr51.9%
fma-undefine51.9%
unsub-neg51.9%
Applied egg-rr74.2%
sub-neg74.2%
add-sqr-sqrt74.2%
pow274.2%
sqrt-div74.2%
unpow274.2%
sqrt-prod39.2%
add-sqr-sqrt75.8%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
add-sqr-sqrt100.0%
add-sqr-sqrt100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
sub-neg100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
clear-num100.0%
clear-num100.0%
frac-times100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-commutative100.0%
times-frac100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-commutative100.0%
times-frac100.0%
metadata-eval100.0%
Applied egg-rr100.0%
swap-sqr100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (hypot (* y 2.0) x))) (- (pow (/ x t_0) 2.0) (pow (/ (* y 2.0) t_0) 2.0))))
double code(double x, double y) {
double t_0 = hypot((y * 2.0), x);
return pow((x / t_0), 2.0) - pow(((y * 2.0) / t_0), 2.0);
}
public static double code(double x, double y) {
double t_0 = Math.hypot((y * 2.0), x);
return Math.pow((x / t_0), 2.0) - Math.pow(((y * 2.0) / t_0), 2.0);
}
def code(x, y): t_0 = math.hypot((y * 2.0), x) return math.pow((x / t_0), 2.0) - math.pow(((y * 2.0) / t_0), 2.0)
function code(x, y) t_0 = hypot(Float64(y * 2.0), x) return Float64((Float64(x / t_0) ^ 2.0) - (Float64(Float64(y * 2.0) / t_0) ^ 2.0)) end
function tmp = code(x, y) t_0 = hypot((y * 2.0), x); tmp = ((x / t_0) ^ 2.0) - (((y * 2.0) / t_0) ^ 2.0); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(y * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]}, N[(N[Power[N[(x / t$95$0), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[(N[(y * 2.0), $MachinePrecision] / t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y \cdot 2, x\right)\\
{\left(\frac{x}{t\_0}\right)}^{2} - {\left(\frac{y \cdot 2}{t\_0}\right)}^{2}
\end{array}
\end{array}
Initial program 51.5%
div-sub51.6%
associate-/l*51.9%
fma-neg51.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
pow251.9%
pow251.9%
*-commutative51.9%
associate-*l*51.9%
pow251.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
Applied egg-rr51.9%
fma-undefine51.9%
unsub-neg51.9%
Applied egg-rr74.2%
sub-neg74.2%
add-sqr-sqrt74.2%
pow274.2%
sqrt-div74.2%
unpow274.2%
sqrt-prod39.2%
add-sqr-sqrt75.8%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
add-sqr-sqrt100.0%
add-sqr-sqrt100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
sub-neg100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (hypot (* y 2.0) x))) (- (pow (/ x t_0) 2.0) (pow (* y (/ 2.0 t_0)) 2.0))))
double code(double x, double y) {
double t_0 = hypot((y * 2.0), x);
return pow((x / t_0), 2.0) - pow((y * (2.0 / t_0)), 2.0);
}
public static double code(double x, double y) {
double t_0 = Math.hypot((y * 2.0), x);
return Math.pow((x / t_0), 2.0) - Math.pow((y * (2.0 / t_0)), 2.0);
}
def code(x, y): t_0 = math.hypot((y * 2.0), x) return math.pow((x / t_0), 2.0) - math.pow((y * (2.0 / t_0)), 2.0)
function code(x, y) t_0 = hypot(Float64(y * 2.0), x) return Float64((Float64(x / t_0) ^ 2.0) - (Float64(y * Float64(2.0 / t_0)) ^ 2.0)) end
function tmp = code(x, y) t_0 = hypot((y * 2.0), x); tmp = ((x / t_0) ^ 2.0) - ((y * (2.0 / t_0)) ^ 2.0); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(y * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]}, N[(N[Power[N[(x / t$95$0), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[(y * N[(2.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y \cdot 2, x\right)\\
{\left(\frac{x}{t\_0}\right)}^{2} - {\left(y \cdot \frac{2}{t\_0}\right)}^{2}
\end{array}
\end{array}
Initial program 51.5%
div-sub51.6%
associate-/l*51.9%
fma-neg51.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
pow251.9%
pow251.9%
*-commutative51.9%
associate-*l*51.9%
pow251.9%
+-commutative51.9%
*-commutative51.9%
associate-*l*51.9%
fma-define51.9%
Applied egg-rr51.9%
fma-undefine51.9%
unsub-neg51.9%
Applied egg-rr74.2%
sub-neg74.2%
add-sqr-sqrt74.2%
pow274.2%
sqrt-div74.2%
unpow274.2%
sqrt-prod39.2%
add-sqr-sqrt75.8%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
add-sqr-sqrt100.0%
add-sqr-sqrt100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
sub-neg100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
associate-/l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1
(+
(pow (/ x (hypot (* y 2.0) x)) 2.0)
(- -1.0 (* -0.25 (pow (/ x y) 2.0)))))
(t_2 (/ (- (* x x) t_0) (+ (* x x) t_0))))
(if (<= (* x x) 2e-254)
t_1
(if (<= (* x x) 2e-137)
t_2
(if (<= (* x x) 5e-44)
t_1
(if (<= (* x x) 1e+223) t_2 (+ 1.0 (* -8.0 (* (/ y x) (/ y x))))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = pow((x / hypot((y * 2.0), x)), 2.0) + (-1.0 - (-0.25 * pow((x / y), 2.0)));
double t_2 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if ((x * x) <= 2e-254) {
tmp = t_1;
} else if ((x * x) <= 2e-137) {
tmp = t_2;
} else if ((x * x) <= 5e-44) {
tmp = t_1;
} else if ((x * x) <= 1e+223) {
tmp = t_2;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = Math.pow((x / Math.hypot((y * 2.0), x)), 2.0) + (-1.0 - (-0.25 * Math.pow((x / y), 2.0)));
double t_2 = ((x * x) - t_0) / ((x * x) + t_0);
double tmp;
if ((x * x) <= 2e-254) {
tmp = t_1;
} else if ((x * x) <= 2e-137) {
tmp = t_2;
} else if ((x * x) <= 5e-44) {
tmp = t_1;
} else if ((x * x) <= 1e+223) {
tmp = t_2;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = math.pow((x / math.hypot((y * 2.0), x)), 2.0) + (-1.0 - (-0.25 * math.pow((x / y), 2.0))) t_2 = ((x * x) - t_0) / ((x * x) + t_0) tmp = 0 if (x * x) <= 2e-254: tmp = t_1 elif (x * x) <= 2e-137: tmp = t_2 elif (x * x) <= 5e-44: tmp = t_1 elif (x * x) <= 1e+223: tmp = t_2 else: tmp = 1.0 + (-8.0 * ((y / x) * (y / x))) return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = Float64((Float64(x / hypot(Float64(y * 2.0), x)) ^ 2.0) + Float64(-1.0 - Float64(-0.25 * (Float64(x / y) ^ 2.0)))) t_2 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) tmp = 0.0 if (Float64(x * x) <= 2e-254) tmp = t_1; elseif (Float64(x * x) <= 2e-137) tmp = t_2; elseif (Float64(x * x) <= 5e-44) tmp = t_1; elseif (Float64(x * x) <= 1e+223) tmp = t_2; else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); t_1 = ((x / hypot((y * 2.0), x)) ^ 2.0) + (-1.0 - (-0.25 * ((x / y) ^ 2.0))); t_2 = ((x * x) - t_0) / ((x * x) + t_0); tmp = 0.0; if ((x * x) <= 2e-254) tmp = t_1; elseif ((x * x) <= 2e-137) tmp = t_2; elseif ((x * x) <= 5e-44) tmp = t_1; elseif ((x * x) <= 1e+223) tmp = t_2; else tmp = 1.0 + (-8.0 * ((y / x) * (y / x))); 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[Power[N[(x / N[Sqrt[N[(y * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(-1.0 - N[(-0.25 * N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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], 2e-254], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 2e-137], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 5e-44], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 1e+223], t$95$2, N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := {\left(\frac{x}{\mathsf{hypot}\left(y \cdot 2, x\right)}\right)}^{2} + \left(-1 - -0.25 \cdot {\left(\frac{x}{y}\right)}^{2}\right)\\
t_2 := \frac{x \cdot x - t\_0}{x \cdot x + t\_0}\\
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-254}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-137}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot x \leq 10^{+223}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.9999999999999998e-254 or 1.99999999999999996e-137 < (*.f64 x x) < 5.00000000000000039e-44Initial program 50.9%
div-sub51.0%
associate-/l*50.9%
fma-neg50.9%
+-commutative50.9%
*-commutative50.9%
associate-*l*50.9%
fma-define50.9%
pow250.9%
pow250.9%
*-commutative50.9%
associate-*l*50.9%
pow250.9%
+-commutative50.9%
*-commutative50.9%
associate-*l*50.9%
fma-define50.9%
Applied egg-rr50.9%
fma-undefine50.9%
unsub-neg50.9%
Applied egg-rr87.5%
sub-neg87.5%
add-sqr-sqrt87.5%
pow287.5%
sqrt-div87.5%
unpow287.5%
sqrt-prod48.2%
add-sqr-sqrt87.7%
sqrt-pow1100.0%
metadata-eval100.0%
pow1100.0%
add-sqr-sqrt100.0%
add-sqr-sqrt100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
sub-neg100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 83.0%
unpow283.0%
unpow283.0%
times-frac90.8%
unpow290.8%
Simplified90.8%
if 1.9999999999999998e-254 < (*.f64 x x) < 1.99999999999999996e-137 or 5.00000000000000039e-44 < (*.f64 x x) < 1.00000000000000005e223Initial program 79.7%
if 1.00000000000000005e223 < (*.f64 x x) Initial program 17.6%
Taylor expanded in y around 0 81.0%
unpow281.0%
unpow281.0%
times-frac91.7%
Applied egg-rr91.7%
Final simplification87.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (* (* (/ x y) (/ x y)) 0.5)))
(if (<= (* x x) 2e-254)
(+ (+ (pow (sqrt (+ 1.0 t_2)) 2.0) -1.0) -1.0)
(if (<= (* x x) 2e-137)
t_1
(if (<= (* x x) 5e-44)
(+ t_2 -1.0)
(if (<= (* x x) 1e+223) t_1 (+ 1.0 (* -8.0 (* (/ y x) (/ y x))))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double t_2 = ((x / y) * (x / y)) * 0.5;
double tmp;
if ((x * x) <= 2e-254) {
tmp = (pow(sqrt((1.0 + t_2)), 2.0) + -1.0) + -1.0;
} else if ((x * x) <= 2e-137) {
tmp = t_1;
} else if ((x * x) <= 5e-44) {
tmp = t_2 + -1.0;
} else if ((x * x) <= 1e+223) {
tmp = t_1;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = y * (y * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
t_2 = ((x / y) * (x / y)) * 0.5d0
if ((x * x) <= 2d-254) then
tmp = ((sqrt((1.0d0 + t_2)) ** 2.0d0) + (-1.0d0)) + (-1.0d0)
else if ((x * x) <= 2d-137) then
tmp = t_1
else if ((x * x) <= 5d-44) then
tmp = t_2 + (-1.0d0)
else if ((x * x) <= 1d+223) then
tmp = t_1
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x) * (y / x)))
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 t_2 = ((x / y) * (x / y)) * 0.5;
double tmp;
if ((x * x) <= 2e-254) {
tmp = (Math.pow(Math.sqrt((1.0 + t_2)), 2.0) + -1.0) + -1.0;
} else if ((x * x) <= 2e-137) {
tmp = t_1;
} else if ((x * x) <= 5e-44) {
tmp = t_2 + -1.0;
} else if ((x * x) <= 1e+223) {
tmp = t_1;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) t_2 = ((x / y) * (x / y)) * 0.5 tmp = 0 if (x * x) <= 2e-254: tmp = (math.pow(math.sqrt((1.0 + t_2)), 2.0) + -1.0) + -1.0 elif (x * x) <= 2e-137: tmp = t_1 elif (x * x) <= 5e-44: tmp = t_2 + -1.0 elif (x * x) <= 1e+223: tmp = t_1 else: tmp = 1.0 + (-8.0 * ((y / x) * (y / x))) 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)) t_2 = Float64(Float64(Float64(x / y) * Float64(x / y)) * 0.5) tmp = 0.0 if (Float64(x * x) <= 2e-254) tmp = Float64(Float64((sqrt(Float64(1.0 + t_2)) ^ 2.0) + -1.0) + -1.0); elseif (Float64(x * x) <= 2e-137) tmp = t_1; elseif (Float64(x * x) <= 5e-44) tmp = Float64(t_2 + -1.0); elseif (Float64(x * x) <= 1e+223) tmp = t_1; else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) * Float64(y / x)))); 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); t_2 = ((x / y) * (x / y)) * 0.5; tmp = 0.0; if ((x * x) <= 2e-254) tmp = ((sqrt((1.0 + t_2)) ^ 2.0) + -1.0) + -1.0; elseif ((x * x) <= 2e-137) tmp = t_1; elseif ((x * x) <= 5e-44) tmp = t_2 + -1.0; elseif ((x * x) <= 1e+223) tmp = t_1; else tmp = 1.0 + (-8.0 * ((y / x) * (y / x))); 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]}, Block[{t$95$2 = N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2e-254], N[(N[(N[Power[N[Sqrt[N[(1.0 + t$95$2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + -1.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e-137], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e-44], N[(t$95$2 + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+223], t$95$1, N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\\
t_2 := \left(\frac{x}{y} \cdot \frac{x}{y}\right) \cdot 0.5\\
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-254}:\\
\;\;\;\;\left({\left(\sqrt{1 + t\_2}\right)}^{2} + -1\right) + -1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-137}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-44}:\\
\;\;\;\;t\_2 + -1\\
\mathbf{elif}\;x \cdot x \leq 10^{+223}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.9999999999999998e-254Initial program 51.2%
Taylor expanded in x around 0 81.1%
expm1-log1p-u81.1%
expm1-undefine81.1%
*-commutative81.1%
add-sqr-sqrt81.1%
pow281.1%
sqrt-div81.1%
sqrt-pow181.3%
metadata-eval81.3%
pow181.3%
sqrt-pow190.7%
metadata-eval90.7%
pow190.7%
Applied egg-rr90.7%
add-sqr-sqrt90.7%
pow290.7%
log1p-undefine90.7%
pow290.7%
*-commutative90.7%
add-exp-log90.7%
+-commutative90.7%
*-commutative90.7%
pow290.7%
Applied egg-rr90.7%
pow290.7%
Applied egg-rr90.7%
if 1.9999999999999998e-254 < (*.f64 x x) < 1.99999999999999996e-137 or 5.00000000000000039e-44 < (*.f64 x x) < 1.00000000000000005e223Initial program 79.7%
if 1.99999999999999996e-137 < (*.f64 x x) < 5.00000000000000039e-44Initial program 49.9%
Taylor expanded in x around 0 90.9%
unpow290.9%
unpow290.9%
times-frac90.9%
Applied egg-rr90.9%
if 1.00000000000000005e223 < (*.f64 x x) Initial program 17.6%
Taylor expanded in y around 0 81.0%
unpow281.0%
unpow281.0%
times-frac91.7%
Applied egg-rr91.7%
Final simplification87.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (* (* (/ x y) (/ x y)) 0.5)))
(if (<= (* x x) 2e-254)
(+ (+ (+ 1.0 t_2) -1.0) -1.0)
(if (<= (* x x) 2e-137)
t_1
(if (<= (* x x) 5e-44)
(+ t_2 -1.0)
(if (<= (* x x) 1e+223) t_1 (+ 1.0 (* -8.0 (* (/ y x) (/ y x))))))))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double t_2 = ((x / y) * (x / y)) * 0.5;
double tmp;
if ((x * x) <= 2e-254) {
tmp = ((1.0 + t_2) + -1.0) + -1.0;
} else if ((x * x) <= 2e-137) {
tmp = t_1;
} else if ((x * x) <= 5e-44) {
tmp = t_2 + -1.0;
} else if ((x * x) <= 1e+223) {
tmp = t_1;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = y * (y * 4.0d0)
t_1 = ((x * x) - t_0) / ((x * x) + t_0)
t_2 = ((x / y) * (x / y)) * 0.5d0
if ((x * x) <= 2d-254) then
tmp = ((1.0d0 + t_2) + (-1.0d0)) + (-1.0d0)
else if ((x * x) <= 2d-137) then
tmp = t_1
else if ((x * x) <= 5d-44) then
tmp = t_2 + (-1.0d0)
else if ((x * x) <= 1d+223) then
tmp = t_1
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x) * (y / x)))
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 t_2 = ((x / y) * (x / y)) * 0.5;
double tmp;
if ((x * x) <= 2e-254) {
tmp = ((1.0 + t_2) + -1.0) + -1.0;
} else if ((x * x) <= 2e-137) {
tmp = t_1;
} else if ((x * x) <= 5e-44) {
tmp = t_2 + -1.0;
} else if ((x * x) <= 1e+223) {
tmp = t_1;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) t_1 = ((x * x) - t_0) / ((x * x) + t_0) t_2 = ((x / y) * (x / y)) * 0.5 tmp = 0 if (x * x) <= 2e-254: tmp = ((1.0 + t_2) + -1.0) + -1.0 elif (x * x) <= 2e-137: tmp = t_1 elif (x * x) <= 5e-44: tmp = t_2 + -1.0 elif (x * x) <= 1e+223: tmp = t_1 else: tmp = 1.0 + (-8.0 * ((y / x) * (y / x))) 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)) t_2 = Float64(Float64(Float64(x / y) * Float64(x / y)) * 0.5) tmp = 0.0 if (Float64(x * x) <= 2e-254) tmp = Float64(Float64(Float64(1.0 + t_2) + -1.0) + -1.0); elseif (Float64(x * x) <= 2e-137) tmp = t_1; elseif (Float64(x * x) <= 5e-44) tmp = Float64(t_2 + -1.0); elseif (Float64(x * x) <= 1e+223) tmp = t_1; else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) * Float64(y / x)))); 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); t_2 = ((x / y) * (x / y)) * 0.5; tmp = 0.0; if ((x * x) <= 2e-254) tmp = ((1.0 + t_2) + -1.0) + -1.0; elseif ((x * x) <= 2e-137) tmp = t_1; elseif ((x * x) <= 5e-44) tmp = t_2 + -1.0; elseif ((x * x) <= 1e+223) tmp = t_1; else tmp = 1.0 + (-8.0 * ((y / x) * (y / x))); 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]}, Block[{t$95$2 = N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2e-254], N[(N[(N[(1.0 + t$95$2), $MachinePrecision] + -1.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e-137], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5e-44], N[(t$95$2 + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+223], t$95$1, N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\\
t_2 := \left(\frac{x}{y} \cdot \frac{x}{y}\right) \cdot 0.5\\
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-254}:\\
\;\;\;\;\left(\left(1 + t\_2\right) + -1\right) + -1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-137}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-44}:\\
\;\;\;\;t\_2 + -1\\
\mathbf{elif}\;x \cdot x \leq 10^{+223}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.9999999999999998e-254Initial program 51.2%
Taylor expanded in x around 0 81.1%
unpow281.1%
unpow281.1%
times-frac90.7%
Applied egg-rr90.7%
*-commutative90.7%
pow290.7%
expm1-log1p-u90.7%
expm1-define90.7%
log1p-undefine90.7%
pow290.7%
*-commutative90.7%
add-exp-log90.7%
+-commutative90.7%
*-commutative90.7%
pow290.7%
Applied egg-rr90.7%
pow290.7%
Applied egg-rr90.7%
if 1.9999999999999998e-254 < (*.f64 x x) < 1.99999999999999996e-137 or 5.00000000000000039e-44 < (*.f64 x x) < 1.00000000000000005e223Initial program 79.7%
if 1.99999999999999996e-137 < (*.f64 x x) < 5.00000000000000039e-44Initial program 49.9%
Taylor expanded in x around 0 90.9%
unpow290.9%
unpow290.9%
times-frac90.9%
Applied egg-rr90.9%
if 1.00000000000000005e223 < (*.f64 x x) Initial program 17.6%
Taylor expanded in y around 0 81.0%
unpow281.0%
unpow281.0%
times-frac91.7%
Applied egg-rr91.7%
Final simplification87.4%
(FPCore (x y) :precision binary64 (if (<= x 2.05e-18) (+ (+ (+ 1.0 (* (* (/ x y) (/ x y)) 0.5)) -1.0) -1.0) (+ 1.0 (* -8.0 (* (/ y x) (/ y x))))))
double code(double x, double y) {
double tmp;
if (x <= 2.05e-18) {
tmp = ((1.0 + (((x / y) * (x / y)) * 0.5)) + -1.0) + -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.05d-18) then
tmp = ((1.0d0 + (((x / y) * (x / y)) * 0.5d0)) + (-1.0d0)) + (-1.0d0)
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x) * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.05e-18) {
tmp = ((1.0 + (((x / y) * (x / y)) * 0.5)) + -1.0) + -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.05e-18: tmp = ((1.0 + (((x / y) * (x / y)) * 0.5)) + -1.0) + -1.0 else: tmp = 1.0 + (-8.0 * ((y / x) * (y / x))) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.05e-18) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(x / y) * Float64(x / y)) * 0.5)) + -1.0) + -1.0); else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.05e-18) tmp = ((1.0 + (((x / y) * (x / y)) * 0.5)) + -1.0) + -1.0; else tmp = 1.0 + (-8.0 * ((y / x) * (y / x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.05e-18], N[(N[(N[(1.0 + N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.05 \cdot 10^{-18}:\\
\;\;\;\;\left(\left(1 + \left(\frac{x}{y} \cdot \frac{x}{y}\right) \cdot 0.5\right) + -1\right) + -1\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if x < 2.0499999999999999e-18Initial program 53.6%
Taylor expanded in x around 0 59.3%
unpow259.3%
unpow259.3%
times-frac64.9%
Applied egg-rr64.9%
*-commutative64.9%
pow264.9%
expm1-log1p-u64.9%
expm1-define64.9%
log1p-undefine64.9%
pow264.9%
*-commutative64.9%
add-exp-log64.9%
+-commutative64.9%
*-commutative64.9%
pow264.9%
Applied egg-rr64.9%
pow264.9%
Applied egg-rr64.9%
if 2.0499999999999999e-18 < x Initial program 45.3%
Taylor expanded in y around 0 78.7%
unpow278.7%
unpow278.7%
times-frac86.6%
Applied egg-rr86.6%
Final simplification70.3%
(FPCore (x y) :precision binary64 (if (<= x 7.6e-19) (+ (* (* (/ x y) (/ x y)) 0.5) -1.0) (+ 1.0 (* -8.0 (* (/ y x) (/ y x))))))
double code(double x, double y) {
double tmp;
if (x <= 7.6e-19) {
tmp = (((x / y) * (x / y)) * 0.5) + -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 7.6d-19) then
tmp = (((x / y) * (x / y)) * 0.5d0) + (-1.0d0)
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x) * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 7.6e-19) {
tmp = (((x / y) * (x / y)) * 0.5) + -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 7.6e-19: tmp = (((x / y) * (x / y)) * 0.5) + -1.0 else: tmp = 1.0 + (-8.0 * ((y / x) * (y / x))) return tmp
function code(x, y) tmp = 0.0 if (x <= 7.6e-19) tmp = Float64(Float64(Float64(Float64(x / y) * Float64(x / y)) * 0.5) + -1.0); else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 7.6e-19) tmp = (((x / y) * (x / y)) * 0.5) + -1.0; else tmp = 1.0 + (-8.0 * ((y / x) * (y / x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 7.6e-19], N[(N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.6 \cdot 10^{-19}:\\
\;\;\;\;\left(\frac{x}{y} \cdot \frac{x}{y}\right) \cdot 0.5 + -1\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if x < 7.6e-19Initial program 53.6%
Taylor expanded in x around 0 59.3%
unpow259.3%
unpow259.3%
times-frac64.9%
Applied egg-rr64.9%
if 7.6e-19 < x Initial program 45.3%
Taylor expanded in y around 0 78.7%
unpow278.7%
unpow278.7%
times-frac86.6%
Applied egg-rr86.6%
Final simplification70.3%
(FPCore (x y) :precision binary64 (if (<= x 4e-19) -1.0 (+ 1.0 (* -8.0 (* (/ y x) (/ y x))))))
double code(double x, double y) {
double tmp;
if (x <= 4e-19) {
tmp = -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4d-19) then
tmp = -1.0d0
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x) * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4e-19) {
tmp = -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4e-19: tmp = -1.0 else: tmp = 1.0 + (-8.0 * ((y / x) * (y / x))) return tmp
function code(x, y) tmp = 0.0 if (x <= 4e-19) tmp = -1.0; else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4e-19) tmp = -1.0; else tmp = 1.0 + (-8.0 * ((y / x) * (y / x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4e-19], -1.0, N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-19}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if x < 3.9999999999999999e-19Initial program 53.6%
Taylor expanded in x around 0 63.6%
if 3.9999999999999999e-19 < x Initial program 45.3%
Taylor expanded in y around 0 78.7%
unpow278.7%
unpow278.7%
times-frac86.6%
Applied egg-rr86.6%
(FPCore (x y) :precision binary64 (if (<= x 1e-20) -1.0 1.0))
double code(double x, double y) {
double tmp;
if (x <= 1e-20) {
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 <= 1d-20) 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 <= 1e-20) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e-20: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= 1e-20) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e-20) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e-20], -1.0, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-20}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 9.99999999999999945e-21Initial program 53.6%
Taylor expanded in x around 0 63.6%
if 9.99999999999999945e-21 < x Initial program 45.3%
Taylor expanded in x around inf 86.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 51.5%
Taylor expanded in x around 0 51.5%
(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 2024088
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(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))))