
(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}
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (/ (fma y 2.0 x) (/ t_0 (/ (+ x (* y -2.0)) t_0)))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return fma(y, 2.0, x) / (t_0 / ((x + (y * -2.0)) / t_0));
}
x = abs(x) y = abs(y) function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64(fma(y, 2.0, x) / Float64(t_0 / Float64(Float64(x + Float64(y * -2.0)) / t_0))) end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(y * 2.0 + x), $MachinePrecision] / N[(t$95$0 / N[(N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{\frac{t_0}{\frac{x + y \cdot -2}{t_0}}}
\end{array}
\end{array}
Initial program 52.9%
add-sqr-sqrt52.9%
difference-of-squares52.9%
*-commutative52.9%
associate-*r*52.7%
*-commutative52.7%
sqrt-prod52.7%
sqrt-prod27.0%
add-sqr-sqrt39.1%
metadata-eval39.1%
*-commutative39.1%
associate-*r*39.0%
*-commutative39.0%
sqrt-prod39.0%
sqrt-prod27.0%
add-sqr-sqrt52.9%
metadata-eval52.9%
Applied egg-rr52.9%
add-sqr-sqrt52.9%
times-frac54.2%
+-commutative54.2%
fma-def54.2%
add-sqr-sqrt54.2%
hypot-def54.2%
sqrt-prod27.7%
*-commutative27.7%
sqrt-prod27.7%
metadata-eval27.7%
associate-*r*27.7%
add-sqr-sqrt54.2%
*-commutative54.2%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.9%
frac-times100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num99.9%
un-div-inv99.9%
sub-neg99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (* (/ (fma y 2.0 x) t_0) (/ (- x (* y 2.0)) t_0))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return (fma(y, 2.0, x) / t_0) * ((x - (y * 2.0)) / t_0);
}
x = abs(x) y = abs(y) function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64(Float64(fma(y, 2.0, x) / t_0) * Float64(Float64(x - Float64(y * 2.0)) / t_0)) end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \frac{x - y \cdot 2}{t_0}
\end{array}
\end{array}
Initial program 52.9%
add-sqr-sqrt52.9%
difference-of-squares52.9%
*-commutative52.9%
associate-*r*52.7%
*-commutative52.7%
sqrt-prod52.7%
sqrt-prod27.0%
add-sqr-sqrt39.1%
metadata-eval39.1%
*-commutative39.1%
associate-*r*39.0%
*-commutative39.0%
sqrt-prod39.0%
sqrt-prod27.0%
add-sqr-sqrt52.9%
metadata-eval52.9%
Applied egg-rr52.9%
add-sqr-sqrt52.9%
times-frac54.2%
+-commutative54.2%
fma-def54.2%
add-sqr-sqrt54.2%
hypot-def54.2%
sqrt-prod27.7%
*-commutative27.7%
sqrt-prod27.7%
metadata-eval27.7%
associate-*r*27.7%
add-sqr-sqrt54.2%
*-commutative54.2%
Applied egg-rr99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (/ (fma y 2.0 x) (* t_0 (/ t_0 (- x (* y 2.0)))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return fma(y, 2.0, x) / (t_0 * (t_0 / (x - (y * 2.0))));
}
x = abs(x) y = abs(y) function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64(fma(y, 2.0, x) / Float64(t_0 * Float64(t_0 / Float64(x - Float64(y * 2.0))))) end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(y * 2.0 + x), $MachinePrecision] / N[(t$95$0 * N[(t$95$0 / N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0 \cdot \frac{t_0}{x - y \cdot 2}}
\end{array}
\end{array}
Initial program 52.9%
add-sqr-sqrt52.9%
difference-of-squares52.9%
*-commutative52.9%
associate-*r*52.7%
*-commutative52.7%
sqrt-prod52.7%
sqrt-prod27.0%
add-sqr-sqrt39.1%
metadata-eval39.1%
*-commutative39.1%
associate-*r*39.0%
*-commutative39.0%
sqrt-prod39.0%
sqrt-prod27.0%
add-sqr-sqrt52.9%
metadata-eval52.9%
Applied egg-rr52.9%
add-sqr-sqrt52.9%
times-frac54.2%
+-commutative54.2%
fma-def54.2%
add-sqr-sqrt54.2%
hypot-def54.2%
sqrt-prod27.7%
*-commutative27.7%
sqrt-prod27.7%
metadata-eval27.7%
associate-*r*27.7%
add-sqr-sqrt54.2%
*-commutative54.2%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.9%
frac-times100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 1e-218)
(+ 1.0 (* (+ (exp (log1p (pow (/ y x) 2.0))) -1.0) -8.0))
(if (<= t_0 5e+110)
(/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ t_0 (* x x)))
(fma 0.5 (* (/ x y) (/ x y)) -1.0)))))x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 1e-218) {
tmp = 1.0 + ((exp(log1p(pow((y / x), 2.0))) + -1.0) * -8.0);
} else if (t_0 <= 5e+110) {
tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
}
return tmp;
}
x = abs(x) y = abs(y) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 1e-218) tmp = Float64(1.0 + Float64(Float64(exp(log1p((Float64(y / x) ^ 2.0))) + -1.0) * -8.0)); elseif (t_0 <= 5e+110) tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); end return tmp end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-218], N[(1.0 + N[(N[(N[Exp[N[Log[1 + N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+110], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 10^{-218}:\\
\;\;\;\;1 + \left(e^{\mathsf{log1p}\left({\left(\frac{y}{x}\right)}^{2}\right)} + -1\right) \cdot -8\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+110}:\\
\;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{t_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 1e-218Initial program 55.3%
Taylor expanded in x around inf 76.8%
associate--l+76.8%
distribute-rgt-out--76.8%
metadata-eval76.8%
*-commutative76.8%
+-commutative76.8%
*-commutative76.8%
fma-def76.8%
unpow276.8%
unpow276.8%
times-frac84.3%
Simplified84.3%
fma-udef84.3%
pow284.3%
Applied egg-rr84.3%
expm1-log1p-u84.3%
expm1-udef84.3%
Applied egg-rr84.3%
if 1e-218 < (*.f64 (*.f64 y 4) y) < 4.99999999999999978e110Initial program 85.7%
add-sqr-sqrt85.7%
difference-of-squares85.7%
*-commutative85.7%
associate-*r*85.7%
*-commutative85.7%
sqrt-prod85.7%
sqrt-prod49.0%
add-sqr-sqrt63.8%
metadata-eval63.8%
*-commutative63.8%
associate-*r*63.8%
*-commutative63.8%
sqrt-prod63.8%
sqrt-prod49.0%
add-sqr-sqrt85.7%
metadata-eval85.7%
Applied egg-rr85.7%
if 4.99999999999999978e110 < (*.f64 (*.f64 y 4) y) Initial program 30.0%
Taylor expanded in x around 0 74.2%
fma-neg74.2%
unpow274.2%
unpow274.2%
metadata-eval74.2%
Simplified74.2%
times-frac84.5%
Applied egg-rr84.5%
Final simplification84.7%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 1e-218)
(+ 1.0 (* (pow (/ y x) 2.0) -8.0))
(if (<= t_0 5e+110)
(/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ t_0 (* x x)))
(fma 0.5 (* (/ x y) (/ x y)) -1.0)))))x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 1e-218) {
tmp = 1.0 + (pow((y / x), 2.0) * -8.0);
} else if (t_0 <= 5e+110) {
tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
}
return tmp;
}
x = abs(x) y = abs(y) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 1e-218) tmp = Float64(1.0 + Float64((Float64(y / x) ^ 2.0) * -8.0)); elseif (t_0 <= 5e+110) tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0); end return tmp end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-218], N[(1.0 + N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+110], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 10^{-218}:\\
\;\;\;\;1 + {\left(\frac{y}{x}\right)}^{2} \cdot -8\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+110}:\\
\;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{t_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 1e-218Initial program 55.3%
Taylor expanded in x around inf 76.8%
associate--l+76.8%
distribute-rgt-out--76.8%
metadata-eval76.8%
*-commutative76.8%
+-commutative76.8%
*-commutative76.8%
fma-def76.8%
unpow276.8%
unpow276.8%
times-frac84.3%
Simplified84.3%
fma-udef84.3%
pow284.3%
Applied egg-rr84.3%
if 1e-218 < (*.f64 (*.f64 y 4) y) < 4.99999999999999978e110Initial program 85.7%
add-sqr-sqrt85.7%
difference-of-squares85.7%
*-commutative85.7%
associate-*r*85.7%
*-commutative85.7%
sqrt-prod85.7%
sqrt-prod49.0%
add-sqr-sqrt63.8%
metadata-eval63.8%
*-commutative63.8%
associate-*r*63.8%
*-commutative63.8%
sqrt-prod63.8%
sqrt-prod49.0%
add-sqr-sqrt85.7%
metadata-eval85.7%
Applied egg-rr85.7%
if 4.99999999999999978e110 < (*.f64 (*.f64 y 4) y) Initial program 30.0%
Taylor expanded in x around 0 74.2%
fma-neg74.2%
unpow274.2%
unpow274.2%
metadata-eval74.2%
Simplified74.2%
times-frac84.5%
Applied egg-rr84.5%
Final simplification84.7%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 1e-218)
(+ 1.0 (* (pow (/ y x) 2.0) -8.0))
(if (<= t_0 5e+208)
(/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ t_0 (* x x)))
(+ -1.0 (* 0.25 (/ x (* y (/ y x)))))))))x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 1e-218) {
tmp = 1.0 + (pow((y / x), 2.0) * -8.0);
} else if (t_0 <= 5e+208) {
tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (t_0 <= 1d-218) then
tmp = 1.0d0 + (((y / x) ** 2.0d0) * (-8.0d0))
else if (t_0 <= 5d+208) then
tmp = ((x - (y * 2.0d0)) * (x + (y * 2.0d0))) / (t_0 + (x * x))
else
tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 1e-218) {
tmp = 1.0 + (Math.pow((y / x), 2.0) * -8.0);
} else if (t_0 <= 5e+208) {
tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 1e-218: tmp = 1.0 + (math.pow((y / x), 2.0) * -8.0) elif t_0 <= 5e+208: tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x)) else: tmp = -1.0 + (0.25 * (x / (y * (y / x)))) return tmp
x = abs(x) y = abs(y) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 1e-218) tmp = Float64(1.0 + Float64((Float64(y / x) ^ 2.0) * -8.0)); elseif (t_0 <= 5e+208) tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x))))); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 1e-218) tmp = 1.0 + (((y / x) ^ 2.0) * -8.0); elseif (t_0 <= 5e+208) tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x)); else tmp = -1.0 + (0.25 * (x / (y * (y / x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-218], N[(1.0 + N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+208], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 10^{-218}:\\
\;\;\;\;1 + {\left(\frac{y}{x}\right)}^{2} \cdot -8\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+208}:\\
\;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{t_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 1e-218Initial program 55.3%
Taylor expanded in x around inf 76.8%
associate--l+76.8%
distribute-rgt-out--76.8%
metadata-eval76.8%
*-commutative76.8%
+-commutative76.8%
*-commutative76.8%
fma-def76.8%
unpow276.8%
unpow276.8%
times-frac84.3%
Simplified84.3%
fma-udef84.3%
pow284.3%
Applied egg-rr84.3%
if 1e-218 < (*.f64 (*.f64 y 4) y) < 5.0000000000000004e208Initial program 82.0%
add-sqr-sqrt82.0%
difference-of-squares82.0%
*-commutative82.0%
associate-*r*82.0%
*-commutative82.0%
sqrt-prod82.0%
sqrt-prod44.7%
add-sqr-sqrt56.8%
metadata-eval56.8%
*-commutative56.8%
associate-*r*56.8%
*-commutative56.8%
sqrt-prod56.8%
sqrt-prod44.7%
add-sqr-sqrt82.0%
metadata-eval82.0%
Applied egg-rr82.0%
if 5.0000000000000004e208 < (*.f64 (*.f64 y 4) y) Initial program 23.5%
Taylor expanded in x around 0 23.6%
unpow223.6%
Simplified23.6%
div-sub23.6%
*-un-lft-identity23.6%
times-frac23.6%
metadata-eval23.6%
times-frac23.6%
pow223.6%
associate-*r*23.6%
*-commutative23.6%
*-inverses87.0%
Applied egg-rr87.0%
unpow287.0%
clear-num87.0%
frac-times87.0%
*-un-lft-identity87.0%
Applied egg-rr87.0%
Final simplification84.5%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 7.2e-110)
(+ 1.0 (* -8.0 (/ y (* x (/ x y)))))
(if (<= y 1.25e+104)
(/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ (* y (* y 4.0)) (* x x)))
(+ -1.0 (* 0.25 (/ x (* y (/ y x))))))))x = abs(x);
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 7.2e-110) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else if (y <= 1.25e+104) {
tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7.2d-110) then
tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
else if (y <= 1.25d+104) then
tmp = ((x - (y * 2.0d0)) * (x + (y * 2.0d0))) / ((y * (y * 4.0d0)) + (x * x))
else
tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 7.2e-110) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else if (y <= 1.25e+104) {
tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): tmp = 0 if y <= 7.2e-110: tmp = 1.0 + (-8.0 * (y / (x * (x / y)))) elif y <= 1.25e+104: tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x)) else: tmp = -1.0 + (0.25 * (x / (y * (y / x)))) return tmp
x = abs(x) y = abs(y) function code(x, y) tmp = 0.0 if (y <= 7.2e-110) tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y))))); elseif (y <= 1.25e+104) tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(Float64(y * Float64(y * 4.0)) + Float64(x * x))); else tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x))))); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.2e-110) tmp = 1.0 + (-8.0 * (y / (x * (x / y)))); elseif (y <= 1.25e+104) tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x)); else tmp = -1.0 + (0.25 * (x / (y * (y / x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 7.2e-110], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e+104], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{-110}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+104}:\\
\;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 7.1999999999999999e-110Initial program 53.1%
Taylor expanded in x around inf 50.9%
associate--l+50.9%
distribute-rgt-out--50.9%
metadata-eval50.9%
*-commutative50.9%
+-commutative50.9%
*-commutative50.9%
fma-def50.9%
unpow250.9%
unpow250.9%
times-frac58.4%
Simplified58.4%
fma-udef58.4%
pow258.4%
Applied egg-rr58.4%
unpow258.4%
clear-num58.4%
frac-times58.4%
*-un-lft-identity58.4%
Applied egg-rr58.4%
if 7.1999999999999999e-110 < y < 1.2499999999999999e104Initial program 81.3%
add-sqr-sqrt81.3%
difference-of-squares81.3%
*-commutative81.3%
associate-*r*81.3%
*-commutative81.3%
sqrt-prod81.3%
sqrt-prod81.1%
add-sqr-sqrt81.3%
metadata-eval81.3%
*-commutative81.3%
associate-*r*81.3%
*-commutative81.3%
sqrt-prod81.3%
sqrt-prod81.1%
add-sqr-sqrt81.3%
metadata-eval81.3%
Applied egg-rr81.3%
if 1.2499999999999999e104 < y Initial program 18.9%
Taylor expanded in x around 0 18.9%
unpow218.9%
Simplified18.9%
div-sub18.9%
*-un-lft-identity18.9%
times-frac18.9%
metadata-eval18.9%
times-frac18.9%
pow218.9%
associate-*r*18.9%
*-commutative18.9%
*-inverses87.7%
Applied egg-rr87.7%
unpow287.7%
clear-num87.7%
frac-times87.7%
*-un-lft-identity87.7%
Applied egg-rr87.7%
Final simplification66.5%
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= y 4.3e-110)
(+ 1.0 (* -8.0 (/ y (* x (/ x y)))))
(if (<= y 1.35e+104)
(/ (- (* x x) t_0) (+ t_0 (* x x)))
(+ -1.0 (* 0.25 (/ x (* y (/ y x)))))))))x = abs(x);
y = abs(y);
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (y <= 4.3e-110) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else if (y <= 1.35e+104) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (y <= 4.3d-110) then
tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
else if (y <= 1.35d+104) then
tmp = ((x * x) - t_0) / (t_0 + (x * x))
else
tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (y <= 4.3e-110) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else if (y <= 1.35e+104) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if y <= 4.3e-110: tmp = 1.0 + (-8.0 * (y / (x * (x / y)))) elif y <= 1.35e+104: tmp = ((x * x) - t_0) / (t_0 + (x * x)) else: tmp = -1.0 + (0.25 * (x / (y * (y / x)))) return tmp
x = abs(x) y = abs(y) function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (y <= 4.3e-110) tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y))))); elseif (y <= 1.35e+104) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(t_0 + Float64(x * x))); else tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x))))); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (y <= 4.3e-110) tmp = 1.0 + (-8.0 * (y / (x * (x / y)))); elseif (y <= 1.35e+104) tmp = ((x * x) - t_0) / (t_0 + (x * x)); else tmp = -1.0 + (0.25 * (x / (y * (y / x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 4.3e-110], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+104], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;y \leq 4.3 \cdot 10^{-110}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;\frac{x \cdot x - t_0}{t_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 4.30000000000000025e-110Initial program 53.1%
Taylor expanded in x around inf 50.9%
associate--l+50.9%
distribute-rgt-out--50.9%
metadata-eval50.9%
*-commutative50.9%
+-commutative50.9%
*-commutative50.9%
fma-def50.9%
unpow250.9%
unpow250.9%
times-frac58.4%
Simplified58.4%
fma-udef58.4%
pow258.4%
Applied egg-rr58.4%
unpow258.4%
clear-num58.4%
frac-times58.4%
*-un-lft-identity58.4%
Applied egg-rr58.4%
if 4.30000000000000025e-110 < y < 1.34999999999999992e104Initial program 81.3%
if 1.34999999999999992e104 < y Initial program 18.9%
Taylor expanded in x around 0 18.9%
unpow218.9%
Simplified18.9%
div-sub18.9%
*-un-lft-identity18.9%
times-frac18.9%
metadata-eval18.9%
times-frac18.9%
pow218.9%
associate-*r*18.9%
*-commutative18.9%
*-inverses87.7%
Applied egg-rr87.7%
unpow287.7%
clear-num87.7%
frac-times87.7%
*-un-lft-identity87.7%
Applied egg-rr87.7%
Final simplification66.5%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 6.2e-6) (+ 1.0 (* -8.0 (/ y (* x (/ x y))))) -1.0))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 6.2e-6) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else {
tmp = -1.0;
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 6.2d-6) then
tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
else
tmp = -1.0d0
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 6.2e-6) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else {
tmp = -1.0;
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): tmp = 0 if y <= 6.2e-6: tmp = 1.0 + (-8.0 * (y / (x * (x / y)))) else: tmp = -1.0 return tmp
x = abs(x) y = abs(y) function code(x, y) tmp = 0.0 if (y <= 6.2e-6) tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y))))); else tmp = -1.0; end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.2e-6) tmp = 1.0 + (-8.0 * (y / (x * (x / y)))); else tmp = -1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 6.2e-6], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{-6}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 6.1999999999999999e-6Initial program 57.2%
Taylor expanded in x around inf 52.5%
associate--l+52.5%
distribute-rgt-out--52.5%
metadata-eval52.5%
*-commutative52.5%
+-commutative52.5%
*-commutative52.5%
fma-def52.5%
unpow252.5%
unpow252.5%
times-frac59.2%
Simplified59.2%
fma-udef59.2%
pow259.2%
Applied egg-rr59.2%
unpow259.2%
clear-num59.2%
frac-times59.1%
*-un-lft-identity59.1%
Applied egg-rr59.1%
if 6.1999999999999999e-6 < y Initial program 37.4%
Taylor expanded in x around 0 77.4%
Final simplification63.1%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 4.7e-7) (+ 1.0 (* -8.0 (/ y (* x (/ x y))))) (+ -1.0 (* 0.25 (/ x (* y (/ y x)))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 4.7e-7) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.7d-7) then
tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
else
tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 4.7e-7) {
tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
} else {
tmp = -1.0 + (0.25 * (x / (y * (y / x))));
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): tmp = 0 if y <= 4.7e-7: tmp = 1.0 + (-8.0 * (y / (x * (x / y)))) else: tmp = -1.0 + (0.25 * (x / (y * (y / x)))) return tmp
x = abs(x) y = abs(y) function code(x, y) tmp = 0.0 if (y <= 4.7e-7) tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y))))); else tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x))))); end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.7e-7) tmp = 1.0 + (-8.0 * (y / (x * (x / y)))); else tmp = -1.0 + (0.25 * (x / (y * (y / x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 4.7e-7], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.7 \cdot 10^{-7}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 4.7e-7Initial program 57.2%
Taylor expanded in x around inf 52.5%
associate--l+52.5%
distribute-rgt-out--52.5%
metadata-eval52.5%
*-commutative52.5%
+-commutative52.5%
*-commutative52.5%
fma-def52.5%
unpow252.5%
unpow252.5%
times-frac59.2%
Simplified59.2%
fma-udef59.2%
pow259.2%
Applied egg-rr59.2%
unpow259.2%
clear-num59.2%
frac-times59.1%
*-un-lft-identity59.1%
Applied egg-rr59.1%
if 4.7e-7 < y Initial program 37.4%
Taylor expanded in x around 0 32.9%
unpow232.9%
Simplified32.9%
div-sub32.9%
*-un-lft-identity32.9%
times-frac32.9%
metadata-eval32.9%
times-frac33.0%
pow233.0%
associate-*r*33.0%
*-commutative33.0%
*-inverses78.4%
Applied egg-rr78.4%
unpow278.4%
clear-num78.4%
frac-times78.4%
*-un-lft-identity78.4%
Applied egg-rr78.4%
Final simplification63.3%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 5e-7) 1.0 -1.0))
x = abs(x);
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 5e-7) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5d-7) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 5e-7) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
x = abs(x) y = abs(y) def code(x, y): tmp = 0 if y <= 5e-7: tmp = 1.0 else: tmp = -1.0 return tmp
x = abs(x) y = abs(y) function code(x, y) tmp = 0.0 if (y <= 5e-7) tmp = 1.0; else tmp = -1.0; end return tmp end
x = abs(x) y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5e-7) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 5e-7], 1.0, -1.0]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-7}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 4.99999999999999977e-7Initial program 57.2%
Taylor expanded in x around inf 57.6%
if 4.99999999999999977e-7 < y Initial program 37.4%
Taylor expanded in x around 0 77.4%
Final simplification61.9%
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 -1.0)
x = abs(x);
y = abs(y);
double code(double x, double y) {
return -1.0;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
return -1.0;
}
x = abs(x) y = abs(y) def code(x, y): return -1.0
x = abs(x) y = abs(y) function code(x, y) return -1.0 end
x = abs(x) y = abs(y) function tmp = code(x, y) tmp = -1.0; end
NOTE: x should be positive before calling this function NOTE: y should be positive before calling this function code[x_, y_] := -1.0
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
-1
\end{array}
Initial program 52.9%
Taylor expanded in x around 0 50.2%
Final simplification50.2%
(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 2023257
(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))))