
(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 10 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)) (t_1 (- x t_0)))
(if (<= y -112000000.0)
t_1
(if (<= y 440000.0)
(+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))
(+ t_1 (* t_0 (/ 1.0 y)))))))
double code(double x, double y) {
double t_0 = (x + -1.0) / y;
double t_1 = x - t_0;
double tmp;
if (y <= -112000000.0) {
tmp = t_1;
} else if (y <= 440000.0) {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
} else {
tmp = t_1 + (t_0 * (1.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) :: t_1
real(8) :: tmp
t_0 = (x + (-1.0d0)) / y
t_1 = x - t_0
if (y <= (-112000000.0d0)) then
tmp = t_1
else if (y <= 440000.0d0) then
tmp = 1.0d0 + (y * ((x + (-1.0d0)) / (y + 1.0d0)))
else
tmp = t_1 + (t_0 * (1.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + -1.0) / y;
double t_1 = x - t_0;
double tmp;
if (y <= -112000000.0) {
tmp = t_1;
} else if (y <= 440000.0) {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
} else {
tmp = t_1 + (t_0 * (1.0 / y));
}
return tmp;
}
def code(x, y): t_0 = (x + -1.0) / y t_1 = x - t_0 tmp = 0 if y <= -112000000.0: tmp = t_1 elif y <= 440000.0: tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))) else: tmp = t_1 + (t_0 * (1.0 / y)) return tmp
function code(x, y) t_0 = Float64(Float64(x + -1.0) / y) t_1 = Float64(x - t_0) tmp = 0.0 if (y <= -112000000.0) tmp = t_1; elseif (y <= 440000.0) tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0)))); else tmp = Float64(t_1 + Float64(t_0 * Float64(1.0 / y))); end return tmp end
function tmp_2 = code(x, y) t_0 = (x + -1.0) / y; t_1 = x - t_0; tmp = 0.0; if (y <= -112000000.0) tmp = t_1; elseif (y <= 440000.0) tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))); else tmp = t_1 + (t_0 * (1.0 / y)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(x - t$95$0), $MachinePrecision]}, If[LessEqual[y, -112000000.0], t$95$1, If[LessEqual[y, 440000.0], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t$95$0 * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{y}\\
t_1 := x - t_0\\
\mathbf{if}\;y \leq -112000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 440000:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_1 + t_0 \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < -1.12e8Initial program 26.8%
associate-*l/51.0%
+-commutative51.0%
Simplified51.0%
Taylor expanded in y around inf 100.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%
if -1.12e8 < y < 4.4e5Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
if 4.4e5 < y Initial program 31.5%
associate-*l/52.3%
+-commutative52.3%
Simplified52.3%
Taylor expanded in y around -inf 100.0%
associate-+r+100.0%
associate--l+100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
*-un-lft-identity100.0%
unpow2100.0%
times-frac100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= y -112000000.0) (not (<= y 155000000.0))) (- x (/ (+ x -1.0) y)) (+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= -112000000.0) || !(y <= 155000000.0)) {
tmp = x - ((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 <= (-112000000.0d0)) .or. (.not. (y <= 155000000.0d0))) then
tmp = x - ((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 <= -112000000.0) || !(y <= 155000000.0)) {
tmp = x - ((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 <= -112000000.0) or not (y <= 155000000.0): tmp = x - ((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 <= -112000000.0) || !(y <= 155000000.0)) tmp = Float64(x - Float64(Float64(x + -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 <= -112000000.0) || ~((y <= 155000000.0))) tmp = x - ((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, -112000000.0], N[Not[LessEqual[y, 155000000.0]], $MachinePrecision]], N[(x - N[(N[(x + -1.0), $MachinePrecision] / 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 -112000000 \lor \neg \left(y \leq 155000000\right):\\
\;\;\;\;x - \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\end{array}
\end{array}
if y < -1.12e8 or 1.55e8 < y Initial program 29.2%
associate-*l/51.7%
+-commutative51.7%
Simplified51.7%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
distribute-neg-in99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
sub-neg99.8%
unsub-neg99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -1.12e8 < y < 1.55e8Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y -9.5e+16) (+ x (/ 1.0 y)) (if (<= y 74000.0) (- 1.0 (/ y (/ (- -1.0 y) x))) (- x (/ (+ x -1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e+16) {
tmp = x + (1.0 / y);
} else if (y <= 74000.0) {
tmp = 1.0 - (y / ((-1.0 - y) / x));
} else {
tmp = x - ((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 <= (-9.5d+16)) then
tmp = x + (1.0d0 / y)
else if (y <= 74000.0d0) then
tmp = 1.0d0 - (y / (((-1.0d0) - y) / x))
else
tmp = x - ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.5e+16) {
tmp = x + (1.0 / y);
} else if (y <= 74000.0) {
tmp = 1.0 - (y / ((-1.0 - y) / x));
} else {
tmp = x - ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e+16: tmp = x + (1.0 / y) elif y <= 74000.0: tmp = 1.0 - (y / ((-1.0 - y) / x)) else: tmp = x - ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e+16) tmp = Float64(x + Float64(1.0 / y)); elseif (y <= 74000.0) tmp = Float64(1.0 - Float64(y / Float64(Float64(-1.0 - y) / x))); else tmp = Float64(x - Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.5e+16) tmp = x + (1.0 / y); elseif (y <= 74000.0) tmp = 1.0 - (y / ((-1.0 - y) / x)); else tmp = x - ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.5e+16], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 74000.0], N[(1.0 - N[(y / N[(N[(-1.0 - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+16}:\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{elif}\;y \leq 74000:\\
\;\;\;\;1 - \frac{y}{\frac{-1 - y}{x}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\end{array}
\end{array}
if y < -9.5e16Initial program 24.2%
associate-*l/49.3%
+-commutative49.3%
Simplified49.3%
Taylor expanded in y around inf 100.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 -9.5e16 < y < 74000Initial program 99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 98.6%
associate-*r/98.6%
neg-mul-198.6%
distribute-neg-in98.6%
metadata-eval98.6%
unsub-neg98.6%
Simplified98.6%
if 74000 < y Initial program 31.5%
associate-*l/52.3%
+-commutative52.3%
Simplified52.3%
Taylor expanded in y around inf 99.6%
associate--l+99.6%
div-sub99.6%
sub-neg99.6%
+-commutative99.6%
metadata-eval99.6%
distribute-neg-in99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
sub-neg99.6%
unsub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.95))) (+ x (/ 1.0 y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.95)) {
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.95d0))) 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.95)) {
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.95): 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.95)) 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.95))) 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.95]], $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.95\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.94999999999999996 < y Initial program 30.3%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 98.9%
associate--l+98.9%
div-sub98.9%
sub-neg98.9%
+-commutative98.9%
metadata-eval98.9%
distribute-neg-in98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
sub-neg98.9%
unsub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in x around 0 98.4%
if -1 < y < 0.94999999999999996Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.6%
Final simplification97.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ (+ x -1.0) y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - ((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 <= 1.0d0))) then
tmp = x - ((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 <= 1.0)) {
tmp = x - ((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 <= 1.0): tmp = x - ((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 <= 1.0)) tmp = Float64(x - Float64(Float64(x + -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 <= 1.0))) tmp = x - ((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, 1.0]], $MachinePrecision]], N[(x - N[(N[(x + -1.0), $MachinePrecision] / 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 1\right):\\
\;\;\;\;x - \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 30.3%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 98.9%
associate--l+98.9%
div-sub98.9%
sub-neg98.9%
+-commutative98.9%
metadata-eval98.9%
distribute-neg-in98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
sub-neg98.9%
unsub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
if -1 < y < 1Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.6%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ 1.0 y)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + (y * 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)) .or. (.not. (y <= 1.0d0))) then
tmp = x + (1.0d0 / y)
else
tmp = 1.0d0 + (y * x)
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 + (y * x);
}
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 + (y * x) 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(y * x)); 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 + (y * x); 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[(y * x), $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 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 30.3%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 98.9%
associate--l+98.9%
div-sub98.9%
sub-neg98.9%
+-commutative98.9%
metadata-eval98.9%
distribute-neg-in98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
sub-neg98.9%
unsub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in x around 0 98.4%
if -1 < y < 1Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.6%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
distribute-lft-neg-out97.0%
*-commutative97.0%
Simplified97.0%
sub-neg97.0%
distribute-rgt-neg-out97.0%
remove-double-neg97.0%
+-commutative97.0%
Applied egg-rr97.0%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 150.0) (+ 1.0 (* y x)) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 150.0) {
tmp = 1.0 + (y * x);
} 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 <= 150.0d0) then
tmp = 1.0d0 + (y * x)
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 <= 150.0) {
tmp = 1.0 + (y * x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 150.0: tmp = 1.0 + (y * x) else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 150.0) tmp = Float64(1.0 + Float64(y * x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 150.0) tmp = 1.0 + (y * x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 150.0], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 150:\\
\;\;\;\;1 + y \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 150 < y Initial program 30.3%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 76.4%
if -1 < y < 150Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.6%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
distribute-lft-neg-out97.0%
*-commutative97.0%
Simplified97.0%
sub-neg97.0%
distribute-rgt-neg-out97.0%
remove-double-neg97.0%
+-commutative97.0%
Applied egg-rr97.0%
Final simplification87.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.9) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.9) {
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.9d0) 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.9) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.9: 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.9) 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.9) 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.9], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.9:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.900000000000000022 < y Initial program 30.9%
associate-*l/52.9%
+-commutative52.9%
Simplified52.9%
Taylor expanded in y around inf 75.9%
if -1 < y < 0.900000000000000022Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.2%
Taylor expanded in x around 0 72.4%
Final simplification74.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.062) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.062) {
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 <= 0.062d0) 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 <= 0.062) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.062: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.062) 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 <= 0.062) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.062], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.062:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.062 < y Initial program 30.9%
associate-*l/52.9%
+-commutative52.9%
Simplified52.9%
Taylor expanded in y around inf 75.9%
if -1 < y < 0.062Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 71.8%
Final simplification73.7%
(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.1%
associate-*l/78.3%
+-commutative78.3%
Simplified78.3%
Taylor expanded in y around 0 40.3%
Final simplification40.3%
(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 2024024
(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))))