
(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%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -320000.0)
t_0
(if (<= y 5.5e-123)
t_1
(if (<= y 2.1e-79) (/ y (+ y 1.0)) (if (<= y 59.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + ((x + -1.0) / y);
double t_1 = x / (y + 1.0);
double tmp;
if (y <= -320000.0) {
tmp = t_0;
} else if (y <= 5.5e-123) {
tmp = t_1;
} else if (y <= 2.1e-79) {
tmp = y / (y + 1.0);
} else if (y <= 59.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 + (-1.0d0)) / y)
t_1 = x / (y + 1.0d0)
if (y <= (-320000.0d0)) then
tmp = t_0
else if (y <= 5.5d-123) then
tmp = t_1
else if (y <= 2.1d-79) then
tmp = y / (y + 1.0d0)
else if (y <= 59.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 + -1.0) / y);
double t_1 = x / (y + 1.0);
double tmp;
if (y <= -320000.0) {
tmp = t_0;
} else if (y <= 5.5e-123) {
tmp = t_1;
} else if (y <= 2.1e-79) {
tmp = y / (y + 1.0);
} else if (y <= 59.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x + -1.0) / y) t_1 = x / (y + 1.0) tmp = 0 if y <= -320000.0: tmp = t_0 elif y <= 5.5e-123: tmp = t_1 elif y <= 2.1e-79: tmp = y / (y + 1.0) elif y <= 59.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x + -1.0) / y)) t_1 = Float64(x / Float64(y + 1.0)) tmp = 0.0 if (y <= -320000.0) tmp = t_0; elseif (y <= 5.5e-123) tmp = t_1; elseif (y <= 2.1e-79) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 59.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x + -1.0) / y); t_1 = x / (y + 1.0); tmp = 0.0; if (y <= -320000.0) tmp = t_0; elseif (y <= 5.5e-123) tmp = t_1; elseif (y <= 2.1e-79) tmp = y / (y + 1.0); elseif (y <= 59.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -320000.0], t$95$0, If[LessEqual[y, 5.5e-123], t$95$1, If[LessEqual[y, 2.1e-79], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 59.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x + -1}{y}\\
t_1 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -320000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-79}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 59:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.2e5 or 59 < y Initial program 100.0%
Taylor expanded in y around inf 99.3%
associate--l+99.3%
div-sub99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
if -3.2e5 < y < 5.5e-123 or 2.0999999999999999e-79 < y < 59Initial program 99.9%
Taylor expanded in x around inf 75.3%
+-commutative75.3%
Simplified75.3%
if 5.5e-123 < y < 2.0999999999999999e-79Initial program 100.0%
Taylor expanded in x around 0 87.7%
+-commutative87.7%
Simplified87.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y 1.0))))
(if (<= y -3.5e+35)
1.0
(if (<= y 4.8e-123)
t_0
(if (<= y 1.3e-77) y (if (<= y 1.7e+43) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -3.5e+35) {
tmp = 1.0;
} else if (y <= 4.8e-123) {
tmp = t_0;
} else if (y <= 1.3e-77) {
tmp = y;
} else if (y <= 1.7e+43) {
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 <= (-3.5d+35)) then
tmp = 1.0d0
else if (y <= 4.8d-123) then
tmp = t_0
else if (y <= 1.3d-77) then
tmp = y
else if (y <= 1.7d+43) 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 <= -3.5e+35) {
tmp = 1.0;
} else if (y <= 4.8e-123) {
tmp = t_0;
} else if (y <= 1.3e-77) {
tmp = y;
} else if (y <= 1.7e+43) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -3.5e+35: tmp = 1.0 elif y <= 4.8e-123: tmp = t_0 elif y <= 1.3e-77: tmp = y elif y <= 1.7e+43: 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 <= -3.5e+35) tmp = 1.0; elseif (y <= 4.8e-123) tmp = t_0; elseif (y <= 1.3e-77) tmp = y; elseif (y <= 1.7e+43) 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 <= -3.5e+35) tmp = 1.0; elseif (y <= 4.8e-123) tmp = t_0; elseif (y <= 1.3e-77) tmp = y; elseif (y <= 1.7e+43) 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, -3.5e+35], 1.0, If[LessEqual[y, 4.8e-123], t$95$0, If[LessEqual[y, 1.3e-77], y, If[LessEqual[y, 1.7e+43], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-77}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.5000000000000001e35 or 1.70000000000000006e43 < y Initial program 100.0%
Taylor expanded in y around inf 81.1%
if -3.5000000000000001e35 < y < 4.8e-123 or 1.3000000000000001e-77 < y < 1.70000000000000006e43Initial program 99.9%
Taylor expanded in x around inf 71.6%
+-commutative71.6%
Simplified71.6%
if 4.8e-123 < y < 1.3000000000000001e-77Initial program 100.0%
Taylor expanded in x around 0 87.7%
+-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 87.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (- 1.0 y))))
(if (<= y -1.0)
1.0
(if (<= y 5.5e-123)
t_0
(if (<= y 1.18e-79) y (if (<= y 0.64) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x * (1.0 - y);
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 5.5e-123) {
tmp = t_0;
} else if (y <= 1.18e-79) {
tmp = y;
} else if (y <= 0.64) {
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 * (1.0d0 - y)
if (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 5.5d-123) then
tmp = t_0
else if (y <= 1.18d-79) then
tmp = y
else if (y <= 0.64d0) 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 * (1.0 - y);
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 5.5e-123) {
tmp = t_0;
} else if (y <= 1.18e-79) {
tmp = y;
} else if (y <= 0.64) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x * (1.0 - y) tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 5.5e-123: tmp = t_0 elif y <= 1.18e-79: tmp = y elif y <= 0.64: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x * Float64(1.0 - y)) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 5.5e-123) tmp = t_0; elseif (y <= 1.18e-79) tmp = y; elseif (y <= 0.64) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (1.0 - y); tmp = 0.0; if (y <= -1.0) tmp = 1.0; elseif (y <= 5.5e-123) tmp = t_0; elseif (y <= 1.18e-79) tmp = y; elseif (y <= 0.64) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 5.5e-123], t$95$0, If[LessEqual[y, 1.18e-79], y, If[LessEqual[y, 0.64], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y\right)\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{-79}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.64:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 0.640000000000000013 < y Initial program 100.0%
Taylor expanded in y around inf 74.0%
if -1 < y < 5.5e-123 or 1.18e-79 < y < 0.640000000000000013Initial program 99.9%
Taylor expanded in x around inf 75.1%
+-commutative75.1%
Simplified75.1%
Taylor expanded in y around 0 74.0%
+-commutative74.0%
remove-double-neg74.0%
mul-1-neg74.0%
distribute-neg-out74.0%
neg-mul-174.0%
*-commutative74.0%
distribute-lft-in74.0%
metadata-eval74.0%
sub-neg74.0%
distribute-rgt-neg-in74.0%
sub0-neg74.0%
associate-+l-74.0%
neg-sub074.0%
+-commutative74.0%
sub-neg74.0%
Simplified74.0%
if 5.5e-123 < y < 1.18e-79Initial program 100.0%
Taylor expanded in x around 0 87.7%
+-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 87.7%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 4.6e-128) x (if (<= y 8e-79) y (if (<= y 0.39) x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 4.6e-128) {
tmp = x;
} else if (y <= 8e-79) {
tmp = y;
} else if (y <= 0.39) {
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 <= 4.6d-128) then
tmp = x
else if (y <= 8d-79) then
tmp = y
else if (y <= 0.39d0) 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 <= 4.6e-128) {
tmp = x;
} else if (y <= 8e-79) {
tmp = y;
} else if (y <= 0.39) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 4.6e-128: tmp = x elif y <= 8e-79: tmp = y elif y <= 0.39: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 4.6e-128) tmp = x; elseif (y <= 8e-79) tmp = y; elseif (y <= 0.39) 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 <= 4.6e-128) tmp = x; elseif (y <= 8e-79) tmp = y; elseif (y <= 0.39) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 4.6e-128], x, If[LessEqual[y, 8e-79], y, If[LessEqual[y, 0.39], x, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-128}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-79}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.39:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 0.39000000000000001 < y Initial program 100.0%
Taylor expanded in y around inf 74.0%
if -1 < y < 4.6000000000000002e-128 or 8e-79 < y < 0.39000000000000001Initial program 99.9%
Taylor expanded in y around 0 71.5%
if 4.6000000000000002e-128 < y < 8e-79Initial program 100.0%
Taylor expanded in x around 0 87.7%
+-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 87.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ 1.0 (/ (+ x -1.0) y)) (+ x (* y (- 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + (y * (1.0 - 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 = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x + (y * (1.0d0 - 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 = 1.0 + ((x + -1.0) / y);
} else {
tmp = x + (y * (1.0 - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = 1.0 + ((x + -1.0) / y) else: tmp = x + (y * (1.0 - x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(1.0 + Float64(Float64(x + -1.0) / y)); else tmp = Float64(x + Float64(y * Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = 1.0 + ((x + -1.0) / y); else tmp = x + (y * (1.0 - x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;1 + \frac{x + -1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 98.9%
associate--l+98.9%
div-sub98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
if -1 < y < 1Initial program 99.9%
Taylor expanded in y around 0 97.4%
Final simplification98.1%
(FPCore (x y) :precision binary64 (if (or (<= x -4.6e-46) (not (<= x 1.75e-44))) (/ x (+ y 1.0)) (/ y (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4.6e-46) || !(x <= 1.75e-44)) {
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 <= (-4.6d-46)) .or. (.not. (x <= 1.75d-44))) 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 <= -4.6e-46) || !(x <= 1.75e-44)) {
tmp = x / (y + 1.0);
} else {
tmp = y / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4.6e-46) or not (x <= 1.75e-44): tmp = x / (y + 1.0) else: tmp = y / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4.6e-46) || !(x <= 1.75e-44)) 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 <= -4.6e-46) || ~((x <= 1.75e-44))) tmp = x / (y + 1.0); else tmp = y / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4.6e-46], N[Not[LessEqual[x, 1.75e-44]], $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 -4.6 \cdot 10^{-46} \lor \neg \left(x \leq 1.75 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + 1}\\
\end{array}
\end{array}
if x < -4.5999999999999998e-46 or 1.7499999999999999e-44 < x Initial program 99.9%
Taylor expanded in x around inf 74.2%
+-commutative74.2%
Simplified74.2%
if -4.5999999999999998e-46 < x < 1.7499999999999999e-44Initial program 100.0%
Taylor expanded in x around 0 87.4%
+-commutative87.4%
Simplified87.4%
Final simplification80.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 2.4) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 2.4) {
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.4d0) 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.4) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 2.4: 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.4) 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.4) 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.4], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.4:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 2.39999999999999991 < y Initial program 100.0%
Taylor expanded in y around inf 74.0%
if -1 < y < 2.39999999999999991Initial program 99.9%
Taylor expanded in y around 0 68.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 100.0%
Taylor expanded in y around inf 40.8%
herbie shell --seed 2024108
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))