
(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 (<= x -2.8e+78)
t_0
(if (<= x 3950000000000.0)
(/ y (+ y 1.0))
(if (<= x 9e+42) x (if (<= x 8e+69) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (x <= -2.8e+78) {
tmp = t_0;
} else if (x <= 3950000000000.0) {
tmp = y / (y + 1.0);
} else if (x <= 9e+42) {
tmp = x;
} else if (x <= 8e+69) {
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 <= (-2.8d+78)) then
tmp = t_0
else if (x <= 3950000000000.0d0) then
tmp = y / (y + 1.0d0)
else if (x <= 9d+42) then
tmp = x
else if (x <= 8d+69) 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 <= -2.8e+78) {
tmp = t_0;
} else if (x <= 3950000000000.0) {
tmp = y / (y + 1.0);
} else if (x <= 9e+42) {
tmp = x;
} else if (x <= 8e+69) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if x <= -2.8e+78: tmp = t_0 elif x <= 3950000000000.0: tmp = y / (y + 1.0) elif x <= 9e+42: tmp = x elif x <= 8e+69: 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 <= -2.8e+78) tmp = t_0; elseif (x <= 3950000000000.0) tmp = Float64(y / Float64(y + 1.0)); elseif (x <= 9e+42) tmp = x; elseif (x <= 8e+69) 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 <= -2.8e+78) tmp = t_0; elseif (x <= 3950000000000.0) tmp = y / (y + 1.0); elseif (x <= 9e+42) tmp = x; elseif (x <= 8e+69) 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, -2.8e+78], t$95$0, If[LessEqual[x, 3950000000000.0], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9e+42], x, If[LessEqual[x, 8e+69], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;x \leq -2.8 \cdot 10^{+78}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3950000000000:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+42}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+69}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.8000000000000001e78 or 8.0000000000000006e69 < x Initial program 100.0%
Taylor expanded in x around inf 82.1%
+-commutative82.1%
Simplified82.1%
if -2.8000000000000001e78 < x < 3.95e12Initial program 99.9%
Taylor expanded in x around 0 79.9%
+-commutative79.9%
Simplified79.9%
if 3.95e12 < x < 9.00000000000000025e42Initial program 100.0%
Taylor expanded in y around 0 86.8%
if 9.00000000000000025e42 < x < 8.0000000000000006e69Initial program 100.0%
Taylor expanded in y around inf 100.0%
Final simplification81.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (- 1.0 x) y))))
(if (<= y -150.0)
t_0
(if (<= y 8.3e-112)
(/ x (+ y 1.0))
(if (<= y 31000000.0) (/ y (+ y 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 - ((1.0 - x) / y);
double tmp;
if (y <= -150.0) {
tmp = t_0;
} else if (y <= 8.3e-112) {
tmp = x / (y + 1.0);
} else if (y <= 31000000.0) {
tmp = y / (y + 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 = 1.0d0 - ((1.0d0 - x) / y)
if (y <= (-150.0d0)) then
tmp = t_0
else if (y <= 8.3d-112) then
tmp = x / (y + 1.0d0)
else if (y <= 31000000.0d0) then
tmp = y / (y + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - ((1.0 - x) / y);
double tmp;
if (y <= -150.0) {
tmp = t_0;
} else if (y <= 8.3e-112) {
tmp = x / (y + 1.0);
} else if (y <= 31000000.0) {
tmp = y / (y + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - ((1.0 - x) / y) tmp = 0 if y <= -150.0: tmp = t_0 elif y <= 8.3e-112: tmp = x / (y + 1.0) elif y <= 31000000.0: tmp = y / (y + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(1.0 - x) / y)) tmp = 0.0 if (y <= -150.0) tmp = t_0; elseif (y <= 8.3e-112) tmp = Float64(x / Float64(y + 1.0)); elseif (y <= 31000000.0) tmp = Float64(y / Float64(y + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - ((1.0 - x) / y); tmp = 0.0; if (y <= -150.0) tmp = t_0; elseif (y <= 8.3e-112) tmp = x / (y + 1.0); elseif (y <= 31000000.0) tmp = y / (y + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -150.0], t$95$0, If[LessEqual[y, 8.3e-112], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 31000000.0], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -150:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8.3 \cdot 10^{-112}:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{elif}\;y \leq 31000000:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -150 or 3.1e7 < y Initial program 100.0%
Taylor expanded in y around -inf 99.6%
mul-1-neg99.6%
unsub-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
Simplified99.6%
if -150 < y < 8.29999999999999961e-112Initial program 100.0%
Taylor expanded in x around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 8.29999999999999961e-112 < y < 3.1e7Initial program 99.8%
Taylor expanded in x around 0 69.1%
+-commutative69.1%
Simplified69.1%
Final simplification89.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 1.7e-111) x (if (<= y 0.76) (- y (* y y)) 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1.7e-111) {
tmp = x;
} else if (y <= 0.76) {
tmp = y - (y * 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 <= 1.7d-111) then
tmp = x
else if (y <= 0.76d0) then
tmp = y - (y * 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 <= 1.7e-111) {
tmp = x;
} else if (y <= 0.76) {
tmp = y - (y * y);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 1.7e-111: tmp = x elif y <= 0.76: tmp = y - (y * y) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 1.7e-111) tmp = x; elseif (y <= 0.76) tmp = Float64(y - Float64(y * 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 <= 1.7e-111) tmp = x; elseif (y <= 0.76) tmp = y - (y * y); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 1.7e-111], x, If[LessEqual[y, 0.76], N[(y - N[(y * y), $MachinePrecision]), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-111}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.76:\\
\;\;\;\;y - y \cdot y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 0.76000000000000001 < y Initial program 100.0%
Taylor expanded in y around inf 75.9%
if -1 < y < 1.69999999999999998e-111Initial program 100.0%
Taylor expanded in y around 0 76.0%
if 1.69999999999999998e-111 < y < 0.76000000000000001Initial program 99.7%
Taylor expanded in x around 0 67.4%
+-commutative67.4%
Simplified67.4%
Taylor expanded in y around 0 67.6%
neg-mul-167.6%
+-commutative67.6%
unsub-neg67.6%
unpow267.6%
Simplified67.6%
Final simplification75.4%
(FPCore (x y) :precision binary64 (if (<= y -150.0) 1.0 (if (<= y 1.25e-111) (/ x (+ y 1.0)) (if (<= y 0.76) (- y (* y y)) 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -150.0) {
tmp = 1.0;
} else if (y <= 1.25e-111) {
tmp = x / (y + 1.0);
} else if (y <= 0.76) {
tmp = y - (y * 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 <= (-150.0d0)) then
tmp = 1.0d0
else if (y <= 1.25d-111) then
tmp = x / (y + 1.0d0)
else if (y <= 0.76d0) then
tmp = y - (y * y)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -150.0) {
tmp = 1.0;
} else if (y <= 1.25e-111) {
tmp = x / (y + 1.0);
} else if (y <= 0.76) {
tmp = y - (y * y);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -150.0: tmp = 1.0 elif y <= 1.25e-111: tmp = x / (y + 1.0) elif y <= 0.76: tmp = y - (y * y) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -150.0) tmp = 1.0; elseif (y <= 1.25e-111) tmp = Float64(x / Float64(y + 1.0)); elseif (y <= 0.76) tmp = Float64(y - Float64(y * y)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -150.0) tmp = 1.0; elseif (y <= 1.25e-111) tmp = x / (y + 1.0); elseif (y <= 0.76) tmp = y - (y * y); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -150.0], 1.0, If[LessEqual[y, 1.25e-111], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.76], N[(y - N[(y * y), $MachinePrecision]), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -150:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-111}:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{elif}\;y \leq 0.76:\\
\;\;\;\;y - y \cdot y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -150 or 0.76000000000000001 < y Initial program 100.0%
Taylor expanded in y around inf 75.9%
if -150 < y < 1.2500000000000001e-111Initial program 100.0%
Taylor expanded in x around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 1.2500000000000001e-111 < y < 0.76000000000000001Initial program 99.7%
Taylor expanded in x around 0 67.4%
+-commutative67.4%
Simplified67.4%
Taylor expanded in y around 0 67.6%
neg-mul-167.6%
+-commutative67.6%
unsub-neg67.6%
unpow267.6%
Simplified67.6%
Final simplification76.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -150.0)
t_0
(if (<= y 1.7e-111)
(/ x (+ y 1.0))
(if (<= y 1.65e+14) (/ y (+ y 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (y <= -150.0) {
tmp = t_0;
} else if (y <= 1.7e-111) {
tmp = x / (y + 1.0);
} else if (y <= 1.65e+14) {
tmp = y / (y + 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 = 1.0d0 + (x / y)
if (y <= (-150.0d0)) then
tmp = t_0
else if (y <= 1.7d-111) then
tmp = x / (y + 1.0d0)
else if (y <= 1.65d+14) then
tmp = y / (y + 1.0d0)
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 <= -150.0) {
tmp = t_0;
} else if (y <= 1.7e-111) {
tmp = x / (y + 1.0);
} else if (y <= 1.65e+14) {
tmp = y / (y + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if y <= -150.0: tmp = t_0 elif y <= 1.7e-111: tmp = x / (y + 1.0) elif y <= 1.65e+14: tmp = y / (y + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (y <= -150.0) tmp = t_0; elseif (y <= 1.7e-111) tmp = Float64(x / Float64(y + 1.0)); elseif (y <= 1.65e+14) tmp = Float64(y / Float64(y + 1.0)); 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 <= -150.0) tmp = t_0; elseif (y <= 1.7e-111) tmp = x / (y + 1.0); elseif (y <= 1.65e+14) tmp = y / (y + 1.0); 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, -150.0], t$95$0, If[LessEqual[y, 1.7e-111], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e+14], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;y \leq -150:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-111}:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+14}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -150 or 1.65e14 < y Initial program 100.0%
Taylor expanded in y around -inf 99.6%
mul-1-neg99.6%
unsub-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in x around inf 99.0%
neg-mul-199.0%
distribute-neg-frac99.0%
Simplified99.0%
if -150 < y < 1.69999999999999998e-111Initial program 100.0%
Taylor expanded in x around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 1.69999999999999998e-111 < y < 1.65e14Initial program 99.8%
Taylor expanded in x around 0 70.6%
+-commutative70.6%
Simplified70.6%
Final simplification88.7%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 1.25e-111) x (if (<= y 1.0) y 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 1.25e-111) {
tmp = x;
} else if (y <= 1.0) {
tmp = 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 <= 1.25d-111) then
tmp = x
else if (y <= 1.0d0) then
tmp = 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 <= 1.25e-111) {
tmp = x;
} else if (y <= 1.0) {
tmp = y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 1.25e-111: tmp = x elif y <= 1.0: tmp = y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 1.25e-111) tmp = x; elseif (y <= 1.0) tmp = 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 <= 1.25e-111) tmp = x; elseif (y <= 1.0) tmp = y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 1.25e-111], x, If[LessEqual[y, 1.0], y, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-111}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 75.9%
if -1 < y < 1.2500000000000001e-111Initial program 100.0%
Taylor expanded in y around 0 76.0%
if 1.2500000000000001e-111 < y < 1Initial program 99.7%
Taylor expanded in x around 0 67.4%
+-commutative67.4%
Simplified67.4%
Taylor expanded in y around 0 65.0%
Final simplification75.2%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 3.5e-9) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.5e-9) {
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.5d-9) 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.5e-9) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 3.5e-9: 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.5e-9) 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.5e-9) 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.5e-9], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 3.4999999999999999e-9 < y Initial program 100.0%
Taylor expanded in y around inf 75.4%
if -1 < y < 3.4999999999999999e-9Initial program 100.0%
Taylor expanded in y around 0 70.3%
Final simplification73.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 43.2%
Final simplification43.2%
herbie shell --seed 2023196
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))