
(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 9 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))))
(if (<= y -4.4e+14)
1.0
(if (<= y -2.1e-75)
t_0
(if (<= y -4.4e-135)
y
(if (<= y 1.2e-61)
t_0
(if (<= y 6.5e-50)
y
(if (<= y 2.1e+50)
t_0
(if (<= y 2.6e+128)
1.0
(if (<= y 5.7e+177) (/ x y) 1.0))))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -4.4e+14) {
tmp = 1.0;
} else if (y <= -2.1e-75) {
tmp = t_0;
} else if (y <= -4.4e-135) {
tmp = y;
} else if (y <= 1.2e-61) {
tmp = t_0;
} else if (y <= 6.5e-50) {
tmp = y;
} else if (y <= 2.1e+50) {
tmp = t_0;
} else if (y <= 2.6e+128) {
tmp = 1.0;
} else if (y <= 5.7e+177) {
tmp = x / y;
} 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 <= (-4.4d+14)) then
tmp = 1.0d0
else if (y <= (-2.1d-75)) then
tmp = t_0
else if (y <= (-4.4d-135)) then
tmp = y
else if (y <= 1.2d-61) then
tmp = t_0
else if (y <= 6.5d-50) then
tmp = y
else if (y <= 2.1d+50) then
tmp = t_0
else if (y <= 2.6d+128) then
tmp = 1.0d0
else if (y <= 5.7d+177) then
tmp = x / y
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 <= -4.4e+14) {
tmp = 1.0;
} else if (y <= -2.1e-75) {
tmp = t_0;
} else if (y <= -4.4e-135) {
tmp = y;
} else if (y <= 1.2e-61) {
tmp = t_0;
} else if (y <= 6.5e-50) {
tmp = y;
} else if (y <= 2.1e+50) {
tmp = t_0;
} else if (y <= 2.6e+128) {
tmp = 1.0;
} else if (y <= 5.7e+177) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -4.4e+14: tmp = 1.0 elif y <= -2.1e-75: tmp = t_0 elif y <= -4.4e-135: tmp = y elif y <= 1.2e-61: tmp = t_0 elif y <= 6.5e-50: tmp = y elif y <= 2.1e+50: tmp = t_0 elif y <= 2.6e+128: tmp = 1.0 elif y <= 5.7e+177: tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) tmp = 0.0 if (y <= -4.4e+14) tmp = 1.0; elseif (y <= -2.1e-75) tmp = t_0; elseif (y <= -4.4e-135) tmp = y; elseif (y <= 1.2e-61) tmp = t_0; elseif (y <= 6.5e-50) tmp = y; elseif (y <= 2.1e+50) tmp = t_0; elseif (y <= 2.6e+128) tmp = 1.0; elseif (y <= 5.7e+177) tmp = Float64(x / y); 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 <= -4.4e+14) tmp = 1.0; elseif (y <= -2.1e-75) tmp = t_0; elseif (y <= -4.4e-135) tmp = y; elseif (y <= 1.2e-61) tmp = t_0; elseif (y <= 6.5e-50) tmp = y; elseif (y <= 2.1e+50) tmp = t_0; elseif (y <= 2.6e+128) tmp = 1.0; elseif (y <= 5.7e+177) tmp = x / y; 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, -4.4e+14], 1.0, If[LessEqual[y, -2.1e-75], t$95$0, If[LessEqual[y, -4.4e-135], y, If[LessEqual[y, 1.2e-61], t$95$0, If[LessEqual[y, 6.5e-50], y, If[LessEqual[y, 2.1e+50], t$95$0, If[LessEqual[y, 2.6e+128], 1.0, If[LessEqual[y, 5.7e+177], N[(x / y), $MachinePrecision], 1.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -4.4 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-135}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-50}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+50}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+128}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{+177}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.4e14 or 2.1e50 < y < 2.6e128 or 5.70000000000000015e177 < y Initial program 100.0%
Taylor expanded in y around inf 79.2%
if -4.4e14 < y < -2.1000000000000001e-75 or -4.3999999999999999e-135 < y < 1.2e-61 or 6.49999999999999987e-50 < y < 2.1e50Initial program 100.0%
Taylor expanded in x around inf 80.3%
+-commutative80.3%
Simplified80.3%
if -2.1000000000000001e-75 < y < -4.3999999999999999e-135 or 1.2e-61 < y < 6.49999999999999987e-50Initial program 100.0%
Taylor expanded in x around 0 77.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in y around 0 77.0%
if 2.6e128 < y < 5.70000000000000015e177Initial program 100.0%
Taylor expanded in x around inf 70.4%
+-commutative70.4%
Simplified70.4%
Taylor expanded in y around inf 70.4%
Final simplification79.1%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
1.0
(if (<= y 3.6e-63)
x
(if (<= y 9.6e-50)
y
(if (<= y 7e-8)
x
(if (<= y 1.6e+49)
(/ x y)
(if (<= y 5.4e+128) 1.0 (if (<= y 5.7e+177) (/ x y) 1.0))))))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.6e-63) {
tmp = x;
} else if (y <= 9.6e-50) {
tmp = y;
} else if (y <= 7e-8) {
tmp = x;
} else if (y <= 1.6e+49) {
tmp = x / y;
} else if (y <= 5.4e+128) {
tmp = 1.0;
} else if (y <= 5.7e+177) {
tmp = x / y;
} 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.6d-63) then
tmp = x
else if (y <= 9.6d-50) then
tmp = y
else if (y <= 7d-8) then
tmp = x
else if (y <= 1.6d+49) then
tmp = x / y
else if (y <= 5.4d+128) then
tmp = 1.0d0
else if (y <= 5.7d+177) then
tmp = x / y
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.6e-63) {
tmp = x;
} else if (y <= 9.6e-50) {
tmp = y;
} else if (y <= 7e-8) {
tmp = x;
} else if (y <= 1.6e+49) {
tmp = x / y;
} else if (y <= 5.4e+128) {
tmp = 1.0;
} else if (y <= 5.7e+177) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 3.6e-63: tmp = x elif y <= 9.6e-50: tmp = y elif y <= 7e-8: tmp = x elif y <= 1.6e+49: tmp = x / y elif y <= 5.4e+128: tmp = 1.0 elif y <= 5.7e+177: tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 3.6e-63) tmp = x; elseif (y <= 9.6e-50) tmp = y; elseif (y <= 7e-8) tmp = x; elseif (y <= 1.6e+49) tmp = Float64(x / y); elseif (y <= 5.4e+128) tmp = 1.0; elseif (y <= 5.7e+177) tmp = Float64(x / y); 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.6e-63) tmp = x; elseif (y <= 9.6e-50) tmp = y; elseif (y <= 7e-8) tmp = x; elseif (y <= 1.6e+49) tmp = x / y; elseif (y <= 5.4e+128) tmp = 1.0; elseif (y <= 5.7e+177) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 3.6e-63], x, If[LessEqual[y, 9.6e-50], y, If[LessEqual[y, 7e-8], x, If[LessEqual[y, 1.6e+49], N[(x / y), $MachinePrecision], If[LessEqual[y, 5.4e+128], 1.0, If[LessEqual[y, 5.7e+177], N[(x / y), $MachinePrecision], 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-63}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{-50}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-8}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+49}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+128}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{+177}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 1.60000000000000007e49 < y < 5.40000000000000002e128 or 5.70000000000000015e177 < y Initial program 100.0%
Taylor expanded in y around inf 75.7%
if -1 < y < 3.60000000000000008e-63 or 9.60000000000000007e-50 < y < 7.00000000000000048e-8Initial program 100.0%
Taylor expanded in y around 0 74.4%
if 3.60000000000000008e-63 < y < 9.60000000000000007e-50Initial program 100.0%
Taylor expanded in x around 0 90.4%
+-commutative90.4%
Simplified90.4%
Taylor expanded in y around 0 90.4%
if 7.00000000000000048e-8 < y < 1.60000000000000007e49 or 5.40000000000000002e128 < y < 5.70000000000000015e177Initial program 99.9%
Taylor expanded in x around inf 73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in y around inf 72.2%
Final simplification75.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))))
(if (<= x -5.1e-9)
t_0
(if (<= x 1.32e-27)
(/ y (+ y 1.0))
(if (<= x 1.2e+14) x (if (<= x 2.4e+68) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (x <= -5.1e-9) {
tmp = t_0;
} else if (x <= 1.32e-27) {
tmp = y / (y + 1.0);
} else if (x <= 1.2e+14) {
tmp = x;
} else if (x <= 2.4e+68) {
tmp = 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 = x / (y + 1.0d0)
if (x <= (-5.1d-9)) then
tmp = t_0
else if (x <= 1.32d-27) then
tmp = y / (y + 1.0d0)
else if (x <= 1.2d+14) then
tmp = x
else if (x <= 2.4d+68) then
tmp = 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (x <= -5.1e-9) {
tmp = t_0;
} else if (x <= 1.32e-27) {
tmp = y / (y + 1.0);
} else if (x <= 1.2e+14) {
tmp = x;
} else if (x <= 2.4e+68) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if x <= -5.1e-9: tmp = t_0 elif x <= 1.32e-27: tmp = y / (y + 1.0) elif x <= 1.2e+14: tmp = x elif x <= 2.4e+68: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) tmp = 0.0 if (x <= -5.1e-9) tmp = t_0; elseif (x <= 1.32e-27) tmp = Float64(y / Float64(y + 1.0)); elseif (x <= 1.2e+14) tmp = x; elseif (x <= 2.4e+68) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + 1.0); tmp = 0.0; if (x <= -5.1e-9) tmp = t_0; elseif (x <= 1.32e-27) tmp = y / (y + 1.0); elseif (x <= 1.2e+14) tmp = x; elseif (x <= 2.4e+68) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.1e-9], t$95$0, If[LessEqual[x, 1.32e-27], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e+14], x, If[LessEqual[x, 2.4e+68], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;x \leq -5.1 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{-27}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+14}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -5.10000000000000017e-9 or 2.40000000000000008e68 < x Initial program 100.0%
Taylor expanded in x around inf 80.6%
+-commutative80.6%
Simplified80.6%
if -5.10000000000000017e-9 < x < 1.3200000000000001e-27Initial program 100.0%
Taylor expanded in x around 0 82.9%
+-commutative82.9%
Simplified82.9%
if 1.3200000000000001e-27 < x < 1.2e14Initial program 100.0%
Taylor expanded in y around 0 85.0%
if 1.2e14 < x < 2.40000000000000008e68Initial program 100.0%
Taylor expanded in y around inf 69.2%
Final simplification81.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -950000000.0)
t_0
(if (<= y 1.2e-61)
t_1
(if (<= y 6.8e-50) y (if (<= y 62000000000000.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = x / (y + 1.0);
double tmp;
if (y <= -950000000.0) {
tmp = t_0;
} else if (y <= 1.2e-61) {
tmp = t_1;
} else if (y <= 6.8e-50) {
tmp = y;
} else if (y <= 62000000000000.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 / (y + 1.0d0)
if (y <= (-950000000.0d0)) then
tmp = t_0
else if (y <= 1.2d-61) then
tmp = t_1
else if (y <= 6.8d-50) then
tmp = y
else if (y <= 62000000000000.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 / (y + 1.0);
double tmp;
if (y <= -950000000.0) {
tmp = t_0;
} else if (y <= 1.2e-61) {
tmp = t_1;
} else if (y <= 6.8e-50) {
tmp = y;
} else if (y <= 62000000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = x / (y + 1.0) tmp = 0 if y <= -950000000.0: tmp = t_0 elif y <= 1.2e-61: tmp = t_1 elif y <= 6.8e-50: tmp = y elif y <= 62000000000000.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(y + 1.0)) tmp = 0.0 if (y <= -950000000.0) tmp = t_0; elseif (y <= 1.2e-61) tmp = t_1; elseif (y <= 6.8e-50) tmp = y; elseif (y <= 62000000000000.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 / (y + 1.0); tmp = 0.0; if (y <= -950000000.0) tmp = t_0; elseif (y <= 1.2e-61) tmp = t_1; elseif (y <= 6.8e-50) tmp = y; elseif (y <= 62000000000000.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[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -950000000.0], t$95$0, If[LessEqual[y, 1.2e-61], t$95$1, If[LessEqual[y, 6.8e-50], y, If[LessEqual[y, 62000000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -950000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-50}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 62000000000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -9.5e8 or 6.2e13 < y Initial program 100.0%
Taylor expanded in y around -inf 99.7%
mul-1-neg99.7%
unsub-neg99.7%
mul-1-neg99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in x around inf 99.4%
neg-mul-199.4%
Simplified99.4%
if -9.5e8 < y < 1.2e-61 or 6.80000000000000029e-50 < y < 6.2e13Initial program 100.0%
Taylor expanded in x around inf 75.8%
+-commutative75.8%
Simplified75.8%
if 1.2e-61 < y < 6.80000000000000029e-50Initial program 100.0%
Taylor expanded in x around 0 90.4%
+-commutative90.4%
Simplified90.4%
Taylor expanded in y around 0 90.4%
Final simplification87.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))))
(if (<= y -470000000.0)
(+ 1.0 (/ (+ x -1.0) y))
(if (<= y 1.2e-61)
t_0
(if (<= y 6.5e-50)
y
(if (<= y 62000000000000.0) t_0 (+ 1.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -470000000.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (y <= 1.2e-61) {
tmp = t_0;
} else if (y <= 6.5e-50) {
tmp = y;
} else if (y <= 62000000000000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x / (y + 1.0d0)
if (y <= (-470000000.0d0)) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else if (y <= 1.2d-61) then
tmp = t_0
else if (y <= 6.5d-50) then
tmp = y
else if (y <= 62000000000000.0d0) then
tmp = t_0
else
tmp = 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 tmp;
if (y <= -470000000.0) {
tmp = 1.0 + ((x + -1.0) / y);
} else if (y <= 1.2e-61) {
tmp = t_0;
} else if (y <= 6.5e-50) {
tmp = y;
} else if (y <= 62000000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 + (x / y);
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -470000000.0: tmp = 1.0 + ((x + -1.0) / y) elif y <= 1.2e-61: tmp = t_0 elif y <= 6.5e-50: tmp = y elif y <= 62000000000000.0: tmp = t_0 else: tmp = 1.0 + (x / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) tmp = 0.0 if (y <= -470000000.0) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); elseif (y <= 1.2e-61) tmp = t_0; elseif (y <= 6.5e-50) tmp = y; elseif (y <= 62000000000000.0) tmp = t_0; else tmp = Float64(1.0 + Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + 1.0); tmp = 0.0; if (y <= -470000000.0) tmp = 1.0 + ((x + -1.0) / y); elseif (y <= 1.2e-61) tmp = t_0; elseif (y <= 6.5e-50) tmp = y; elseif (y <= 62000000000000.0) tmp = t_0; else tmp = 1.0 + (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -470000000.0], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e-61], t$95$0, If[LessEqual[y, 6.5e-50], y, If[LessEqual[y, 62000000000000.0], t$95$0, N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -470000000:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-50}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 62000000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y}\\
\end{array}
\end{array}
if y < -4.7e8Initial program 100.0%
Taylor expanded in y around -inf 99.5%
mul-1-neg99.5%
unsub-neg99.5%
mul-1-neg99.5%
sub-neg99.5%
Simplified99.5%
if -4.7e8 < y < 1.2e-61 or 6.49999999999999987e-50 < y < 6.2e13Initial program 100.0%
Taylor expanded in x around inf 75.8%
+-commutative75.8%
Simplified75.8%
if 1.2e-61 < y < 6.49999999999999987e-50Initial program 100.0%
Taylor expanded in x around 0 90.4%
+-commutative90.4%
Simplified90.4%
Taylor expanded in y around 0 90.4%
if 6.2e13 < y Initial program 100.0%
Taylor expanded in y around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification88.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 1.2e-61) x (if (<= y 6.5e-50) y (if (<= y 3.8e+32) x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1.2e-61) {
tmp = x;
} else if (y <= 6.5e-50) {
tmp = y;
} else if (y <= 3.8e+32) {
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.2d-61) then
tmp = x
else if (y <= 6.5d-50) then
tmp = y
else if (y <= 3.8d+32) 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.2e-61) {
tmp = x;
} else if (y <= 6.5e-50) {
tmp = y;
} else if (y <= 3.8e+32) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 1.2e-61: tmp = x elif y <= 6.5e-50: tmp = y elif y <= 3.8e+32: 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.2e-61) tmp = x; elseif (y <= 6.5e-50) tmp = y; elseif (y <= 3.8e+32) 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.2e-61) tmp = x; elseif (y <= 6.5e-50) tmp = y; elseif (y <= 3.8e+32) 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.2e-61], x, If[LessEqual[y, 6.5e-50], y, If[LessEqual[y, 3.8e+32], x, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-50}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+32}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 3.8000000000000003e32 < y Initial program 100.0%
Taylor expanded in y around inf 70.4%
if -1 < y < 1.2e-61 or 6.49999999999999987e-50 < y < 3.8000000000000003e32Initial program 100.0%
Taylor expanded in y around 0 71.2%
if 1.2e-61 < y < 6.49999999999999987e-50Initial program 100.0%
Taylor expanded in x around 0 90.4%
+-commutative90.4%
Simplified90.4%
Taylor expanded in y around 0 90.4%
Final simplification71.2%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 3.8e+32) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.8e+32) {
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.8d+32) 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.8e+32) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 3.8e+32: 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.8e+32) 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.8e+32) 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.8e+32], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+32}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 3.8000000000000003e32 < y Initial program 100.0%
Taylor expanded in y around inf 70.4%
if -1 < y < 3.8000000000000003e32Initial program 100.0%
Taylor expanded in y around 0 68.6%
Final simplification69.5%
(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 37.0%
Final simplification37.0%
herbie shell --seed 2023195
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))