
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) y)))
(if (<= y -9e+16)
(- x (/ -1.0 y))
(if (<= y 250000.0)
(+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))
(+ (- x t_0) (/ t_0 y))))))
double code(double x, double y) {
double t_0 = (x + -1.0) / y;
double tmp;
if (y <= -9e+16) {
tmp = x - (-1.0 / y);
} else if (y <= 250000.0) {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
} else {
tmp = (x - t_0) + (t_0 / y);
}
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 = (x + (-1.0d0)) / y
if (y <= (-9d+16)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 250000.0d0) then
tmp = 1.0d0 + (y * ((x + (-1.0d0)) / (y + 1.0d0)))
else
tmp = (x - t_0) + (t_0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + -1.0) / y;
double tmp;
if (y <= -9e+16) {
tmp = x - (-1.0 / y);
} else if (y <= 250000.0) {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
} else {
tmp = (x - t_0) + (t_0 / y);
}
return tmp;
}
def code(x, y): t_0 = (x + -1.0) / y tmp = 0 if y <= -9e+16: tmp = x - (-1.0 / y) elif y <= 250000.0: tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))) else: tmp = (x - t_0) + (t_0 / y) return tmp
function code(x, y) t_0 = Float64(Float64(x + -1.0) / y) tmp = 0.0 if (y <= -9e+16) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 250000.0) tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0)))); else tmp = Float64(Float64(x - t_0) + Float64(t_0 / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x + -1.0) / y; tmp = 0.0; if (y <= -9e+16) tmp = x - (-1.0 / y); elseif (y <= 250000.0) tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))); else tmp = (x - t_0) + (t_0 / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -9e+16], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 250000.0], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - t$95$0), $MachinePrecision] + N[(t$95$0 / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{y}\\
\mathbf{if}\;y \leq -9 \cdot 10^{+16}:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 250000:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(x - t_0\right) + \frac{t_0}{y}\\
\end{array}
\end{array}
if y < -9e16Initial program 34.0%
sub-neg34.0%
distribute-neg-frac34.0%
neg-mul-134.0%
associate-*l/34.0%
metadata-eval34.0%
associate-*l/34.0%
associate-/r/34.0%
metadata-eval34.0%
distribute-neg-frac34.0%
cancel-sign-sub-inv34.0%
associate-/r/34.0%
associate-/r*34.0%
neg-mul-134.0%
associate-/r/34.0%
distribute-rgt-neg-in34.0%
associate-/r/34.0%
distribute-neg-frac34.0%
metadata-eval34.0%
associate-/r/34.0%
Simplified51.7%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
metadata-eval100.0%
distribute-neg-in100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
sub-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -9e16 < y < 2.5e5Initial program 99.9%
sub-neg99.9%
distribute-neg-frac99.9%
neg-mul-199.9%
associate-*l/99.9%
metadata-eval99.9%
associate-*l/99.9%
associate-/r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
cancel-sign-sub-inv99.9%
associate-/r/99.8%
associate-/r*99.8%
neg-mul-199.8%
associate-/r/99.9%
distribute-rgt-neg-in99.9%
associate-/r/99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
associate-/r/99.9%
Simplified99.9%
if 2.5e5 < y Initial program 29.0%
sub-neg29.0%
distribute-neg-frac29.0%
neg-mul-129.0%
associate-*l/29.2%
metadata-eval29.2%
associate-*l/29.2%
associate-/r/29.2%
metadata-eval29.2%
distribute-neg-frac29.2%
cancel-sign-sub-inv29.2%
associate-/r/28.9%
associate-/r*28.9%
neg-mul-128.9%
associate-/r/29.2%
distribute-rgt-neg-in29.2%
associate-/r/28.9%
distribute-neg-frac28.9%
metadata-eval28.9%
associate-/r/29.2%
Simplified62.5%
Taylor expanded in y around -inf 100.0%
+-commutative100.0%
associate--l+100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
unpow2100.0%
associate-/r*100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ y (+ y 1.0)))) (fma x t_0 (* (+ y 1.0) (/ t_0 (+ y (* y y)))))))
double code(double x, double y) {
double t_0 = y / (y + 1.0);
return fma(x, t_0, ((y + 1.0) * (t_0 / (y + (y * y)))));
}
function code(x, y) t_0 = Float64(y / Float64(y + 1.0)) return fma(x, t_0, Float64(Float64(y + 1.0) * Float64(t_0 / Float64(y + Float64(y * y))))) end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(x * t$95$0 + N[(N[(y + 1.0), $MachinePrecision] * N[(t$95$0 / N[(y + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + 1}\\
\mathsf{fma}\left(x, t_0, \left(y + 1\right) \cdot \frac{t_0}{y + y \cdot y}\right)
\end{array}
\end{array}
Initial program 68.6%
sub-neg68.6%
distribute-neg-frac68.6%
neg-mul-168.6%
associate-*l/68.7%
metadata-eval68.7%
associate-*l/68.7%
associate-/r/68.7%
metadata-eval68.7%
distribute-neg-frac68.7%
cancel-sign-sub-inv68.7%
associate-/r/68.6%
associate-/r*68.6%
neg-mul-168.6%
associate-/r/68.7%
distribute-rgt-neg-in68.7%
associate-/r/68.6%
distribute-neg-frac68.6%
metadata-eval68.6%
associate-/r/68.7%
Simplified80.3%
associate-/r/80.3%
add-exp-log58.2%
sub-neg58.2%
log1p-def58.2%
div-inv58.2%
clear-num58.2%
distribute-lft-neg-in58.2%
Applied egg-rr58.2%
neg-sub058.2%
metadata-eval58.2%
associate--r-58.2%
metadata-eval58.2%
metadata-eval58.2%
+-commutative58.2%
associate-*r/53.8%
associate-*l/58.3%
*-commutative58.3%
Simplified58.3%
Taylor expanded in x around inf 21.9%
+-commutative21.9%
exp-sum21.9%
fma-def21.9%
mul-1-neg21.9%
log-rec21.9%
remove-double-neg21.9%
rem-exp-log22.7%
+-commutative22.7%
rem-exp-log22.9%
Simplified66.5%
expm1-log1p-u66.6%
expm1-udef66.5%
*-commutative66.5%
associate-/l*68.8%
+-commutative68.8%
+-commutative68.8%
+-commutative68.8%
Applied egg-rr68.8%
expm1-def68.8%
expm1-log1p68.7%
associate-/r/76.0%
*-commutative76.0%
associate-*r/66.5%
times-frac67.5%
associate-/l*67.5%
associate-*r/67.5%
*-commutative67.5%
times-frac76.1%
associate-/l*88.6%
*-inverses88.6%
/-rgt-identity88.6%
Simplified88.6%
Taylor expanded in y around 0 98.0%
unpow298.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (or (<= y -9e+16) (not (<= y 33000000000.0))) (- x (/ -1.0 y)) (+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= -9e+16) || !(y <= 33000000000.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * ((x + -1.0) / (y + 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 <= (-9d+16)) .or. (.not. (y <= 33000000000.0d0))) then
tmp = x - ((-1.0d0) / y)
else
tmp = 1.0d0 + (y * ((x + (-1.0d0)) / (y + 1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -9e+16) || !(y <= 33000000000.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -9e+16) or not (y <= 33000000000.0): tmp = x - (-1.0 / y) else: tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -9e+16) || !(y <= 33000000000.0)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -9e+16) || ~((y <= 33000000000.0))) tmp = x - (-1.0 / y); else tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -9e+16], N[Not[LessEqual[y, 33000000000.0]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+16} \lor \neg \left(y \leq 33000000000\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\end{array}
\end{array}
if y < -9e16 or 3.3e10 < y Initial program 31.5%
sub-neg31.5%
distribute-neg-frac31.5%
neg-mul-131.5%
associate-*l/31.6%
metadata-eval31.6%
associate-*l/31.6%
associate-/r/31.6%
metadata-eval31.6%
distribute-neg-frac31.6%
cancel-sign-sub-inv31.6%
associate-/r/31.4%
associate-/r*31.4%
neg-mul-131.4%
associate-/r/31.6%
distribute-rgt-neg-in31.6%
associate-/r/31.4%
distribute-neg-frac31.4%
metadata-eval31.4%
associate-/r/31.6%
Simplified57.1%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
distribute-neg-in99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
sub-neg99.9%
unsub-neg99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
if -9e16 < y < 3.3e10Initial program 99.9%
sub-neg99.9%
distribute-neg-frac99.9%
neg-mul-199.9%
associate-*l/99.9%
metadata-eval99.9%
associate-*l/99.9%
associate-/r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
cancel-sign-sub-inv99.9%
associate-/r/99.8%
associate-/r*99.8%
neg-mul-199.8%
associate-/r/99.9%
distribute-rgt-neg-in99.9%
associate-/r/99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
associate-/r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.82))) (- x (/ -1.0 y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.82)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * (x + -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)) .or. (.not. (y <= 0.82d0))) then
tmp = x - ((-1.0d0) / y)
else
tmp = 1.0d0 + (y * (x + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.82)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * (x + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.82): tmp = x - (-1.0 / y) else: tmp = 1.0 + (y * (x + -1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.82)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 + Float64(y * Float64(x + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.82))) tmp = x - (-1.0 / y); else tmp = 1.0 + (y * (x + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.82]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.82\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.819999999999999951 < y Initial program 33.1%
sub-neg33.1%
distribute-neg-frac33.1%
neg-mul-133.1%
associate-*l/33.1%
metadata-eval33.1%
associate-*l/33.1%
associate-/r/33.1%
metadata-eval33.1%
distribute-neg-frac33.1%
cancel-sign-sub-inv33.1%
associate-/r/33.0%
associate-/r*33.0%
neg-mul-133.0%
associate-/r/33.1%
distribute-rgt-neg-in33.1%
associate-/r/33.0%
distribute-neg-frac33.0%
metadata-eval33.0%
associate-/r/33.1%
Simplified58.0%
Taylor expanded in y around inf 98.8%
+-commutative98.8%
associate--l+98.8%
div-sub98.8%
sub-neg98.8%
+-commutative98.8%
metadata-eval98.8%
distribute-neg-in98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
sub-neg98.8%
unsub-neg98.8%
sub-neg98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in x around 0 98.8%
if -1 < y < 0.819999999999999951Initial program 100.0%
sub-neg100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-*l/100.0%
associate-/r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
cancel-sign-sub-inv100.0%
associate-/r/100.0%
associate-/r*100.0%
neg-mul-1100.0%
associate-/r/100.0%
distribute-rgt-neg-in100.0%
associate-/r/100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
Final simplification98.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.072))) (- x (/ -1.0 y)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.072)) {
tmp = x - (-1.0 / y);
} else {
tmp = 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 <= (-1.0d0)) .or. (.not. (y <= 0.072d0))) then
tmp = x - ((-1.0d0) / y)
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.072)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.072): tmp = x - (-1.0 / y) else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.072)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.072))) tmp = x - (-1.0 / y); else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.072]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.072\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < -1 or 0.0719999999999999946 < y Initial program 33.1%
sub-neg33.1%
distribute-neg-frac33.1%
neg-mul-133.1%
associate-*l/33.1%
metadata-eval33.1%
associate-*l/33.1%
associate-/r/33.1%
metadata-eval33.1%
distribute-neg-frac33.1%
cancel-sign-sub-inv33.1%
associate-/r/33.0%
associate-/r*33.0%
neg-mul-133.0%
associate-/r/33.1%
distribute-rgt-neg-in33.1%
associate-/r/33.0%
distribute-neg-frac33.0%
metadata-eval33.0%
associate-/r/33.1%
Simplified58.0%
Taylor expanded in y around inf 98.8%
+-commutative98.8%
associate--l+98.8%
div-sub98.8%
sub-neg98.8%
+-commutative98.8%
metadata-eval98.8%
distribute-neg-in98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
sub-neg98.8%
unsub-neg98.8%
sub-neg98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in x around 0 98.8%
if -1 < y < 0.0719999999999999946Initial program 100.0%
sub-neg100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-*l/100.0%
associate-/r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
cancel-sign-sub-inv100.0%
associate-/r/100.0%
associate-/r*100.0%
neg-mul-1100.0%
associate-/r/100.0%
distribute-rgt-neg-in100.0%
associate-/r/100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
Taylor expanded in x around 0 75.1%
Final simplification86.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ -1.0 y)) (+ 1.0 (* x y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.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 <= (-1.0d0)) .or. (.not. (y <= 1.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 <= -1.0) || !(y <= 1.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x - (-1.0 / y) else: tmp = 1.0 + (x * y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.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 <= -1.0) || ~((y <= 1.0))) tmp = x - (-1.0 / y); else tmp = 1.0 + (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], 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 -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot y\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 33.1%
sub-neg33.1%
distribute-neg-frac33.1%
neg-mul-133.1%
associate-*l/33.1%
metadata-eval33.1%
associate-*l/33.1%
associate-/r/33.1%
metadata-eval33.1%
distribute-neg-frac33.1%
cancel-sign-sub-inv33.1%
associate-/r/33.0%
associate-/r*33.0%
neg-mul-133.0%
associate-/r/33.1%
distribute-rgt-neg-in33.1%
associate-/r/33.0%
distribute-neg-frac33.0%
metadata-eval33.0%
associate-/r/33.1%
Simplified58.0%
Taylor expanded in y around inf 98.8%
+-commutative98.8%
associate--l+98.8%
div-sub98.8%
sub-neg98.8%
+-commutative98.8%
metadata-eval98.8%
distribute-neg-in98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
sub-neg98.8%
unsub-neg98.8%
sub-neg98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in x around 0 98.8%
if -1 < y < 1Initial program 100.0%
sub-neg100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-*l/100.0%
associate-/r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
cancel-sign-sub-inv100.0%
associate-/r/100.0%
associate-/r*100.0%
neg-mul-1100.0%
associate-/r/100.0%
distribute-rgt-neg-in100.0%
associate-/r/100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
Taylor expanded in x around inf 97.6%
mul-1-neg97.6%
distribute-rgt-neg-out97.6%
Simplified97.6%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.17) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.17) {
tmp = 1.0 - 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 <= (-1.0d0)) then
tmp = x
else if (y <= 0.17d0) then
tmp = 1.0d0 - y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.17) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.17: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.17) tmp = Float64(1.0 - y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 0.17) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.17], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.17:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.170000000000000012 < y Initial program 33.1%
sub-neg33.1%
distribute-neg-frac33.1%
neg-mul-133.1%
associate-*l/33.1%
metadata-eval33.1%
associate-*l/33.1%
associate-/r/33.1%
metadata-eval33.1%
distribute-neg-frac33.1%
cancel-sign-sub-inv33.1%
associate-/r/33.0%
associate-/r*33.0%
neg-mul-133.0%
associate-/r/33.1%
distribute-rgt-neg-in33.1%
associate-/r/33.0%
distribute-neg-frac33.0%
metadata-eval33.0%
associate-/r/33.1%
Simplified58.0%
Taylor expanded in y around inf 74.0%
if -1 < y < 0.170000000000000012Initial program 100.0%
sub-neg100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
associate-*l/100.0%
metadata-eval100.0%
associate-*l/100.0%
associate-/r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
cancel-sign-sub-inv100.0%
associate-/r/100.0%
associate-/r*100.0%
neg-mul-1100.0%
associate-/r/100.0%
distribute-rgt-neg-in100.0%
associate-/r/100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
Taylor expanded in x around 0 75.1%
Final simplification74.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 5e+17) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 5e+17) {
tmp = 1.0;
} 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 <= (-1.0d0)) then
tmp = x
else if (y <= 5d+17) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 5e+17) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 5e+17: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 5e+17) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 5e+17) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 5e+17], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 5e17 < y Initial program 32.8%
sub-neg32.8%
distribute-neg-frac32.8%
neg-mul-132.8%
associate-*l/32.8%
metadata-eval32.8%
associate-*l/32.8%
associate-/r/32.8%
metadata-eval32.8%
distribute-neg-frac32.8%
cancel-sign-sub-inv32.8%
associate-/r/32.7%
associate-/r*32.7%
neg-mul-132.7%
associate-/r/32.8%
distribute-rgt-neg-in32.8%
associate-/r/32.7%
distribute-neg-frac32.7%
metadata-eval32.7%
associate-/r/32.8%
Simplified58.4%
Taylor expanded in y around inf 75.7%
if -1 < y < 5e17Initial program 98.8%
sub-neg98.8%
distribute-neg-frac98.8%
neg-mul-198.8%
associate-*l/98.8%
metadata-eval98.8%
associate-*l/98.8%
associate-/r/98.8%
metadata-eval98.8%
distribute-neg-frac98.8%
cancel-sign-sub-inv98.8%
associate-/r/98.8%
associate-/r*98.8%
neg-mul-198.8%
associate-/r/98.8%
distribute-rgt-neg-in98.8%
associate-/r/98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
associate-/r/98.8%
Simplified98.8%
Taylor expanded in y around 0 72.6%
Final simplification74.0%
(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 68.6%
sub-neg68.6%
distribute-neg-frac68.6%
neg-mul-168.6%
associate-*l/68.7%
metadata-eval68.7%
associate-*l/68.7%
associate-/r/68.7%
metadata-eval68.7%
distribute-neg-frac68.7%
cancel-sign-sub-inv68.7%
associate-/r/68.6%
associate-/r*68.6%
neg-mul-168.6%
associate-/r/68.7%
distribute-rgt-neg-in68.7%
associate-/r/68.6%
distribute-neg-frac68.6%
metadata-eval68.6%
associate-/r/68.7%
Simplified80.3%
Taylor expanded in y around 0 41.0%
Final simplification41.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (/ 1.0 y) (- (/ x y) x))))
(if (< y -3693.8482788297247)
t_0
(if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) t_0))))
double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} 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 / y) - ((x / y) - x)
if (y < (-3693.8482788297247d0)) then
tmp = t_0
else if (y < 6799310503.41891d0) then
tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (1.0 / y) - ((x / y) - x) tmp = 0 if y < -3693.8482788297247: tmp = t_0 elif y < 6799310503.41891: tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(1.0 / y) - Float64(Float64(x / y) - x)) tmp = 0.0 if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 / y) - ((x / y) - x); tmp = 0.0; if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -3693.8482788297247], t$95$0, If[Less[y, 6799310503.41891], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{y} - \left(\frac{x}{y} - x\right)\\
\mathbf{if}\;y < -3693.8482788297247:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 6799310503.41891:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023185
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))