
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x + y) / (y + 1.0);
}
def code(x, y): return (x + y) / (y + 1.0)
function code(x, y) return Float64(Float64(x + y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x + y) / (y + 1.0); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{y + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x + y) / (y + 1.0);
}
def code(x, y): return (x + y) / (y + 1.0)
function code(x, y) return Float64(Float64(x + y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x + y) / (y + 1.0); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{y + 1}
\end{array}
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x + y) / (y + 1.0);
}
def code(x, y): return (x + y) / (y + 1.0)
function code(x, y) return Float64(Float64(x + y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x + y) / (y + 1.0); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{y + 1}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))) (t_1 (/ y (+ y 1.0))))
(if (<= y -2.2e+16)
(+ 1.0 (/ x y))
(if (<= y -3.2e-86)
t_1
(if (<= y 2.5e-58)
t_0
(if (<= y 5.1e-33)
t_1
(if (<= y 11000000000.0) t_0 (- 1.0 (/ (- 1.0 x) y)))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double t_1 = y / (y + 1.0);
double tmp;
if (y <= -2.2e+16) {
tmp = 1.0 + (x / y);
} else if (y <= -3.2e-86) {
tmp = t_1;
} else if (y <= 2.5e-58) {
tmp = t_0;
} else if (y <= 5.1e-33) {
tmp = t_1;
} else if (y <= 11000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 - ((1.0 - x) / 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 / (y + 1.0d0)
t_1 = y / (y + 1.0d0)
if (y <= (-2.2d+16)) then
tmp = 1.0d0 + (x / y)
else if (y <= (-3.2d-86)) then
tmp = t_1
else if (y <= 2.5d-58) then
tmp = t_0
else if (y <= 5.1d-33) then
tmp = t_1
else if (y <= 11000000000.0d0) then
tmp = t_0
else
tmp = 1.0d0 - ((1.0d0 - x) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y + 1.0);
double t_1 = y / (y + 1.0);
double tmp;
if (y <= -2.2e+16) {
tmp = 1.0 + (x / y);
} else if (y <= -3.2e-86) {
tmp = t_1;
} else if (y <= 2.5e-58) {
tmp = t_0;
} else if (y <= 5.1e-33) {
tmp = t_1;
} else if (y <= 11000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 - ((1.0 - x) / y);
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) t_1 = y / (y + 1.0) tmp = 0 if y <= -2.2e+16: tmp = 1.0 + (x / y) elif y <= -3.2e-86: tmp = t_1 elif y <= 2.5e-58: tmp = t_0 elif y <= 5.1e-33: tmp = t_1 elif y <= 11000000000.0: tmp = t_0 else: tmp = 1.0 - ((1.0 - x) / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) t_1 = Float64(y / Float64(y + 1.0)) tmp = 0.0 if (y <= -2.2e+16) tmp = Float64(1.0 + Float64(x / y)); elseif (y <= -3.2e-86) tmp = t_1; elseif (y <= 2.5e-58) tmp = t_0; elseif (y <= 5.1e-33) tmp = t_1; elseif (y <= 11000000000.0) tmp = t_0; else tmp = Float64(1.0 - Float64(Float64(1.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + 1.0); t_1 = y / (y + 1.0); tmp = 0.0; if (y <= -2.2e+16) tmp = 1.0 + (x / y); elseif (y <= -3.2e-86) tmp = t_1; elseif (y <= 2.5e-58) tmp = t_0; elseif (y <= 5.1e-33) tmp = t_1; elseif (y <= 11000000000.0) tmp = t_0; else tmp = 1.0 - ((1.0 - x) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e+16], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.2e-86], t$95$1, If[LessEqual[y, 2.5e-58], t$95$0, If[LessEqual[y, 5.1e-33], t$95$1, If[LessEqual[y, 11000000000.0], t$95$0, N[(1.0 - N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
t_1 := \frac{y}{y + 1}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+16}:\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-33}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 11000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1 - x}{y}\\
\end{array}
\end{array}
if y < -2.2e16Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate--l+100.0%
+-commutative100.0%
associate--r-100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
if -2.2e16 < y < -3.20000000000000006e-86 or 2.49999999999999989e-58 < y < 5.10000000000000008e-33Initial program 99.9%
Taylor expanded in x around 0 76.0%
+-commutative76.0%
Simplified76.0%
if -3.20000000000000006e-86 < y < 2.49999999999999989e-58 or 5.10000000000000008e-33 < y < 1.1e10Initial program 100.0%
Taylor expanded in x around inf 82.1%
+-commutative82.1%
Simplified82.1%
if 1.1e10 < y Initial program 100.0%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
associate--r-99.9%
div-sub99.9%
Simplified99.9%
Final simplification88.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))))
(if (<= y -1.0)
1.0
(if (<= y -1.08e-88)
y
(if (<= y 5.5e-58)
t_0
(if (<= y 1.55e-35) y (if (<= y 5e+15) t_0 1.0)))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= -1.08e-88) {
tmp = y;
} else if (y <= 5.5e-58) {
tmp = t_0;
} else if (y <= 1.55e-35) {
tmp = y;
} else if (y <= 5e+15) {
tmp = t_0;
} else {
tmp = 1.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 = x / (y + 1.0d0)
if (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= (-1.08d-88)) then
tmp = y
else if (y <= 5.5d-58) then
tmp = t_0
else if (y <= 1.55d-35) then
tmp = y
else if (y <= 5d+15) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= -1.08e-88) {
tmp = y;
} else if (y <= 5.5e-58) {
tmp = t_0;
} else if (y <= 1.55e-35) {
tmp = y;
} else if (y <= 5e+15) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= -1.08e-88: tmp = y elif y <= 5.5e-58: tmp = t_0 elif y <= 1.55e-35: tmp = y elif y <= 5e+15: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= -1.08e-88) tmp = y; elseif (y <= 5.5e-58) tmp = t_0; elseif (y <= 1.55e-35) tmp = y; elseif (y <= 5e+15) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + 1.0); tmp = 0.0; if (y <= -1.0) tmp = 1.0; elseif (y <= -1.08e-88) tmp = y; elseif (y <= 5.5e-58) tmp = t_0; elseif (y <= 1.55e-35) tmp = y; elseif (y <= 5e+15) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, -1.08e-88], y, If[LessEqual[y, 5.5e-58], t$95$0, If[LessEqual[y, 1.55e-35], y, If[LessEqual[y, 5e+15], t$95$0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.08 \cdot 10^{-88}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{-35}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 5e15 < y Initial program 100.0%
Taylor expanded in y around inf 68.5%
if -1 < y < -1.07999999999999995e-88 or 5.49999999999999996e-58 < y < 1.55000000000000006e-35Initial program 99.9%
Taylor expanded in x around 0 72.8%
+-commutative72.8%
Simplified72.8%
Taylor expanded in y around 0 71.3%
if -1.07999999999999995e-88 < y < 5.49999999999999996e-58 or 1.55000000000000006e-35 < y < 5e15Initial program 100.0%
Taylor expanded in x around inf 81.6%
+-commutative81.6%
Simplified81.6%
Final simplification75.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))) (t_1 (+ 1.0 (/ x y))) (t_2 (/ y (+ y 1.0))))
(if (<= y -2.2e+16)
t_1
(if (<= y -3.2e-86)
t_2
(if (<= y 2.5e-58)
t_0
(if (<= y 7e-36) t_2 (if (<= y 11000000000.0) t_0 t_1)))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double t_1 = 1.0 + (x / y);
double t_2 = y / (y + 1.0);
double tmp;
if (y <= -2.2e+16) {
tmp = t_1;
} else if (y <= -3.2e-86) {
tmp = t_2;
} else if (y <= 2.5e-58) {
tmp = t_0;
} else if (y <= 7e-36) {
tmp = t_2;
} else if (y <= 11000000000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: tmp
t_0 = x / (y + 1.0d0)
t_1 = 1.0d0 + (x / y)
t_2 = y / (y + 1.0d0)
if (y <= (-2.2d+16)) then
tmp = t_1
else if (y <= (-3.2d-86)) then
tmp = t_2
else if (y <= 2.5d-58) then
tmp = t_0
else if (y <= 7d-36) then
tmp = t_2
else if (y <= 11000000000.0d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y + 1.0);
double t_1 = 1.0 + (x / y);
double t_2 = y / (y + 1.0);
double tmp;
if (y <= -2.2e+16) {
tmp = t_1;
} else if (y <= -3.2e-86) {
tmp = t_2;
} else if (y <= 2.5e-58) {
tmp = t_0;
} else if (y <= 7e-36) {
tmp = t_2;
} else if (y <= 11000000000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) t_1 = 1.0 + (x / y) t_2 = y / (y + 1.0) tmp = 0 if y <= -2.2e+16: tmp = t_1 elif y <= -3.2e-86: tmp = t_2 elif y <= 2.5e-58: tmp = t_0 elif y <= 7e-36: tmp = t_2 elif y <= 11000000000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) t_1 = Float64(1.0 + Float64(x / y)) t_2 = Float64(y / Float64(y + 1.0)) tmp = 0.0 if (y <= -2.2e+16) tmp = t_1; elseif (y <= -3.2e-86) tmp = t_2; elseif (y <= 2.5e-58) tmp = t_0; elseif (y <= 7e-36) tmp = t_2; elseif (y <= 11000000000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + 1.0); t_1 = 1.0 + (x / y); t_2 = y / (y + 1.0); tmp = 0.0; if (y <= -2.2e+16) tmp = t_1; elseif (y <= -3.2e-86) tmp = t_2; elseif (y <= 2.5e-58) tmp = t_0; elseif (y <= 7e-36) tmp = t_2; elseif (y <= 11000000000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e+16], t$95$1, If[LessEqual[y, -3.2e-86], t$95$2, If[LessEqual[y, 2.5e-58], t$95$0, If[LessEqual[y, 7e-36], t$95$2, If[LessEqual[y, 11000000000.0], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
t_1 := 1 + \frac{x}{y}\\
t_2 := \frac{y}{y + 1}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+16}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-36}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 11000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -2.2e16 or 1.1e10 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate--l+100.0%
+-commutative100.0%
associate--r-100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
neg-mul-199.8%
distribute-neg-frac99.8%
Simplified99.8%
if -2.2e16 < y < -3.20000000000000006e-86 or 2.49999999999999989e-58 < y < 6.9999999999999999e-36Initial program 99.9%
Taylor expanded in x around 0 76.0%
+-commutative76.0%
Simplified76.0%
if -3.20000000000000006e-86 < y < 2.49999999999999989e-58 or 6.9999999999999999e-36 < y < 1.1e10Initial program 100.0%
Taylor expanded in x around inf 82.1%
+-commutative82.1%
Simplified82.1%
Final simplification88.5%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
1.0
(if (<= y -3.2e-86)
y
(if (<= y 3.6e-59) x (if (<= y 6e-34) y (if (<= y 2.45e-5) x 1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= -3.2e-86) {
tmp = y;
} else if (y <= 3.6e-59) {
tmp = x;
} else if (y <= 6e-34) {
tmp = y;
} else if (y <= 2.45e-5) {
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 <= (-3.2d-86)) then
tmp = y
else if (y <= 3.6d-59) then
tmp = x
else if (y <= 6d-34) then
tmp = y
else if (y <= 2.45d-5) 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 <= -3.2e-86) {
tmp = y;
} else if (y <= 3.6e-59) {
tmp = x;
} else if (y <= 6e-34) {
tmp = y;
} else if (y <= 2.45e-5) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= -3.2e-86: tmp = y elif y <= 3.6e-59: tmp = x elif y <= 6e-34: tmp = y elif y <= 2.45e-5: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= -3.2e-86) tmp = y; elseif (y <= 3.6e-59) tmp = x; elseif (y <= 6e-34) tmp = y; elseif (y <= 2.45e-5) 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 <= -3.2e-86) tmp = y; elseif (y <= 3.6e-59) tmp = x; elseif (y <= 6e-34) tmp = y; elseif (y <= 2.45e-5) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, -3.2e-86], y, If[LessEqual[y, 3.6e-59], x, If[LessEqual[y, 6e-34], y, If[LessEqual[y, 2.45e-5], x, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-86}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-59}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-34}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 2.45e-5 < y Initial program 100.0%
Taylor expanded in y around inf 65.6%
if -1 < y < -3.20000000000000006e-86 or 3.6e-59 < y < 6e-34Initial program 99.9%
Taylor expanded in x around 0 72.8%
+-commutative72.8%
Simplified72.8%
Taylor expanded in y around 0 71.3%
if -3.20000000000000006e-86 < y < 3.6e-59 or 6e-34 < y < 2.45e-5Initial program 100.0%
Taylor expanded in y around 0 83.0%
Final simplification74.2%
(FPCore (x y) :precision binary64 (if (or (<= x -3.5e-34) (not (<= x 1.4e+15))) (/ x (+ y 1.0)) (/ y (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -3.5e-34) || !(x <= 1.4e+15)) {
tmp = x / (y + 1.0);
} else {
tmp = y / (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 ((x <= (-3.5d-34)) .or. (.not. (x <= 1.4d+15))) then
tmp = x / (y + 1.0d0)
else
tmp = y / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3.5e-34) || !(x <= 1.4e+15)) {
tmp = x / (y + 1.0);
} else {
tmp = y / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3.5e-34) or not (x <= 1.4e+15): tmp = x / (y + 1.0) else: tmp = y / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3.5e-34) || !(x <= 1.4e+15)) tmp = Float64(x / Float64(y + 1.0)); else tmp = Float64(y / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3.5e-34) || ~((x <= 1.4e+15))) tmp = x / (y + 1.0); else tmp = y / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3.5e-34], N[Not[LessEqual[x, 1.4e+15]], $MachinePrecision]], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-34} \lor \neg \left(x \leq 1.4 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + 1}\\
\end{array}
\end{array}
if x < -3.5e-34 or 1.4e15 < x Initial program 100.0%
Taylor expanded in x around inf 83.1%
+-commutative83.1%
Simplified83.1%
if -3.5e-34 < x < 1.4e15Initial program 100.0%
Taylor expanded in x around 0 74.2%
+-commutative74.2%
Simplified74.2%
Final simplification78.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 2.45e-5) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 2.45e-5) {
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 <= 2.45d-5) 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 <= 2.45e-5) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 2.45e-5: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 2.45e-5) 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 <= 2.45e-5) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 2.45e-5], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 2.45e-5 < y Initial program 100.0%
Taylor expanded in y around inf 65.6%
if -1 < y < 2.45e-5Initial program 100.0%
Taylor expanded in y around 0 73.7%
Final simplification70.1%
(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 31.3%
Final simplification31.3%
herbie shell --seed 2023308
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))