
(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 11 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 (+ 1.0 (/ -1.0 y))))
(if (<= y -4.8e+100)
1.0
(if (<= y -4.2e+40)
(/ x y)
(if (<= y -1.0) t_0 (if (<= y -3.5e-54) y (if (<= y 2.0) x t_0)))))))
double code(double x, double y) {
double t_0 = 1.0 + (-1.0 / y);
double tmp;
if (y <= -4.8e+100) {
tmp = 1.0;
} else if (y <= -4.2e+40) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = t_0;
} else if (y <= -3.5e-54) {
tmp = y;
} else if (y <= 2.0) {
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 + ((-1.0d0) / y)
if (y <= (-4.8d+100)) then
tmp = 1.0d0
else if (y <= (-4.2d+40)) then
tmp = x / y
else if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= (-3.5d-54)) then
tmp = y
else if (y <= 2.0d0) 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 + (-1.0 / y);
double tmp;
if (y <= -4.8e+100) {
tmp = 1.0;
} else if (y <= -4.2e+40) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = t_0;
} else if (y <= -3.5e-54) {
tmp = y;
} else if (y <= 2.0) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-1.0 / y) tmp = 0 if y <= -4.8e+100: tmp = 1.0 elif y <= -4.2e+40: tmp = x / y elif y <= -1.0: tmp = t_0 elif y <= -3.5e-54: tmp = y elif y <= 2.0: tmp = x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-1.0 / y)) tmp = 0.0 if (y <= -4.8e+100) tmp = 1.0; elseif (y <= -4.2e+40) tmp = Float64(x / y); elseif (y <= -1.0) tmp = t_0; elseif (y <= -3.5e-54) tmp = y; elseif (y <= 2.0) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-1.0 / y); tmp = 0.0; if (y <= -4.8e+100) tmp = 1.0; elseif (y <= -4.2e+40) tmp = x / y; elseif (y <= -1.0) tmp = t_0; elseif (y <= -3.5e-54) tmp = y; elseif (y <= 2.0) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.8e+100], 1.0, If[LessEqual[y, -4.2e+40], N[(x / y), $MachinePrecision], If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, -3.5e-54], y, If[LessEqual[y, 2.0], x, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{-1}{y}\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+100}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{-54}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -4.80000000000000023e100Initial program 100.0%
Taylor expanded in y around inf 91.4%
if -4.80000000000000023e100 < y < -4.2000000000000002e40Initial program 99.9%
Taylor expanded in x around inf 78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in y around inf 78.7%
if -4.2000000000000002e40 < y < -1 or 2 < y Initial program 100.0%
Taylor expanded in x around 0 74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in y around inf 73.4%
if -1 < y < -3.49999999999999982e-54Initial program 99.9%
Taylor expanded in x around 0 59.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in y around 0 55.5%
if -3.49999999999999982e-54 < y < 2Initial program 100.0%
Taylor expanded in y around 0 78.7%
Final simplification78.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ -1.0 y))))
(if (<= y -4.2e+100)
1.0
(if (<= y -2.4e+40)
(/ x y)
(if (<= y -1.0)
t_0
(if (<= y -5.2e-54) y (if (<= y 1.0) (- x (* x y)) t_0)))))))
double code(double x, double y) {
double t_0 = 1.0 + (-1.0 / y);
double tmp;
if (y <= -4.2e+100) {
tmp = 1.0;
} else if (y <= -2.4e+40) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = t_0;
} else if (y <= -5.2e-54) {
tmp = y;
} else if (y <= 1.0) {
tmp = x - (x * 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 + ((-1.0d0) / y)
if (y <= (-4.2d+100)) then
tmp = 1.0d0
else if (y <= (-2.4d+40)) then
tmp = x / y
else if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= (-5.2d-54)) then
tmp = y
else if (y <= 1.0d0) then
tmp = x - (x * y)
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 / y);
double tmp;
if (y <= -4.2e+100) {
tmp = 1.0;
} else if (y <= -2.4e+40) {
tmp = x / y;
} else if (y <= -1.0) {
tmp = t_0;
} else if (y <= -5.2e-54) {
tmp = y;
} else if (y <= 1.0) {
tmp = x - (x * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (-1.0 / y) tmp = 0 if y <= -4.2e+100: tmp = 1.0 elif y <= -2.4e+40: tmp = x / y elif y <= -1.0: tmp = t_0 elif y <= -5.2e-54: tmp = y elif y <= 1.0: tmp = x - (x * y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(-1.0 / y)) tmp = 0.0 if (y <= -4.2e+100) tmp = 1.0; elseif (y <= -2.4e+40) tmp = Float64(x / y); elseif (y <= -1.0) tmp = t_0; elseif (y <= -5.2e-54) tmp = y; elseif (y <= 1.0) tmp = Float64(x - Float64(x * y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (-1.0 / y); tmp = 0.0; if (y <= -4.2e+100) tmp = 1.0; elseif (y <= -2.4e+40) tmp = x / y; elseif (y <= -1.0) tmp = t_0; elseif (y <= -5.2e-54) tmp = y; elseif (y <= 1.0) tmp = x - (x * y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.2e+100], 1.0, If[LessEqual[y, -2.4e+40], N[(x / y), $MachinePrecision], If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, -5.2e-54], y, If[LessEqual[y, 1.0], N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{-1}{y}\\
\mathbf{if}\;y \leq -4.2 \cdot 10^{+100}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-54}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -4.1999999999999997e100Initial program 100.0%
Taylor expanded in y around inf 91.4%
if -4.1999999999999997e100 < y < -2.4e40Initial program 99.9%
Taylor expanded in x around inf 78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in y around inf 78.7%
if -2.4e40 < y < -1 or 1 < y Initial program 100.0%
Taylor expanded in x around 0 74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in y around inf 73.4%
if -1 < y < -5.20000000000000004e-54Initial program 99.9%
Taylor expanded in x around 0 59.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in y around 0 55.5%
if -5.20000000000000004e-54 < y < 1Initial program 100.0%
Taylor expanded in x around inf 80.4%
+-commutative80.4%
Simplified80.4%
Taylor expanded in y around 0 79.3%
mul-1-neg79.3%
distribute-rgt-neg-out79.3%
+-commutative79.3%
distribute-rgt-neg-out79.3%
unsub-neg79.3%
*-commutative79.3%
Simplified79.3%
Final simplification78.7%
(FPCore (x y)
:precision binary64
(if (<= y -1.68e+100)
1.0
(if (<= y -2.1e+40)
(/ x y)
(if (<= y -66.0)
(+ 1.0 (/ -1.0 y))
(if (<= y 1.5e+23) (/ x (+ y 1.0)) 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.68e+100) {
tmp = 1.0;
} else if (y <= -2.1e+40) {
tmp = x / y;
} else if (y <= -66.0) {
tmp = 1.0 + (-1.0 / y);
} else if (y <= 1.5e+23) {
tmp = x / (y + 1.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) :: tmp
if (y <= (-1.68d+100)) then
tmp = 1.0d0
else if (y <= (-2.1d+40)) then
tmp = x / y
else if (y <= (-66.0d0)) then
tmp = 1.0d0 + ((-1.0d0) / y)
else if (y <= 1.5d+23) then
tmp = x / (y + 1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.68e+100) {
tmp = 1.0;
} else if (y <= -2.1e+40) {
tmp = x / y;
} else if (y <= -66.0) {
tmp = 1.0 + (-1.0 / y);
} else if (y <= 1.5e+23) {
tmp = x / (y + 1.0);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.68e+100: tmp = 1.0 elif y <= -2.1e+40: tmp = x / y elif y <= -66.0: tmp = 1.0 + (-1.0 / y) elif y <= 1.5e+23: tmp = x / (y + 1.0) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.68e+100) tmp = 1.0; elseif (y <= -2.1e+40) tmp = Float64(x / y); elseif (y <= -66.0) tmp = Float64(1.0 + Float64(-1.0 / y)); elseif (y <= 1.5e+23) tmp = Float64(x / Float64(y + 1.0)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.68e+100) tmp = 1.0; elseif (y <= -2.1e+40) tmp = x / y; elseif (y <= -66.0) tmp = 1.0 + (-1.0 / y); elseif (y <= 1.5e+23) tmp = x / (y + 1.0); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.68e+100], 1.0, If[LessEqual[y, -2.1e+40], N[(x / y), $MachinePrecision], If[LessEqual[y, -66.0], N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+23], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.68 \cdot 10^{+100}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq -66:\\
\;\;\;\;1 + \frac{-1}{y}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+23}:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.68000000000000008e100 or 1.5e23 < y Initial program 100.0%
Taylor expanded in y around inf 83.9%
if -1.68000000000000008e100 < y < -2.1000000000000001e40Initial program 99.9%
Taylor expanded in x around inf 78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in y around inf 78.7%
if -2.1000000000000001e40 < y < -66Initial program 100.0%
Taylor expanded in x around 0 83.9%
+-commutative83.9%
Simplified83.9%
Taylor expanded in y around inf 75.0%
if -66 < y < 1.5e23Initial program 100.0%
Taylor expanded in x around inf 76.6%
+-commutative76.6%
Simplified76.6%
Final simplification79.5%
(FPCore (x y)
:precision binary64
(if (<= y -4.9e+101)
1.0
(if (<= y -6.5e+40)
(/ x y)
(if (<= y -5.2e-54)
(/ y (+ y 1.0))
(if (<= y 2.6e+20) (/ x (+ y 1.0)) 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -4.9e+101) {
tmp = 1.0;
} else if (y <= -6.5e+40) {
tmp = x / y;
} else if (y <= -5.2e-54) {
tmp = y / (y + 1.0);
} else if (y <= 2.6e+20) {
tmp = x / (y + 1.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) :: tmp
if (y <= (-4.9d+101)) then
tmp = 1.0d0
else if (y <= (-6.5d+40)) then
tmp = x / y
else if (y <= (-5.2d-54)) then
tmp = y / (y + 1.0d0)
else if (y <= 2.6d+20) then
tmp = x / (y + 1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4.9e+101) {
tmp = 1.0;
} else if (y <= -6.5e+40) {
tmp = x / y;
} else if (y <= -5.2e-54) {
tmp = y / (y + 1.0);
} else if (y <= 2.6e+20) {
tmp = x / (y + 1.0);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.9e+101: tmp = 1.0 elif y <= -6.5e+40: tmp = x / y elif y <= -5.2e-54: tmp = y / (y + 1.0) elif y <= 2.6e+20: tmp = x / (y + 1.0) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -4.9e+101) tmp = 1.0; elseif (y <= -6.5e+40) tmp = Float64(x / y); elseif (y <= -5.2e-54) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 2.6e+20) tmp = Float64(x / Float64(y + 1.0)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.9e+101) tmp = 1.0; elseif (y <= -6.5e+40) tmp = x / y; elseif (y <= -5.2e-54) tmp = y / (y + 1.0); elseif (y <= 2.6e+20) tmp = x / (y + 1.0); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.9e+101], 1.0, If[LessEqual[y, -6.5e+40], N[(x / y), $MachinePrecision], If[LessEqual[y, -5.2e-54], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+20], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.9 \cdot 10^{+101}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-54}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+20}:\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.89999999999999983e101 or 2.6e20 < y Initial program 100.0%
Taylor expanded in y around inf 83.9%
if -4.89999999999999983e101 < y < -6.5000000000000001e40Initial program 99.9%
Taylor expanded in x around inf 78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in y around inf 78.7%
if -6.5000000000000001e40 < y < -5.20000000000000004e-54Initial program 99.9%
Taylor expanded in x around 0 68.4%
+-commutative68.4%
Simplified68.4%
if -5.20000000000000004e-54 < y < 2.6e20Initial program 100.0%
Taylor expanded in x around inf 79.8%
+-commutative79.8%
Simplified79.8%
Final simplification80.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.82))) (+ 1.0 (/ x y)) (- x (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.82)) {
tmp = 1.0 + (x / y);
} else {
tmp = x - (y * (x + -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)) .or. (.not. (y <= 0.82d0))) then
tmp = 1.0d0 + (x / y)
else
tmp = x - (y * (x + (-1.0d0)))
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 * (x + -1.0));
}
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 * (x + -1.0)) 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(x + -1.0))); 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 * (x + -1.0)); 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[(x + -1.0), $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(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.819999999999999951 < y Initial program 100.0%
Taylor expanded in y around -inf 99.2%
mul-1-neg99.2%
unsub-neg99.2%
mul-1-neg99.2%
sub-neg99.2%
Simplified99.2%
Taylor expanded in x around inf 98.2%
neg-mul-198.2%
distribute-neg-frac98.2%
Simplified98.2%
if -1 < y < 0.819999999999999951Initial program 100.0%
Taylor expanded in y around 0 98.1%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ 1.0 (/ (+ x -1.0) y)) (- x (* y (+ x -1.0)))))
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 * (x + -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)) .or. (.not. (y <= 1.0d0))) then
tmp = 1.0d0 + ((x + (-1.0d0)) / y)
else
tmp = x - (y * (x + (-1.0d0)))
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 * (x + -1.0));
}
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 * (x + -1.0)) 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(x + -1.0))); 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 * (x + -1.0)); 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[(x + -1.0), $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(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around -inf 99.2%
mul-1-neg99.2%
unsub-neg99.2%
mul-1-neg99.2%
sub-neg99.2%
Simplified99.2%
if -1 < y < 1Initial program 100.0%
Taylor expanded in y around 0 98.1%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (or (<= y -66.0) (not (<= y 420000.0))) (+ 1.0 (/ x y)) (/ x (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((y <= -66.0) || !(y <= 420000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (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 ((y <= (-66.0d0)) .or. (.not. (y <= 420000.0d0))) then
tmp = 1.0d0 + (x / y)
else
tmp = x / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -66.0) || !(y <= 420000.0)) {
tmp = 1.0 + (x / y);
} else {
tmp = x / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -66.0) or not (y <= 420000.0): tmp = 1.0 + (x / y) else: tmp = x / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -66.0) || !(y <= 420000.0)) tmp = Float64(1.0 + Float64(x / y)); else tmp = Float64(x / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -66.0) || ~((y <= 420000.0))) tmp = 1.0 + (x / y); else tmp = x / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -66.0], N[Not[LessEqual[y, 420000.0]], $MachinePrecision]], N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -66 \lor \neg \left(y \leq 420000\right):\\
\;\;\;\;1 + \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y + 1}\\
\end{array}
\end{array}
if y < -66 or 4.2e5 < y Initial program 100.0%
Taylor expanded in y around -inf 99.2%
mul-1-neg99.2%
unsub-neg99.2%
mul-1-neg99.2%
sub-neg99.2%
Simplified99.2%
Taylor expanded in x around inf 98.2%
neg-mul-198.2%
distribute-neg-frac98.2%
Simplified98.2%
if -66 < y < 4.2e5Initial program 100.0%
Taylor expanded in x around inf 77.0%
+-commutative77.0%
Simplified77.0%
Final simplification87.6%
(FPCore (x y) :precision binary64 (if (<= y -1.65e+100) 1.0 (if (<= y -3.8e+14) (/ x y) (if (<= y 1.7) x 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -1.65e+100) {
tmp = 1.0;
} else if (y <= -3.8e+14) {
tmp = x / y;
} else if (y <= 1.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 <= (-1.65d+100)) then
tmp = 1.0d0
else if (y <= (-3.8d+14)) then
tmp = x / y
else if (y <= 1.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 <= -1.65e+100) {
tmp = 1.0;
} else if (y <= -3.8e+14) {
tmp = x / y;
} else if (y <= 1.7) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.65e+100: tmp = 1.0 elif y <= -3.8e+14: tmp = x / y elif y <= 1.7: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.65e+100) tmp = 1.0; elseif (y <= -3.8e+14) tmp = Float64(x / y); elseif (y <= 1.7) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.65e+100) tmp = 1.0; elseif (y <= -3.8e+14) tmp = x / y; elseif (y <= 1.7) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.65e+100], 1.0, If[LessEqual[y, -3.8e+14], N[(x / y), $MachinePrecision], If[LessEqual[y, 1.7], x, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+100}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.8 \cdot 10^{+14}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 1.7:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.6500000000000001e100 or 1.69999999999999996 < y Initial program 100.0%
Taylor expanded in y around inf 80.6%
if -1.6500000000000001e100 < y < -3.8e14Initial program 99.9%
Taylor expanded in x around inf 71.4%
+-commutative71.4%
Simplified71.4%
Taylor expanded in y around inf 71.4%
if -3.8e14 < y < 1.69999999999999996Initial program 100.0%
Taylor expanded in y around 0 72.9%
Final simplification76.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 3.3) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.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 <= 3.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 <= 3.3) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 3.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 <= 3.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 <= 3.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, 3.3], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.3:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 3.2999999999999998 < y Initial program 100.0%
Taylor expanded in y around inf 72.9%
if -1 < y < 3.2999999999999998Initial program 100.0%
Taylor expanded in y around 0 74.9%
Final simplification73.9%
(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 38.2%
Final simplification38.2%
herbie shell --seed 2023200
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))