
(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 10 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
(if (<= y -4.4e+82)
1.0
(if (<= y -3.7e+52)
(/ x y)
(if (<= y -1.0)
1.0
(if (<= y 3.2e-86) x (if (<= y 1.35e-36) y (if (<= y 3.7) x 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -4.4e+82) {
tmp = 1.0;
} else if (y <= -3.7e+52) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.2e-86) {
tmp = x;
} else if (y <= 1.35e-36) {
tmp = y;
} else if (y <= 3.7) {
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 <= (-4.4d+82)) then
tmp = 1.0d0
else if (y <= (-3.7d+52)) then
tmp = x / y
else if (y <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= 3.2d-86) then
tmp = x
else if (y <= 1.35d-36) then
tmp = y
else if (y <= 3.7d0) 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 <= -4.4e+82) {
tmp = 1.0;
} else if (y <= -3.7e+52) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.2e-86) {
tmp = x;
} else if (y <= 1.35e-36) {
tmp = y;
} else if (y <= 3.7) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.4e+82: tmp = 1.0 elif y <= -3.7e+52: tmp = x / y elif y <= -1.0: tmp = 1.0 elif y <= 3.2e-86: tmp = x elif y <= 1.35e-36: tmp = y elif y <= 3.7: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -4.4e+82) tmp = 1.0; elseif (y <= -3.7e+52) tmp = Float64(x / y); elseif (y <= -1.0) tmp = 1.0; elseif (y <= 3.2e-86) tmp = x; elseif (y <= 1.35e-36) tmp = y; elseif (y <= 3.7) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.4e+82) tmp = 1.0; elseif (y <= -3.7e+52) tmp = x / y; elseif (y <= -1.0) tmp = 1.0; elseif (y <= 3.2e-86) tmp = x; elseif (y <= 1.35e-36) tmp = y; elseif (y <= 3.7) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.4e+82], 1.0, If[LessEqual[y, -3.7e+52], N[(x / y), $MachinePrecision], If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 3.2e-86], x, If[LessEqual[y, 1.35e-36], y, If[LessEqual[y, 3.7], x, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.4 \cdot 10^{+82}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{+52}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-86}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-36}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.7:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.4000000000000002e82 or -3.7e52 < y < -1 or 3.7000000000000002 < y Initial program 100.0%
Taylor expanded in y around inf 77.1%
if -4.4000000000000002e82 < y < -3.7e52Initial program 100.0%
Taylor expanded in x around inf 86.7%
+-commutative86.7%
Simplified86.7%
Taylor expanded in y around inf 86.7%
if -1 < y < 3.20000000000000006e-86 or 1.35000000000000004e-36 < y < 3.7000000000000002Initial program 100.0%
Taylor expanded in y around 0 82.7%
if 3.20000000000000006e-86 < y < 1.35000000000000004e-36Initial program 100.0%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 87.6%
Final simplification80.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -1.0)
t_0
(if (<= y 5e-88) x (if (<= y 3.8e-37) y (if (<= y 0.0225) x t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 5e-88) {
tmp = x;
} else if (y <= 3.8e-37) {
tmp = y;
} else if (y <= 0.0225) {
tmp = x;
} 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 + (x / y)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 5d-88) then
tmp = x
else if (y <= 3.8d-37) then
tmp = y
else if (y <= 0.0225d0) then
tmp = x
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 tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 5e-88) {
tmp = x;
} else if (y <= 3.8e-37) {
tmp = y;
} else if (y <= 0.0225) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 5e-88: tmp = x elif y <= 3.8e-37: tmp = y elif y <= 0.0225: tmp = x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 5e-88) tmp = x; elseif (y <= 3.8e-37) tmp = y; elseif (y <= 0.0225) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 5e-88) tmp = x; elseif (y <= 3.8e-37) tmp = y; elseif (y <= 0.0225) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 5e-88], x, If[LessEqual[y, 3.8e-37], y, If[LessEqual[y, 0.0225], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-88}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-37}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.0225:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 0.022499999999999999 < y Initial program 100.0%
clear-num99.9%
inv-pow99.9%
flip-+38.8%
associate-/r/38.8%
metadata-eval38.8%
unpow-prod-down38.7%
metadata-eval38.7%
metadata-eval38.7%
inv-pow38.7%
Applied egg-rr38.7%
associate-*r/38.7%
*-rgt-identity38.7%
unpow-138.7%
associate-/r/38.7%
Simplified38.7%
Taylor expanded in y around inf 72.9%
neg-mul-172.9%
Simplified72.9%
Taylor expanded in y around inf 96.8%
if -1 < y < 5.00000000000000009e-88 or 3.8000000000000004e-37 < y < 0.022499999999999999Initial program 100.0%
Taylor expanded in y around 0 83.2%
if 5.00000000000000009e-88 < y < 3.8000000000000004e-37Initial program 100.0%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 87.6%
Final simplification89.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (- x (* x y))))
(if (<= y -1.0)
t_0
(if (<= y 8e-87) t_1 (if (<= y 2.9e-37) y (if (<= y 0.05) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double t_1 = x - (x * y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 8e-87) {
tmp = t_1;
} else if (y <= 2.9e-37) {
tmp = y;
} else if (y <= 0.05) {
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 - (x * y)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 8d-87) then
tmp = t_1
else if (y <= 2.9d-37) then
tmp = y
else if (y <= 0.05d0) 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 - (x * y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 8e-87) {
tmp = t_1;
} else if (y <= 2.9e-37) {
tmp = y;
} else if (y <= 0.05) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) t_1 = x - (x * y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 8e-87: tmp = t_1 elif y <= 2.9e-37: tmp = y elif y <= 0.05: 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(x * y)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 8e-87) tmp = t_1; elseif (y <= 2.9e-37) tmp = y; elseif (y <= 0.05) 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 - (x * y); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 8e-87) tmp = t_1; elseif (y <= 2.9e-37) tmp = y; elseif (y <= 0.05) 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 8e-87], t$95$1, If[LessEqual[y, 2.9e-37], y, If[LessEqual[y, 0.05], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
t_1 := x - x \cdot y\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-87}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-37}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.05:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 0.050000000000000003 < y Initial program 100.0%
clear-num99.9%
inv-pow99.9%
flip-+38.8%
associate-/r/38.8%
metadata-eval38.8%
unpow-prod-down38.7%
metadata-eval38.7%
metadata-eval38.7%
inv-pow38.7%
Applied egg-rr38.7%
associate-*r/38.7%
*-rgt-identity38.7%
unpow-138.7%
associate-/r/38.7%
Simplified38.7%
Taylor expanded in y around inf 72.9%
neg-mul-172.9%
Simplified72.9%
Taylor expanded in y around inf 96.8%
if -1 < y < 8.00000000000000014e-87 or 2.90000000000000005e-37 < y < 0.050000000000000003Initial program 100.0%
Taylor expanded in x around inf 84.0%
+-commutative84.0%
Simplified84.0%
Taylor expanded in y around 0 83.8%
+-commutative83.8%
mul-1-neg83.8%
unsub-neg83.8%
*-commutative83.8%
Simplified83.8%
if 8.00000000000000014e-87 < y < 2.90000000000000005e-37Initial program 100.0%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 87.6%
Final simplification90.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -2.8e+25)
t_0
(if (<= y 1.3e-85)
t_1
(if (<= y 8.5e-31) y (if (<= y 29000.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 <= -2.8e+25) {
tmp = t_0;
} else if (y <= 1.3e-85) {
tmp = t_1;
} else if (y <= 8.5e-31) {
tmp = y;
} else if (y <= 29000.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 <= (-2.8d+25)) then
tmp = t_0
else if (y <= 1.3d-85) then
tmp = t_1
else if (y <= 8.5d-31) then
tmp = y
else if (y <= 29000.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 <= -2.8e+25) {
tmp = t_0;
} else if (y <= 1.3e-85) {
tmp = t_1;
} else if (y <= 8.5e-31) {
tmp = y;
} else if (y <= 29000.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 <= -2.8e+25: tmp = t_0 elif y <= 1.3e-85: tmp = t_1 elif y <= 8.5e-31: tmp = y elif y <= 29000.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 <= -2.8e+25) tmp = t_0; elseif (y <= 1.3e-85) tmp = t_1; elseif (y <= 8.5e-31) tmp = y; elseif (y <= 29000.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 <= -2.8e+25) tmp = t_0; elseif (y <= 1.3e-85) tmp = t_1; elseif (y <= 8.5e-31) tmp = y; elseif (y <= 29000.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, -2.8e+25], t$95$0, If[LessEqual[y, 1.3e-85], t$95$1, If[LessEqual[y, 8.5e-31], y, If[LessEqual[y, 29000.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 -2.8 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-85}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-31}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 29000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.8000000000000002e25 or 29000 < y Initial program 100.0%
clear-num99.9%
inv-pow99.9%
flip-+37.0%
associate-/r/36.9%
metadata-eval36.9%
unpow-prod-down36.9%
metadata-eval36.9%
metadata-eval36.9%
inv-pow36.9%
Applied egg-rr36.9%
associate-*r/36.9%
*-rgt-identity36.9%
unpow-136.9%
associate-/r/36.9%
Simplified36.9%
Taylor expanded in y around inf 75.7%
neg-mul-175.7%
Simplified75.7%
Taylor expanded in y around inf 99.0%
if -2.8000000000000002e25 < y < 1.30000000000000006e-85 or 8.5000000000000007e-31 < y < 29000Initial program 100.0%
Taylor expanded in x around inf 83.9%
+-commutative83.9%
Simplified83.9%
if 1.30000000000000006e-85 < y < 8.5000000000000007e-31Initial program 100.0%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 87.6%
Final simplification90.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -2.8e+25)
t_0
(if (<= y 1.35e-85)
t_1
(if (<= y 5.5e-32) (/ y (+ y 1.0)) (if (<= y 27000.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 <= -2.8e+25) {
tmp = t_0;
} else if (y <= 1.35e-85) {
tmp = t_1;
} else if (y <= 5.5e-32) {
tmp = y / (y + 1.0);
} else if (y <= 27000.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 <= (-2.8d+25)) then
tmp = t_0
else if (y <= 1.35d-85) then
tmp = t_1
else if (y <= 5.5d-32) then
tmp = y / (y + 1.0d0)
else if (y <= 27000.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 <= -2.8e+25) {
tmp = t_0;
} else if (y <= 1.35e-85) {
tmp = t_1;
} else if (y <= 5.5e-32) {
tmp = y / (y + 1.0);
} else if (y <= 27000.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 <= -2.8e+25: tmp = t_0 elif y <= 1.35e-85: tmp = t_1 elif y <= 5.5e-32: tmp = y / (y + 1.0) elif y <= 27000.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 <= -2.8e+25) tmp = t_0; elseif (y <= 1.35e-85) tmp = t_1; elseif (y <= 5.5e-32) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 27000.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 <= -2.8e+25) tmp = t_0; elseif (y <= 1.35e-85) tmp = t_1; elseif (y <= 5.5e-32) tmp = y / (y + 1.0); elseif (y <= 27000.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, -2.8e+25], t$95$0, If[LessEqual[y, 1.35e-85], t$95$1, If[LessEqual[y, 5.5e-32], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 27000.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 -2.8 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-85}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-32}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 27000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.8000000000000002e25 or 27000 < y Initial program 100.0%
clear-num99.9%
inv-pow99.9%
flip-+37.0%
associate-/r/36.9%
metadata-eval36.9%
unpow-prod-down36.9%
metadata-eval36.9%
metadata-eval36.9%
inv-pow36.9%
Applied egg-rr36.9%
associate-*r/36.9%
*-rgt-identity36.9%
unpow-136.9%
associate-/r/36.9%
Simplified36.9%
Taylor expanded in y around inf 75.7%
neg-mul-175.7%
Simplified75.7%
Taylor expanded in y around inf 99.0%
if -2.8000000000000002e25 < y < 1.3500000000000001e-85 or 5.50000000000000024e-32 < y < 27000Initial program 100.0%
Taylor expanded in x around inf 83.9%
+-commutative83.9%
Simplified83.9%
if 1.3500000000000001e-85 < y < 5.50000000000000024e-32Initial program 100.0%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
Final simplification90.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.82))) (+ 1.0 (/ x y)) (+ x (* y (- 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.82)) {
tmp = 1.0 + (x / 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 <= 0.82d0))) then
tmp = 1.0d0 + (x / 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 <= 0.82)) {
tmp = 1.0 + (x / y);
} else {
tmp = x + (y * (1.0 - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.82): tmp = 1.0 + (x / y) else: tmp = x + (y * (1.0 - x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.82)) tmp = Float64(1.0 + Float64(x / 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 <= 0.82))) tmp = 1.0 + (x / 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, 0.82]], $MachinePrecision]], N[(1.0 + N[(x / 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 0.82\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if y < -1 or 0.819999999999999951 < y Initial program 100.0%
clear-num99.9%
inv-pow99.9%
flip-+38.8%
associate-/r/38.8%
metadata-eval38.8%
unpow-prod-down38.7%
metadata-eval38.7%
metadata-eval38.7%
inv-pow38.7%
Applied egg-rr38.7%
associate-*r/38.7%
*-rgt-identity38.7%
unpow-138.7%
associate-/r/38.7%
Simplified38.7%
Taylor expanded in y around inf 72.9%
neg-mul-172.9%
Simplified72.9%
Taylor expanded in y around inf 96.8%
if -1 < y < 0.819999999999999951Initial program 100.0%
Taylor expanded in y around 0 99.1%
Final simplification98.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 1.35e-85) x (if (<= y 3.6e-32) y (if (<= y 7.8) x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1.35e-85) {
tmp = x;
} else if (y <= 3.6e-32) {
tmp = y;
} else if (y <= 7.8) {
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.35d-85) then
tmp = x
else if (y <= 3.6d-32) then
tmp = y
else if (y <= 7.8d0) 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.35e-85) {
tmp = x;
} else if (y <= 3.6e-32) {
tmp = y;
} else if (y <= 7.8) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 1.35e-85: tmp = x elif y <= 3.6e-32: tmp = y elif y <= 7.8: 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.35e-85) tmp = x; elseif (y <= 3.6e-32) tmp = y; elseif (y <= 7.8) 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.35e-85) tmp = x; elseif (y <= 3.6e-32) tmp = y; elseif (y <= 7.8) 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.35e-85], x, If[LessEqual[y, 3.6e-32], y, If[LessEqual[y, 7.8], x, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-85}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-32}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7.8:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 7.79999999999999982 < y Initial program 100.0%
Taylor expanded in y around inf 73.5%
if -1 < y < 1.3500000000000001e-85 or 3.59999999999999993e-32 < y < 7.79999999999999982Initial program 100.0%
Taylor expanded in y around 0 82.7%
if 1.3500000000000001e-85 < y < 3.59999999999999993e-32Initial program 100.0%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 87.6%
Final simplification78.5%
(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 73.5%
if -1 < y < 2.39999999999999991Initial program 100.0%
Taylor expanded in y around 0 78.8%
Final simplification76.3%
(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 36.4%
Final simplification36.4%
herbie shell --seed 2023174
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))