
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- 1.0 y))))
(if (<= y -8500000.0)
t_0
(if (<= y -1.7e-61)
t_1
(if (<= y -6.2e-86) (/ y (+ y -1.0)) (if (<= y 900000.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (1.0 - y);
double tmp;
if (y <= -8500000.0) {
tmp = t_0;
} else if (y <= -1.7e-61) {
tmp = t_1;
} else if (y <= -6.2e-86) {
tmp = y / (y + -1.0);
} else if (y <= 900000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = x / (1.0d0 - y)
if (y <= (-8500000.0d0)) then
tmp = t_0
else if (y <= (-1.7d-61)) then
tmp = t_1
else if (y <= (-6.2d-86)) then
tmp = y / (y + (-1.0d0))
else if (y <= 900000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (1.0 - y);
double tmp;
if (y <= -8500000.0) {
tmp = t_0;
} else if (y <= -1.7e-61) {
tmp = t_1;
} else if (y <= -6.2e-86) {
tmp = y / (y + -1.0);
} else if (y <= 900000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) t_1 = x / (1.0 - y) tmp = 0 if y <= -8500000.0: tmp = t_0 elif y <= -1.7e-61: tmp = t_1 elif y <= -6.2e-86: tmp = y / (y + -1.0) elif y <= 900000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(1.0 - y)) tmp = 0.0 if (y <= -8500000.0) tmp = t_0; elseif (y <= -1.7e-61) tmp = t_1; elseif (y <= -6.2e-86) tmp = Float64(y / Float64(y + -1.0)); elseif (y <= 900000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); t_1 = x / (1.0 - y); tmp = 0.0; if (y <= -8500000.0) tmp = t_0; elseif (y <= -1.7e-61) tmp = t_1; elseif (y <= -6.2e-86) tmp = y / (y + -1.0); elseif (y <= 900000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8500000.0], t$95$0, If[LessEqual[y, -1.7e-61], t$95$1, If[LessEqual[y, -6.2e-86], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 900000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{1 - y}\\
\mathbf{if}\;y \leq -8500000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{elif}\;y \leq 900000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -8.5e6 or 9e5 < y Initial program 100.0%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
div-sub99.9%
unsub-neg99.9%
mul-1-neg99.9%
+-commutative99.9%
metadata-eval99.9%
distribute-lft-in99.9%
metadata-eval99.9%
sub-neg99.9%
associate-*r/99.9%
mul-1-neg99.9%
unsub-neg99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 99.3%
if -8.5e6 < y < -1.6999999999999999e-61 or -6.19999999999999977e-86 < y < 9e5Initial program 100.0%
Taylor expanded in x around inf 83.6%
if -1.6999999999999999e-61 < y < -6.19999999999999977e-86Initial program 100.0%
Taylor expanded in x around 0 80.1%
metadata-eval80.1%
times-frac80.1%
*-lft-identity80.1%
neg-mul-180.1%
neg-sub080.1%
associate--r-80.1%
metadata-eval80.1%
Simplified80.1%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -8000000.0)
t_0
(if (<= y -1.7e-61)
(* x (/ 1.0 (- 1.0 y)))
(if (<= y -2.05e-84)
(/ y (+ y -1.0))
(if (<= y 13500000.0) (/ x (- 1.0 y)) t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -8000000.0) {
tmp = t_0;
} else if (y <= -1.7e-61) {
tmp = x * (1.0 / (1.0 - y));
} else if (y <= -2.05e-84) {
tmp = y / (y + -1.0);
} else if (y <= 13500000.0) {
tmp = x / (1.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-8000000.0d0)) then
tmp = t_0
else if (y <= (-1.7d-61)) then
tmp = x * (1.0d0 / (1.0d0 - y))
else if (y <= (-2.05d-84)) then
tmp = y / (y + (-1.0d0))
else if (y <= 13500000.0d0) then
tmp = x / (1.0d0 - y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -8000000.0) {
tmp = t_0;
} else if (y <= -1.7e-61) {
tmp = x * (1.0 / (1.0 - y));
} else if (y <= -2.05e-84) {
tmp = y / (y + -1.0);
} else if (y <= 13500000.0) {
tmp = x / (1.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -8000000.0: tmp = t_0 elif y <= -1.7e-61: tmp = x * (1.0 / (1.0 - y)) elif y <= -2.05e-84: tmp = y / (y + -1.0) elif y <= 13500000.0: tmp = x / (1.0 - y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -8000000.0) tmp = t_0; elseif (y <= -1.7e-61) tmp = Float64(x * Float64(1.0 / Float64(1.0 - y))); elseif (y <= -2.05e-84) tmp = Float64(y / Float64(y + -1.0)); elseif (y <= 13500000.0) tmp = Float64(x / Float64(1.0 - y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -8000000.0) tmp = t_0; elseif (y <= -1.7e-61) tmp = x * (1.0 / (1.0 - y)); elseif (y <= -2.05e-84) tmp = y / (y + -1.0); elseif (y <= 13500000.0) tmp = x / (1.0 - y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8000000.0], t$95$0, If[LessEqual[y, -1.7e-61], N[(x * N[(1.0 / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.05e-84], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 13500000.0], N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -8000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-61}:\\
\;\;\;\;x \cdot \frac{1}{1 - y}\\
\mathbf{elif}\;y \leq -2.05 \cdot 10^{-84}:\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{elif}\;y \leq 13500000:\\
\;\;\;\;\frac{x}{1 - y}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -8e6 or 1.35e7 < y Initial program 100.0%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
div-sub99.9%
unsub-neg99.9%
mul-1-neg99.9%
+-commutative99.9%
metadata-eval99.9%
distribute-lft-in99.9%
metadata-eval99.9%
sub-neg99.9%
associate-*r/99.9%
mul-1-neg99.9%
unsub-neg99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 99.3%
if -8e6 < y < -1.6999999999999999e-61Initial program 99.9%
Taylor expanded in x around inf 94.0%
clear-num93.8%
associate-/r/94.1%
Applied egg-rr94.1%
if -1.6999999999999999e-61 < y < -2.05000000000000003e-84Initial program 100.0%
Taylor expanded in x around 0 80.1%
metadata-eval80.1%
times-frac80.1%
*-lft-identity80.1%
neg-mul-180.1%
neg-sub080.1%
associate--r-80.1%
metadata-eval80.1%
Simplified80.1%
if -2.05000000000000003e-84 < y < 1.35e7Initial program 100.0%
Taylor expanded in x around inf 82.2%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(if (<= y -110000.0)
(- 1.0 (/ (+ x -1.0) y))
(if (<= y -2.1e-61)
(* x (/ 1.0 (- 1.0 y)))
(if (<= y -1.7e-84)
(/ y (+ y -1.0))
(if (<= y 28000000.0) (/ x (- 1.0 y)) (- 1.0 (/ x y)))))))
double code(double x, double y) {
double tmp;
if (y <= -110000.0) {
tmp = 1.0 - ((x + -1.0) / y);
} else if (y <= -2.1e-61) {
tmp = x * (1.0 / (1.0 - y));
} else if (y <= -1.7e-84) {
tmp = y / (y + -1.0);
} else if (y <= 28000000.0) {
tmp = x / (1.0 - y);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-110000.0d0)) then
tmp = 1.0d0 - ((x + (-1.0d0)) / y)
else if (y <= (-2.1d-61)) then
tmp = x * (1.0d0 / (1.0d0 - y))
else if (y <= (-1.7d-84)) then
tmp = y / (y + (-1.0d0))
else if (y <= 28000000.0d0) then
tmp = x / (1.0d0 - y)
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -110000.0) {
tmp = 1.0 - ((x + -1.0) / y);
} else if (y <= -2.1e-61) {
tmp = x * (1.0 / (1.0 - y));
} else if (y <= -1.7e-84) {
tmp = y / (y + -1.0);
} else if (y <= 28000000.0) {
tmp = x / (1.0 - y);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -110000.0: tmp = 1.0 - ((x + -1.0) / y) elif y <= -2.1e-61: tmp = x * (1.0 / (1.0 - y)) elif y <= -1.7e-84: tmp = y / (y + -1.0) elif y <= 28000000.0: tmp = x / (1.0 - y) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -110000.0) tmp = Float64(1.0 - Float64(Float64(x + -1.0) / y)); elseif (y <= -2.1e-61) tmp = Float64(x * Float64(1.0 / Float64(1.0 - y))); elseif (y <= -1.7e-84) tmp = Float64(y / Float64(y + -1.0)); elseif (y <= 28000000.0) tmp = Float64(x / Float64(1.0 - y)); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -110000.0) tmp = 1.0 - ((x + -1.0) / y); elseif (y <= -2.1e-61) tmp = x * (1.0 / (1.0 - y)); elseif (y <= -1.7e-84) tmp = y / (y + -1.0); elseif (y <= 28000000.0) tmp = x / (1.0 - y); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -110000.0], N[(1.0 - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.1e-61], N[(x * N[(1.0 / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.7e-84], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 28000000.0], N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -110000:\\
\;\;\;\;1 - \frac{x + -1}{y}\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-61}:\\
\;\;\;\;x \cdot \frac{1}{1 - y}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-84}:\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{elif}\;y \leq 28000000:\\
\;\;\;\;\frac{x}{1 - y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.1e5Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
div-sub100.0%
unsub-neg100.0%
mul-1-neg100.0%
+-commutative100.0%
metadata-eval100.0%
distribute-lft-in100.0%
metadata-eval100.0%
sub-neg100.0%
associate-*r/100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if -1.1e5 < y < -2.0999999999999999e-61Initial program 99.9%
Taylor expanded in x around inf 94.0%
clear-num93.8%
associate-/r/94.1%
Applied egg-rr94.1%
if -2.0999999999999999e-61 < y < -1.7000000000000001e-84Initial program 100.0%
Taylor expanded in x around 0 80.1%
metadata-eval80.1%
times-frac80.1%
*-lft-identity80.1%
neg-mul-180.1%
neg-sub080.1%
associate--r-80.1%
metadata-eval80.1%
Simplified80.1%
if -1.7000000000000001e-84 < y < 2.8e7Initial program 100.0%
Taylor expanded in x around inf 82.2%
if 2.8e7 < y Initial program 100.0%
Taylor expanded in y around inf 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
div-sub99.6%
unsub-neg99.6%
mul-1-neg99.6%
+-commutative99.6%
metadata-eval99.6%
distribute-lft-in99.6%
metadata-eval99.6%
sub-neg99.6%
associate-*r/99.6%
mul-1-neg99.6%
unsub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 99.6%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (or (<= y -0.0156) (not (<= y 1.0))) (- 1.0 (/ x y)) x))
double code(double x, double y) {
double tmp;
if ((y <= -0.0156) || !(y <= 1.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-0.0156d0)) .or. (.not. (y <= 1.0d0))) then
tmp = 1.0d0 - (x / y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -0.0156) || !(y <= 1.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.0156) or not (y <= 1.0): tmp = 1.0 - (x / y) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.0156) || !(y <= 1.0)) tmp = Float64(1.0 - Float64(x / y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.0156) || ~((y <= 1.0))) tmp = 1.0 - (x / y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.0156], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0156 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -0.015599999999999999 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
div-sub99.3%
unsub-neg99.3%
mul-1-neg99.3%
+-commutative99.3%
metadata-eval99.3%
distribute-lft-in99.3%
metadata-eval99.3%
sub-neg99.3%
associate-*r/99.3%
mul-1-neg99.3%
unsub-neg99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in x around inf 98.8%
if -0.015599999999999999 < y < 1Initial program 100.0%
Taylor expanded in y around 0 78.0%
Final simplification87.3%
(FPCore (x y) :precision binary64 (if (or (<= y -3750000.0) (not (<= y 62000000.0))) (- 1.0 (/ x y)) (/ x (- 1.0 y))))
double code(double x, double y) {
double tmp;
if ((y <= -3750000.0) || !(y <= 62000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (1.0 - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3750000.0d0)) .or. (.not. (y <= 62000000.0d0))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3750000.0) || !(y <= 62000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (1.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3750000.0) or not (y <= 62000000.0): tmp = 1.0 - (x / y) else: tmp = x / (1.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -3750000.0) || !(y <= 62000000.0)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3750000.0) || ~((y <= 62000000.0))) tmp = 1.0 - (x / y); else tmp = x / (1.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3750000.0], N[Not[LessEqual[y, 62000000.0]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3750000 \lor \neg \left(y \leq 62000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - y}\\
\end{array}
\end{array}
if y < -3.75e6 or 6.2e7 < y Initial program 100.0%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
div-sub99.9%
unsub-neg99.9%
mul-1-neg99.9%
+-commutative99.9%
metadata-eval99.9%
distribute-lft-in99.9%
metadata-eval99.9%
sub-neg99.9%
associate-*r/99.9%
mul-1-neg99.9%
unsub-neg99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 99.3%
if -3.75e6 < y < 6.2e7Initial program 100.0%
Taylor expanded in x around inf 80.3%
Final simplification88.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x;
} 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 (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 1.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 71.9%
if -1 < y < 1Initial program 100.0%
Taylor expanded in y around 0 78.0%
Final simplification75.3%
(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 100.0%
Taylor expanded in y around inf 34.5%
Final simplification34.5%
herbie shell --seed 2023322
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, C"
:precision binary64
(/ (- x y) (- 1.0 y)))