
(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))))
(if (<= y -1.1e+77)
1.0
(if (<= y -1.26e-33)
t_0
(if (<= y -1.95e-94)
y
(if (<= y 1.3e-57)
t_0
(if (<= y 1.16e-10) y (if (<= y 1.12e+79) t_0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -1.1e+77) {
tmp = 1.0;
} else if (y <= -1.26e-33) {
tmp = t_0;
} else if (y <= -1.95e-94) {
tmp = y;
} else if (y <= 1.3e-57) {
tmp = t_0;
} else if (y <= 1.16e-10) {
tmp = y;
} else if (y <= 1.12e+79) {
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.1d+77)) then
tmp = 1.0d0
else if (y <= (-1.26d-33)) then
tmp = t_0
else if (y <= (-1.95d-94)) then
tmp = y
else if (y <= 1.3d-57) then
tmp = t_0
else if (y <= 1.16d-10) then
tmp = y
else if (y <= 1.12d+79) 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.1e+77) {
tmp = 1.0;
} else if (y <= -1.26e-33) {
tmp = t_0;
} else if (y <= -1.95e-94) {
tmp = y;
} else if (y <= 1.3e-57) {
tmp = t_0;
} else if (y <= 1.16e-10) {
tmp = y;
} else if (y <= 1.12e+79) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -1.1e+77: tmp = 1.0 elif y <= -1.26e-33: tmp = t_0 elif y <= -1.95e-94: tmp = y elif y <= 1.3e-57: tmp = t_0 elif y <= 1.16e-10: tmp = y elif y <= 1.12e+79: 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.1e+77) tmp = 1.0; elseif (y <= -1.26e-33) tmp = t_0; elseif (y <= -1.95e-94) tmp = y; elseif (y <= 1.3e-57) tmp = t_0; elseif (y <= 1.16e-10) tmp = y; elseif (y <= 1.12e+79) 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.1e+77) tmp = 1.0; elseif (y <= -1.26e-33) tmp = t_0; elseif (y <= -1.95e-94) tmp = y; elseif (y <= 1.3e-57) tmp = t_0; elseif (y <= 1.16e-10) tmp = y; elseif (y <= 1.12e+79) 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.1e+77], 1.0, If[LessEqual[y, -1.26e-33], t$95$0, If[LessEqual[y, -1.95e-94], y, If[LessEqual[y, 1.3e-57], t$95$0, If[LessEqual[y, 1.16e-10], y, If[LessEqual[y, 1.12e+79], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -1.1 \cdot 10^{+77}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.26 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-94}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{-10}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+79}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.1e77 or 1.12e79 < y Initial program 100.0%
Taylor expanded in y around inf 85.0%
if -1.1e77 < y < -1.26000000000000005e-33 or -1.9500000000000001e-94 < y < 1.29999999999999993e-57 or 1.16e-10 < y < 1.12e79Initial program 100.0%
Taylor expanded in x around inf 82.6%
+-commutative82.6%
Simplified82.6%
if -1.26000000000000005e-33 < y < -1.9500000000000001e-94 or 1.29999999999999993e-57 < y < 1.16e-10Initial program 100.0%
Taylor expanded in x around 0 70.0%
+-commutative70.0%
Simplified70.0%
Taylor expanded in y around 0 68.6%
Final simplification82.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))))
(if (<= y -5.4e+76)
1.0
(if (<= y -1.42e-33)
t_0
(if (<= y -2.15e-94)
y
(if (<= y 1.3e-55)
t_0
(if (<= y 1.3e-9)
(/ y (+ y 1.0))
(if (<= y 1.22e+79) t_0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -5.4e+76) {
tmp = 1.0;
} else if (y <= -1.42e-33) {
tmp = t_0;
} else if (y <= -2.15e-94) {
tmp = y;
} else if (y <= 1.3e-55) {
tmp = t_0;
} else if (y <= 1.3e-9) {
tmp = y / (y + 1.0);
} else if (y <= 1.22e+79) {
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 <= (-5.4d+76)) then
tmp = 1.0d0
else if (y <= (-1.42d-33)) then
tmp = t_0
else if (y <= (-2.15d-94)) then
tmp = y
else if (y <= 1.3d-55) then
tmp = t_0
else if (y <= 1.3d-9) then
tmp = y / (y + 1.0d0)
else if (y <= 1.22d+79) 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 <= -5.4e+76) {
tmp = 1.0;
} else if (y <= -1.42e-33) {
tmp = t_0;
} else if (y <= -2.15e-94) {
tmp = y;
} else if (y <= 1.3e-55) {
tmp = t_0;
} else if (y <= 1.3e-9) {
tmp = y / (y + 1.0);
} else if (y <= 1.22e+79) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -5.4e+76: tmp = 1.0 elif y <= -1.42e-33: tmp = t_0 elif y <= -2.15e-94: tmp = y elif y <= 1.3e-55: tmp = t_0 elif y <= 1.3e-9: tmp = y / (y + 1.0) elif y <= 1.22e+79: 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 <= -5.4e+76) tmp = 1.0; elseif (y <= -1.42e-33) tmp = t_0; elseif (y <= -2.15e-94) tmp = y; elseif (y <= 1.3e-55) tmp = t_0; elseif (y <= 1.3e-9) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 1.22e+79) 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 <= -5.4e+76) tmp = 1.0; elseif (y <= -1.42e-33) tmp = t_0; elseif (y <= -2.15e-94) tmp = y; elseif (y <= 1.3e-55) tmp = t_0; elseif (y <= 1.3e-9) tmp = y / (y + 1.0); elseif (y <= 1.22e+79) 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, -5.4e+76], 1.0, If[LessEqual[y, -1.42e-33], t$95$0, If[LessEqual[y, -2.15e-94], y, If[LessEqual[y, 1.3e-55], t$95$0, If[LessEqual[y, 1.3e-9], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.22e+79], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -5.4 \cdot 10^{+76}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.42 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.15 \cdot 10^{-94}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-9}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{+79}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.3999999999999998e76 or 1.22000000000000002e79 < y Initial program 100.0%
Taylor expanded in y around inf 85.0%
if -5.3999999999999998e76 < y < -1.42000000000000007e-33 or -2.1499999999999999e-94 < y < 1.2999999999999999e-55 or 1.3000000000000001e-9 < y < 1.22000000000000002e79Initial program 100.0%
Taylor expanded in x around inf 82.6%
+-commutative82.6%
Simplified82.6%
if -1.42000000000000007e-33 < y < -2.1499999999999999e-94Initial program 100.0%
Taylor expanded in x around 0 70.6%
+-commutative70.6%
Simplified70.6%
Taylor expanded in y around 0 70.6%
if 1.2999999999999999e-55 < y < 1.3000000000000001e-9Initial program 100.0%
Taylor expanded in x around 0 69.3%
+-commutative69.3%
Simplified69.3%
Final simplification82.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))))
(if (<= y -1900000.0)
(+ 1.0 (/ x y))
(if (<= y 4.2e-56)
t_0
(if (<= y 1.1e-8)
(/ y (+ y 1.0))
(if (<= y 10200000000000.0) t_0 (+ 1.0 (/ (+ x -1.0) y))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -1900000.0) {
tmp = 1.0 + (x / y);
} else if (y <= 4.2e-56) {
tmp = t_0;
} else if (y <= 1.1e-8) {
tmp = y / (y + 1.0);
} else if (y <= 10200000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 + ((x + -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) :: tmp
t_0 = x / (y + 1.0d0)
if (y <= (-1900000.0d0)) then
tmp = 1.0d0 + (x / y)
else if (y <= 4.2d-56) then
tmp = t_0
else if (y <= 1.1d-8) then
tmp = y / (y + 1.0d0)
else if (y <= 10200000000000.0d0) then
tmp = t_0
else
tmp = 1.0d0 + ((x + (-1.0d0)) / 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 <= -1900000.0) {
tmp = 1.0 + (x / y);
} else if (y <= 4.2e-56) {
tmp = t_0;
} else if (y <= 1.1e-8) {
tmp = y / (y + 1.0);
} else if (y <= 10200000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 + ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -1900000.0: tmp = 1.0 + (x / y) elif y <= 4.2e-56: tmp = t_0 elif y <= 1.1e-8: tmp = y / (y + 1.0) elif y <= 10200000000000.0: tmp = t_0 else: tmp = 1.0 + ((x + -1.0) / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(y + 1.0)) tmp = 0.0 if (y <= -1900000.0) tmp = Float64(1.0 + Float64(x / y)); elseif (y <= 4.2e-56) tmp = t_0; elseif (y <= 1.1e-8) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 10200000000000.0) tmp = t_0; else tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y + 1.0); tmp = 0.0; if (y <= -1900000.0) tmp = 1.0 + (x / y); elseif (y <= 4.2e-56) tmp = t_0; elseif (y <= 1.1e-8) tmp = y / (y + 1.0); elseif (y <= 10200000000000.0) tmp = t_0; else tmp = 1.0 + ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1900000.0], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2e-56], t$95$0, If[LessEqual[y, 1.1e-8], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 10200000000000.0], t$95$0, N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -1900000:\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-8}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 10200000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\end{array}
\end{array}
if y < -1.9e6Initial 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%
distribute-neg-frac100.0%
Simplified100.0%
if -1.9e6 < y < 4.20000000000000012e-56 or 1.0999999999999999e-8 < y < 1.02e13Initial program 100.0%
Taylor expanded in x around inf 83.0%
+-commutative83.0%
Simplified83.0%
if 4.20000000000000012e-56 < y < 1.0999999999999999e-8Initial program 100.0%
Taylor expanded in x around 0 69.3%
+-commutative69.3%
Simplified69.3%
if 1.02e13 < 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%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -850.0)
t_0
(if (<= y 1.35e-55)
t_1
(if (<= y 1.7e-10)
(/ y (+ y 1.0))
(if (<= y 10200000000000.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 <= -850.0) {
tmp = t_0;
} else if (y <= 1.35e-55) {
tmp = t_1;
} else if (y <= 1.7e-10) {
tmp = y / (y + 1.0);
} else if (y <= 10200000000000.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 <= (-850.0d0)) then
tmp = t_0
else if (y <= 1.35d-55) then
tmp = t_1
else if (y <= 1.7d-10) then
tmp = y / (y + 1.0d0)
else if (y <= 10200000000000.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 <= -850.0) {
tmp = t_0;
} else if (y <= 1.35e-55) {
tmp = t_1;
} else if (y <= 1.7e-10) {
tmp = y / (y + 1.0);
} else if (y <= 10200000000000.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 <= -850.0: tmp = t_0 elif y <= 1.35e-55: tmp = t_1 elif y <= 1.7e-10: tmp = y / (y + 1.0) elif y <= 10200000000000.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 <= -850.0) tmp = t_0; elseif (y <= 1.35e-55) tmp = t_1; elseif (y <= 1.7e-10) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 10200000000000.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 <= -850.0) tmp = t_0; elseif (y <= 1.35e-55) tmp = t_1; elseif (y <= 1.7e-10) tmp = y / (y + 1.0); elseif (y <= 10200000000000.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, -850.0], t$95$0, If[LessEqual[y, 1.35e-55], t$95$1, If[LessEqual[y, 1.7e-10], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 10200000000000.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 -850:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-55}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 10200000000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -850 or 1.02e13 < 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 99.9%
neg-mul-199.9%
distribute-neg-frac99.9%
Simplified99.9%
if -850 < y < 1.35000000000000002e-55 or 1.70000000000000007e-10 < y < 1.02e13Initial program 100.0%
Taylor expanded in x around inf 83.0%
+-commutative83.0%
Simplified83.0%
if 1.35000000000000002e-55 < y < 1.70000000000000007e-10Initial program 100.0%
Taylor expanded in x around 0 69.3%
+-commutative69.3%
Simplified69.3%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
1.0
(if (<= y 1e-55)
x
(if (<= y 3.1e-8) y (if (<= y 10200000000000.0) x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1e-55) {
tmp = x;
} else if (y <= 3.1e-8) {
tmp = y;
} else if (y <= 10200000000000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 1d-55) then
tmp = x
else if (y <= 3.1d-8) then
tmp = y
else if (y <= 10200000000000.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1e-55) {
tmp = x;
} else if (y <= 3.1e-8) {
tmp = y;
} else if (y <= 10200000000000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 1e-55: tmp = x elif y <= 3.1e-8: tmp = y elif y <= 10200000000000.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 1e-55) tmp = x; elseif (y <= 3.1e-8) tmp = y; elseif (y <= 10200000000000.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = 1.0; elseif (y <= 1e-55) tmp = x; elseif (y <= 3.1e-8) tmp = y; elseif (y <= 10200000000000.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 1e-55], x, If[LessEqual[y, 3.1e-8], y, If[LessEqual[y, 10200000000000.0], x, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{-55}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-8}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 10200000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 1.02e13 < y Initial program 100.0%
Taylor expanded in y around inf 73.9%
if -1 < y < 9.99999999999999995e-56 or 3.1e-8 < y < 1.02e13Initial program 100.0%
Taylor expanded in y around 0 79.8%
if 9.99999999999999995e-56 < y < 3.1e-8Initial program 100.0%
Taylor expanded in x around 0 69.3%
+-commutative69.3%
Simplified69.3%
Taylor expanded in y around 0 66.2%
Final simplification76.5%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 10200000000000.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 10200000000000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 10200000000000.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 10200000000000.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 10200000000000.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 10200000000000.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = 1.0; elseif (y <= 10200000000000.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 10200000000000.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10200000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 1.02e13 < y Initial program 100.0%
Taylor expanded in y around inf 73.9%
if -1 < y < 1.02e13Initial program 100.0%
Taylor expanded in y around 0 75.7%
Final simplification74.8%
(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.2%
Final simplification37.2%
herbie shell --seed 2023271
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))