
(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 (* y (- 1.0 y))))
(if (<= y -6800000.0)
1.0
(if (<= y -5.8e-50)
t_0
(if (<= y 6.8e-135) x (if (<= y 0.00215) t_0 1.0))))))
double code(double x, double y) {
double t_0 = y * (1.0 - y);
double tmp;
if (y <= -6800000.0) {
tmp = 1.0;
} else if (y <= -5.8e-50) {
tmp = t_0;
} else if (y <= 6.8e-135) {
tmp = x;
} else if (y <= 0.00215) {
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 = y * (1.0d0 - y)
if (y <= (-6800000.0d0)) then
tmp = 1.0d0
else if (y <= (-5.8d-50)) then
tmp = t_0
else if (y <= 6.8d-135) then
tmp = x
else if (y <= 0.00215d0) 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 = y * (1.0 - y);
double tmp;
if (y <= -6800000.0) {
tmp = 1.0;
} else if (y <= -5.8e-50) {
tmp = t_0;
} else if (y <= 6.8e-135) {
tmp = x;
} else if (y <= 0.00215) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (1.0 - y) tmp = 0 if y <= -6800000.0: tmp = 1.0 elif y <= -5.8e-50: tmp = t_0 elif y <= 6.8e-135: tmp = x elif y <= 0.00215: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(y * Float64(1.0 - y)) tmp = 0.0 if (y <= -6800000.0) tmp = 1.0; elseif (y <= -5.8e-50) tmp = t_0; elseif (y <= 6.8e-135) tmp = x; elseif (y <= 0.00215) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (1.0 - y); tmp = 0.0; if (y <= -6800000.0) tmp = 1.0; elseif (y <= -5.8e-50) tmp = t_0; elseif (y <= 6.8e-135) tmp = x; elseif (y <= 0.00215) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6800000.0], 1.0, If[LessEqual[y, -5.8e-50], t$95$0, If[LessEqual[y, 6.8e-135], x, If[LessEqual[y, 0.00215], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - y\right)\\
\mathbf{if}\;y \leq -6800000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-50}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-135}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.00215:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.8e6 or 0.00215 < y Initial program 100.0%
Taylor expanded in y around inf 68.7%
if -6.8e6 < y < -5.80000000000000016e-50 or 6.79999999999999978e-135 < y < 0.00215Initial program 99.9%
clear-num99.4%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 94.3%
neg-mul-194.3%
sub-neg94.3%
Simplified94.3%
Taylor expanded in x around 0 60.5%
if -5.80000000000000016e-50 < y < 6.79999999999999978e-135Initial program 100.0%
Taylor expanded in y around 0 90.5%
Final simplification76.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -10500000.0)
t_0
(if (<= y 6.8e-135)
t_1
(if (<= y 2.9e-24) y (if (<= y 13000000000.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 <= -10500000.0) {
tmp = t_0;
} else if (y <= 6.8e-135) {
tmp = t_1;
} else if (y <= 2.9e-24) {
tmp = y;
} else if (y <= 13000000000.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 <= (-10500000.0d0)) then
tmp = t_0
else if (y <= 6.8d-135) then
tmp = t_1
else if (y <= 2.9d-24) then
tmp = y
else if (y <= 13000000000.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 <= -10500000.0) {
tmp = t_0;
} else if (y <= 6.8e-135) {
tmp = t_1;
} else if (y <= 2.9e-24) {
tmp = y;
} else if (y <= 13000000000.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 <= -10500000.0: tmp = t_0 elif y <= 6.8e-135: tmp = t_1 elif y <= 2.9e-24: tmp = y elif y <= 13000000000.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 <= -10500000.0) tmp = t_0; elseif (y <= 6.8e-135) tmp = t_1; elseif (y <= 2.9e-24) tmp = y; elseif (y <= 13000000000.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 <= -10500000.0) tmp = t_0; elseif (y <= 6.8e-135) tmp = t_1; elseif (y <= 2.9e-24) tmp = y; elseif (y <= 13000000000.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, -10500000.0], t$95$0, If[LessEqual[y, 6.8e-135], t$95$1, If[LessEqual[y, 2.9e-24], y, If[LessEqual[y, 13000000000.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 -10500000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-24}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 13000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.05e7 or 1.3e10 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate--l+100.0%
+-commutative100.0%
associate--r-100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
Simplified99.3%
div-inv99.2%
cancel-sign-sub99.2%
div-inv99.3%
+-commutative99.3%
Applied egg-rr99.3%
if -1.05e7 < y < 6.79999999999999978e-135 or 2.8999999999999999e-24 < y < 1.3e10Initial program 100.0%
Taylor expanded in x around inf 85.2%
+-commutative85.2%
Simplified85.2%
if 6.79999999999999978e-135 < y < 2.8999999999999999e-24Initial program 100.0%
Taylor expanded in x around 0 66.2%
+-commutative66.2%
Simplified66.2%
Taylor expanded in y around 0 66.2%
Final simplification89.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= y -1.0)
t_0
(if (<= y 1.45e-135) x (if (<= y 5.2e-11) (* y (- 1.0 y)) 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 <= 1.45e-135) {
tmp = x;
} else if (y <= 5.2e-11) {
tmp = y * (1.0 - y);
} 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 <= 1.45d-135) then
tmp = x
else if (y <= 5.2d-11) then
tmp = y * (1.0d0 - y)
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 <= 1.45e-135) {
tmp = x;
} else if (y <= 5.2e-11) {
tmp = y * (1.0 - y);
} 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 <= 1.45e-135: tmp = x elif y <= 5.2e-11: tmp = y * (1.0 - y) 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 <= 1.45e-135) tmp = x; elseif (y <= 5.2e-11) tmp = Float64(y * Float64(1.0 - y)); 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 <= 1.45e-135) tmp = x; elseif (y <= 5.2e-11) tmp = y * (1.0 - y); 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, 1.45e-135], x, If[LessEqual[y, 5.2e-11], N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 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 1.45 \cdot 10^{-135}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-11}:\\
\;\;\;\;y \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 5.2000000000000001e-11 < y Initial program 100.0%
Taylor expanded in y around inf 95.4%
+-commutative95.4%
associate--l+95.4%
+-commutative95.4%
associate--r-95.4%
div-sub95.4%
Simplified95.4%
Taylor expanded in x around inf 94.7%
neg-mul-194.7%
distribute-neg-frac94.7%
Simplified94.7%
div-inv94.5%
cancel-sign-sub94.5%
div-inv94.7%
+-commutative94.7%
Applied egg-rr94.7%
if -1 < y < 1.4500000000000001e-135Initial program 100.0%
Taylor expanded in y around 0 86.5%
if 1.4500000000000001e-135 < y < 5.2000000000000001e-11Initial program 99.9%
clear-num99.6%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 100.0%
neg-mul-1100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 61.4%
Final simplification87.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.76))) (+ 1.0 (/ x y)) (* (+ x y) (- 1.0 y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.76)) {
tmp = 1.0 + (x / y);
} else {
tmp = (x + y) * (1.0 - y);
}
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.76d0))) then
tmp = 1.0d0 + (x / y)
else
tmp = (x + y) * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.76)) {
tmp = 1.0 + (x / y);
} else {
tmp = (x + y) * (1.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.76): tmp = 1.0 + (x / y) else: tmp = (x + y) * (1.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.76)) tmp = Float64(1.0 + Float64(x / y)); else tmp = Float64(Float64(x + y) * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.76))) tmp = 1.0 + (x / y); else tmp = (x + y) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.76]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.76\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if y < -1 or 0.76000000000000001 < y Initial program 100.0%
Taylor expanded in y around inf 98.2%
+-commutative98.2%
associate--l+98.2%
+-commutative98.2%
associate--r-98.2%
div-sub98.2%
Simplified98.2%
Taylor expanded in x around inf 97.5%
neg-mul-197.5%
distribute-neg-frac97.5%
Simplified97.5%
div-inv97.3%
cancel-sign-sub97.3%
div-inv97.5%
+-commutative97.5%
Applied egg-rr97.5%
if -1 < y < 0.76000000000000001Initial program 100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 98.7%
neg-mul-198.7%
sub-neg98.7%
Simplified98.7%
Final simplification98.1%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ 1.0 (/ (+ x -1.0) y)) (* (+ x y) (- 1.0 y))))
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 - y);
}
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 - y)
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 - y);
}
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 - y) 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(Float64(x + y) * Float64(1.0 - y)); 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 - y); 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[(N[(x + y), $MachinePrecision] * N[(1.0 - y), $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}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 98.2%
+-commutative98.2%
associate--l+98.2%
+-commutative98.2%
associate--r-98.2%
div-sub98.2%
Simplified98.2%
if -1 < y < 1Initial program 100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 98.7%
neg-mul-198.7%
sub-neg98.7%
Simplified98.7%
Final simplification98.5%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 6.8e-135) x (if (<= y 0.00215) y 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 6.8e-135) {
tmp = x;
} else if (y <= 0.00215) {
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 <= 6.8d-135) then
tmp = x
else if (y <= 0.00215d0) 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 <= 6.8e-135) {
tmp = x;
} else if (y <= 0.00215) {
tmp = y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 6.8e-135: tmp = x elif y <= 0.00215: tmp = y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= 6.8e-135) tmp = x; elseif (y <= 0.00215) 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 <= 6.8e-135) tmp = x; elseif (y <= 0.00215) tmp = y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 6.8e-135], x, If[LessEqual[y, 0.00215], y, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-135}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.00215:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 0.00215 < y Initial program 100.0%
Taylor expanded in y around inf 67.6%
if -1 < y < 6.79999999999999978e-135Initial program 100.0%
Taylor expanded in y around 0 86.5%
if 6.79999999999999978e-135 < y < 0.00215Initial program 99.9%
Taylor expanded in x around 0 59.1%
+-commutative59.1%
Simplified59.1%
Taylor expanded in y around 0 58.9%
Final simplification74.8%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 2.3) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 2.3) {
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.3d0) 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.3) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 2.3: 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.3) 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.3) 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.3], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.3:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 2.2999999999999998 < y Initial program 100.0%
Taylor expanded in y around inf 69.3%
if -1 < y < 2.2999999999999998Initial program 100.0%
Taylor expanded in y around 0 76.1%
Final simplification73.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 33.9%
Final simplification33.9%
herbie shell --seed 2024036
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))