
(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 7 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}
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(if (<= x_m 9e-156)
(log1p (+ (* (exp -1.0) (/ (* (/ x_m y) 0.5) (/ y x_m))) (expm1 -1.0)))
(if (<= x_m 5.1e+115)
(log1p
(expm1
(/
(fma y (* y -4.0) (pow x_m 2.0))
(fma 4.0 (pow y 2.0) (pow x_m 2.0)))))
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m)))))))x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 9e-156) {
tmp = log1p(((exp(-1.0) * (((x_m / y) * 0.5) / (y / x_m))) + expm1(-1.0)));
} else if (x_m <= 5.1e+115) {
tmp = log1p(expm1((fma(y, (y * -4.0), pow(x_m, 2.0)) / fma(4.0, pow(y, 2.0), pow(x_m, 2.0)))));
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 9e-156) tmp = log1p(Float64(Float64(exp(-1.0) * Float64(Float64(Float64(x_m / y) * 0.5) / Float64(y / x_m))) + expm1(-1.0))); elseif (x_m <= 5.1e+115) tmp = log1p(expm1(Float64(fma(y, Float64(y * -4.0), (x_m ^ 2.0)) / fma(4.0, (y ^ 2.0), (x_m ^ 2.0))))); else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 9e-156], N[Log[1 + N[(N[(N[Exp[-1.0], $MachinePrecision] * N[(N[(N[(x$95$m / y), $MachinePrecision] * 0.5), $MachinePrecision] / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(Exp[-1.0] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x$95$m, 5.1e+115], N[Log[1 + N[(Exp[N[(N[(y * N[(y * -4.0), $MachinePrecision] + N[Power[x$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / N[(4.0 * N[Power[y, 2.0], $MachinePrecision] + N[Power[x$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 9 \cdot 10^{-156}:\\
\;\;\;\;\mathsf{log1p}\left(e^{-1} \cdot \frac{\frac{x\_m}{y} \cdot 0.5}{\frac{y}{x\_m}} + \mathsf{expm1}\left(-1\right)\right)\\
\mathbf{elif}\;x\_m \leq 5.1 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{fma}\left(y, y \cdot -4, {x\_m}^{2}\right)}{\mathsf{fma}\left(4, {y}^{2}, {x\_m}^{2}\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x\_m} \cdot \frac{y}{x\_m}\right)\\
\end{array}
\end{array}
if x < 8.99999999999999971e-156Initial program 45.3%
log1p-expm1-u45.3%
sub-neg45.3%
+-commutative45.3%
*-commutative45.3%
distribute-rgt-neg-in45.3%
fma-define45.3%
distribute-rgt-neg-in45.3%
metadata-eval45.3%
pow245.3%
+-commutative45.3%
*-commutative45.3%
associate-*l*45.2%
fma-define45.2%
pow245.2%
pow245.2%
Applied egg-rr45.2%
Taylor expanded in y around inf 50.7%
+-commutative50.7%
associate--l+50.7%
distribute-rgt-out--50.7%
metadata-eval50.7%
associate-/l*50.7%
associate-*l/50.7%
unpow250.7%
unpow250.7%
times-frac63.7%
unpow263.7%
expm1-define63.7%
Simplified63.7%
pow263.7%
*-commutative63.7%
associate-*r*63.7%
clear-num63.7%
un-div-inv63.7%
*-commutative63.7%
Applied egg-rr63.7%
if 8.99999999999999971e-156 < x < 5.0999999999999996e115Initial program 80.8%
log1p-expm1-u80.8%
sub-neg80.8%
+-commutative80.8%
*-commutative80.8%
distribute-rgt-neg-in80.8%
fma-define80.8%
distribute-rgt-neg-in80.8%
metadata-eval80.8%
pow280.8%
+-commutative80.8%
*-commutative80.8%
associate-*l*80.8%
fma-define80.8%
pow280.8%
pow280.8%
Applied egg-rr80.8%
if 5.0999999999999996e115 < x Initial program 14.0%
Taylor expanded in y around 0 80.1%
unpow280.1%
unpow280.1%
times-frac92.6%
Applied egg-rr92.6%
Final simplification72.5%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= x_m 3e-156)
(log1p (+ (* (exp -1.0) (/ (* (/ x_m y) 0.5) (/ y x_m))) (expm1 -1.0)))
(if (<= x_m 6.3e+115)
(/ (- (* x_m x_m) t_0) (+ (* x_m x_m) t_0))
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x_m <= 3e-156) {
tmp = log1p(((exp(-1.0) * (((x_m / y) * 0.5) / (y / x_m))) + expm1(-1.0)));
} else if (x_m <= 6.3e+115) {
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0);
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x_m <= 3e-156) {
tmp = Math.log1p(((Math.exp(-1.0) * (((x_m / y) * 0.5) / (y / x_m))) + Math.expm1(-1.0)));
} else if (x_m <= 6.3e+115) {
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0);
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): t_0 = y * (y * 4.0) tmp = 0 if x_m <= 3e-156: tmp = math.log1p(((math.exp(-1.0) * (((x_m / y) * 0.5) / (y / x_m))) + math.expm1(-1.0))) elif x_m <= 6.3e+115: tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0) else: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) return tmp
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (x_m <= 3e-156) tmp = log1p(Float64(Float64(exp(-1.0) * Float64(Float64(Float64(x_m / y) * 0.5) / Float64(y / x_m))) + expm1(-1.0))); elseif (x_m <= 6.3e+115) tmp = Float64(Float64(Float64(x_m * x_m) - t_0) / Float64(Float64(x_m * x_m) + t_0)); else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); end return tmp end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 3e-156], N[Log[1 + N[(N[(N[Exp[-1.0], $MachinePrecision] * N[(N[(N[(x$95$m / y), $MachinePrecision] * 0.5), $MachinePrecision] / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(Exp[-1.0] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x$95$m, 6.3e+115], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x\_m \leq 3 \cdot 10^{-156}:\\
\;\;\;\;\mathsf{log1p}\left(e^{-1} \cdot \frac{\frac{x\_m}{y} \cdot 0.5}{\frac{y}{x\_m}} + \mathsf{expm1}\left(-1\right)\right)\\
\mathbf{elif}\;x\_m \leq 6.3 \cdot 10^{+115}:\\
\;\;\;\;\frac{x\_m \cdot x\_m - t\_0}{x\_m \cdot x\_m + t\_0}\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x\_m} \cdot \frac{y}{x\_m}\right)\\
\end{array}
\end{array}
if x < 3e-156Initial program 45.3%
log1p-expm1-u45.3%
sub-neg45.3%
+-commutative45.3%
*-commutative45.3%
distribute-rgt-neg-in45.3%
fma-define45.3%
distribute-rgt-neg-in45.3%
metadata-eval45.3%
pow245.3%
+-commutative45.3%
*-commutative45.3%
associate-*l*45.2%
fma-define45.2%
pow245.2%
pow245.2%
Applied egg-rr45.2%
Taylor expanded in y around inf 50.7%
+-commutative50.7%
associate--l+50.7%
distribute-rgt-out--50.7%
metadata-eval50.7%
associate-/l*50.7%
associate-*l/50.7%
unpow250.7%
unpow250.7%
times-frac63.7%
unpow263.7%
expm1-define63.7%
Simplified63.7%
pow263.7%
*-commutative63.7%
associate-*r*63.7%
clear-num63.7%
un-div-inv63.7%
*-commutative63.7%
Applied egg-rr63.7%
if 3e-156 < x < 6.2999999999999997e115Initial program 80.8%
if 6.2999999999999997e115 < x Initial program 14.0%
Taylor expanded in y around 0 80.1%
unpow280.1%
unpow280.1%
times-frac92.6%
Applied egg-rr92.6%
Final simplification72.5%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= x_m 7.3e-156)
(+ -1.0 (* 0.5 (* (/ x_m y) (/ x_m y))))
(if (<= x_m 4e+115)
(/ (- (* x_m x_m) t_0) (+ (* x_m x_m) t_0))
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x_m <= 7.3e-156) {
tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y)));
} else if (x_m <= 4e+115) {
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0);
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (x_m <= 7.3d-156) then
tmp = (-1.0d0) + (0.5d0 * ((x_m / y) * (x_m / y)))
else if (x_m <= 4d+115) then
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0)
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x_m) * (y / x_m)))
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (x_m <= 7.3e-156) {
tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y)));
} else if (x_m <= 4e+115) {
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0);
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): t_0 = y * (y * 4.0) tmp = 0 if x_m <= 7.3e-156: tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y))) elif x_m <= 4e+115: tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0) else: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) return tmp
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (x_m <= 7.3e-156) tmp = Float64(-1.0 + Float64(0.5 * Float64(Float64(x_m / y) * Float64(x_m / y)))); elseif (x_m <= 4e+115) tmp = Float64(Float64(Float64(x_m * x_m) - t_0) / Float64(Float64(x_m * x_m) + t_0)); else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) t_0 = y * (y * 4.0); tmp = 0.0; if (x_m <= 7.3e-156) tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y))); elseif (x_m <= 4e+115) tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0); else tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 7.3e-156], N[(-1.0 + N[(0.5 * N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 4e+115], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x\_m \leq 7.3 \cdot 10^{-156}:\\
\;\;\;\;-1 + 0.5 \cdot \left(\frac{x\_m}{y} \cdot \frac{x\_m}{y}\right)\\
\mathbf{elif}\;x\_m \leq 4 \cdot 10^{+115}:\\
\;\;\;\;\frac{x\_m \cdot x\_m - t\_0}{x\_m \cdot x\_m + t\_0}\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x\_m} \cdot \frac{y}{x\_m}\right)\\
\end{array}
\end{array}
if x < 7.3e-156Initial program 45.3%
Taylor expanded in x around 0 50.2%
unpow250.2%
unpow250.2%
times-frac61.8%
Applied egg-rr61.8%
if 7.3e-156 < x < 4.0000000000000001e115Initial program 80.8%
if 4.0000000000000001e115 < x Initial program 14.0%
Taylor expanded in y around 0 80.1%
unpow280.1%
unpow280.1%
times-frac92.6%
Applied egg-rr92.6%
Final simplification71.3%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= x_m 2.35e-21) -1.0 (+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 2.35e-21) {
tmp = -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (x_m <= 2.35d-21) then
tmp = -1.0d0
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x_m) * (y / x_m)))
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (x_m <= 2.35e-21) {
tmp = -1.0;
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if x_m <= 2.35e-21: tmp = -1.0 else: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 2.35e-21) tmp = -1.0; else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (x_m <= 2.35e-21) tmp = -1.0; else tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 2.35e-21], -1.0, N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.35 \cdot 10^{-21}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x\_m} \cdot \frac{y}{x\_m}\right)\\
\end{array}
\end{array}
if x < 2.35000000000000015e-21Initial program 50.0%
Taylor expanded in x around 0 61.6%
if 2.35000000000000015e-21 < x Initial program 34.2%
Taylor expanded in y around 0 75.0%
unpow275.0%
unpow275.0%
times-frac83.9%
Applied egg-rr83.9%
Final simplification67.7%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= x_m 2.4e-21) (+ -1.0 (* 0.5 (* (/ x_m y) (/ x_m y)))) (+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 2.4e-21) {
tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y)));
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (x_m <= 2.4d-21) then
tmp = (-1.0d0) + (0.5d0 * ((x_m / y) * (x_m / y)))
else
tmp = 1.0d0 + ((-8.0d0) * ((y / x_m) * (y / x_m)))
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (x_m <= 2.4e-21) {
tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y)));
} else {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if x_m <= 2.4e-21: tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y))) else: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 2.4e-21) tmp = Float64(-1.0 + Float64(0.5 * Float64(Float64(x_m / y) * Float64(x_m / y)))); else tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (x_m <= 2.4e-21) tmp = -1.0 + (0.5 * ((x_m / y) * (x_m / y))); else tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 2.4e-21], N[(-1.0 + N[(0.5 * N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.4 \cdot 10^{-21}:\\
\;\;\;\;-1 + 0.5 \cdot \left(\frac{x\_m}{y} \cdot \frac{x\_m}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x\_m} \cdot \frac{y}{x\_m}\right)\\
\end{array}
\end{array}
if x < 2.3999999999999999e-21Initial program 50.0%
Taylor expanded in x around 0 52.9%
unpow252.9%
unpow252.9%
times-frac62.8%
Applied egg-rr62.8%
if 2.3999999999999999e-21 < x Initial program 34.2%
Taylor expanded in y around 0 75.0%
unpow275.0%
unpow275.0%
times-frac83.9%
Applied egg-rr83.9%
Final simplification68.6%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= x_m 2.6e-14) -1.0 1.0))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (x_m <= 2.6e-14) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (x_m <= 2.6d-14) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (x_m <= 2.6e-14) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if x_m <= 2.6e-14: tmp = -1.0 else: tmp = 1.0 return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (x_m <= 2.6e-14) tmp = -1.0; else tmp = 1.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (x_m <= 2.6e-14) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[x$95$m, 2.6e-14], -1.0, 1.0]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.6 \cdot 10^{-14}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.59999999999999997e-14Initial program 50.3%
Taylor expanded in x around 0 61.3%
if 2.59999999999999997e-14 < x Initial program 33.3%
Taylor expanded in x around inf 82.5%
Final simplification67.0%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 -1.0)
x_m = fabs(x);
double code(double x_m, double y) {
return -1.0;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = -1.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return -1.0;
}
x_m = math.fabs(x) def code(x_m, y): return -1.0
x_m = abs(x) function code(x_m, y) return -1.0 end
x_m = abs(x); function tmp = code(x_m, y) tmp = -1.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := -1.0
\begin{array}{l}
x_m = \left|x\right|
\\
-1
\end{array}
Initial program 45.7%
Taylor expanded in x around 0 49.5%
Final simplification49.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 2024079
(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))))