
(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 8 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 (<= y -3.6e+24)
1.0
(if (<= y -1.45e-12)
t_0
(if (<= y -2.3e-53)
y
(if (<= y 3.4e-66)
x
(if (<= y 9.8e-20) y (if (<= y 1.8e+23) t_0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (y + 1.0);
double tmp;
if (y <= -3.6e+24) {
tmp = 1.0;
} else if (y <= -1.45e-12) {
tmp = t_0;
} else if (y <= -2.3e-53) {
tmp = y;
} else if (y <= 3.4e-66) {
tmp = x;
} else if (y <= 9.8e-20) {
tmp = y;
} else if (y <= 1.8e+23) {
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.6d+24)) then
tmp = 1.0d0
else if (y <= (-1.45d-12)) then
tmp = t_0
else if (y <= (-2.3d-53)) then
tmp = y
else if (y <= 3.4d-66) then
tmp = x
else if (y <= 9.8d-20) then
tmp = y
else if (y <= 1.8d+23) 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.6e+24) {
tmp = 1.0;
} else if (y <= -1.45e-12) {
tmp = t_0;
} else if (y <= -2.3e-53) {
tmp = y;
} else if (y <= 3.4e-66) {
tmp = x;
} else if (y <= 9.8e-20) {
tmp = y;
} else if (y <= 1.8e+23) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y + 1.0) tmp = 0 if y <= -3.6e+24: tmp = 1.0 elif y <= -1.45e-12: tmp = t_0 elif y <= -2.3e-53: tmp = y elif y <= 3.4e-66: tmp = x elif y <= 9.8e-20: tmp = y elif y <= 1.8e+23: 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.6e+24) tmp = 1.0; elseif (y <= -1.45e-12) tmp = t_0; elseif (y <= -2.3e-53) tmp = y; elseif (y <= 3.4e-66) tmp = x; elseif (y <= 9.8e-20) tmp = y; elseif (y <= 1.8e+23) 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.6e+24) tmp = 1.0; elseif (y <= -1.45e-12) tmp = t_0; elseif (y <= -2.3e-53) tmp = y; elseif (y <= 3.4e-66) tmp = x; elseif (y <= 9.8e-20) tmp = y; elseif (y <= 1.8e+23) 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.6e+24], 1.0, If[LessEqual[y, -1.45e-12], t$95$0, If[LessEqual[y, -2.3e-53], y, If[LessEqual[y, 3.4e-66], x, If[LessEqual[y, 9.8e-20], y, If[LessEqual[y, 1.8e+23], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
\mathbf{if}\;y \leq -3.6 \cdot 10^{+24}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.3 \cdot 10^{-53}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-66}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-20}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+23}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.59999999999999983e24 or 1.7999999999999999e23 < y Initial program 100.0%
Taylor expanded in y around inf 80.4%
if -3.59999999999999983e24 < y < -1.4500000000000001e-12 or 9.8000000000000003e-20 < y < 1.7999999999999999e23Initial program 99.9%
Taylor expanded in x around inf 74.8%
+-commutative74.8%
Simplified74.8%
if -1.4500000000000001e-12 < y < -2.3000000000000001e-53 or 3.39999999999999997e-66 < y < 9.8000000000000003e-20Initial program 100.0%
Taylor expanded in x around 0 84.9%
+-commutative84.9%
Simplified84.9%
Taylor expanded in y around 0 84.8%
if -2.3000000000000001e-53 < y < 3.39999999999999997e-66Initial program 100.0%
Taylor expanded in y around 0 85.0%
Final simplification82.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (+ x -1.0) y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -1150000000.0)
t_0
(if (<= y 5.1e-66)
t_1
(if (<= y 3.3e-20) (/ y (+ y 1.0)) (if (<= y 23000.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 <= -1150000000.0) {
tmp = t_0;
} else if (y <= 5.1e-66) {
tmp = t_1;
} else if (y <= 3.3e-20) {
tmp = y / (y + 1.0);
} else if (y <= 23000.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 <= (-1150000000.0d0)) then
tmp = t_0
else if (y <= 5.1d-66) then
tmp = t_1
else if (y <= 3.3d-20) then
tmp = y / (y + 1.0d0)
else if (y <= 23000.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 <= -1150000000.0) {
tmp = t_0;
} else if (y <= 5.1e-66) {
tmp = t_1;
} else if (y <= 3.3e-20) {
tmp = y / (y + 1.0);
} else if (y <= 23000.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 <= -1150000000.0: tmp = t_0 elif y <= 5.1e-66: tmp = t_1 elif y <= 3.3e-20: tmp = y / (y + 1.0) elif y <= 23000.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 <= -1150000000.0) tmp = t_0; elseif (y <= 5.1e-66) tmp = t_1; elseif (y <= 3.3e-20) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 23000.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 <= -1150000000.0) tmp = t_0; elseif (y <= 5.1e-66) tmp = t_1; elseif (y <= 3.3e-20) tmp = y / (y + 1.0); elseif (y <= 23000.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, -1150000000.0], t$95$0, If[LessEqual[y, 5.1e-66], t$95$1, If[LessEqual[y, 3.3e-20], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 23000.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 -1150000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-66}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-20}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 23000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.15e9 or 23000 < y Initial program 100.0%
Taylor expanded in y around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
mul-1-neg99.4%
sub-neg99.4%
Simplified99.4%
if -1.15e9 < y < 5.10000000000000022e-66 or 3.3e-20 < y < 23000Initial program 100.0%
Taylor expanded in x around inf 81.1%
+-commutative81.1%
Simplified81.1%
if 5.10000000000000022e-66 < y < 3.3e-20Initial program 100.0%
Taylor expanded in x around 0 78.3%
+-commutative78.3%
Simplified78.3%
Final simplification89.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))) (t_1 (/ x (+ y 1.0))))
(if (<= y -1900000000.0)
t_0
(if (<= y 2.3e-66)
t_1
(if (<= y 2.8e-19)
(/ y (+ y 1.0))
(if (<= y 1100000000000.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 <= -1900000000.0) {
tmp = t_0;
} else if (y <= 2.3e-66) {
tmp = t_1;
} else if (y <= 2.8e-19) {
tmp = y / (y + 1.0);
} else if (y <= 1100000000000.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 <= (-1900000000.0d0)) then
tmp = t_0
else if (y <= 2.3d-66) then
tmp = t_1
else if (y <= 2.8d-19) then
tmp = y / (y + 1.0d0)
else if (y <= 1100000000000.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 <= -1900000000.0) {
tmp = t_0;
} else if (y <= 2.3e-66) {
tmp = t_1;
} else if (y <= 2.8e-19) {
tmp = y / (y + 1.0);
} else if (y <= 1100000000000.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 <= -1900000000.0: tmp = t_0 elif y <= 2.3e-66: tmp = t_1 elif y <= 2.8e-19: tmp = y / (y + 1.0) elif y <= 1100000000000.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 <= -1900000000.0) tmp = t_0; elseif (y <= 2.3e-66) tmp = t_1; elseif (y <= 2.8e-19) tmp = Float64(y / Float64(y + 1.0)); elseif (y <= 1100000000000.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 <= -1900000000.0) tmp = t_0; elseif (y <= 2.3e-66) tmp = t_1; elseif (y <= 2.8e-19) tmp = y / (y + 1.0); elseif (y <= 1100000000000.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, -1900000000.0], t$95$0, If[LessEqual[y, 2.3e-66], t$95$1, If[LessEqual[y, 2.8e-19], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1100000000000.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 -1900000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-66}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-19}:\\
\;\;\;\;\frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 1100000000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.9e9 or 1.1e12 < y Initial program 100.0%
Taylor expanded in y around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
neg-mul-199.8%
Simplified99.8%
if -1.9e9 < y < 2.29999999999999992e-66 or 2.80000000000000003e-19 < y < 1.1e12Initial program 100.0%
Taylor expanded in x around inf 80.8%
+-commutative80.8%
Simplified80.8%
if 2.29999999999999992e-66 < y < 2.80000000000000003e-19Initial program 100.0%
Taylor expanded in x around 0 78.3%
+-commutative78.3%
Simplified78.3%
Final simplification89.3%
(FPCore (x y)
:precision binary64
(if (<= y -550000000.0)
1.0
(if (<= y -1.35e-49)
y
(if (<= y 1.3e-67) x (if (<= y 1.85e-20) y (if (<= y 4.3) x 1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -550000000.0) {
tmp = 1.0;
} else if (y <= -1.35e-49) {
tmp = y;
} else if (y <= 1.3e-67) {
tmp = x;
} else if (y <= 1.85e-20) {
tmp = y;
} else if (y <= 4.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 <= (-550000000.0d0)) then
tmp = 1.0d0
else if (y <= (-1.35d-49)) then
tmp = y
else if (y <= 1.3d-67) then
tmp = x
else if (y <= 1.85d-20) then
tmp = y
else if (y <= 4.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 <= -550000000.0) {
tmp = 1.0;
} else if (y <= -1.35e-49) {
tmp = y;
} else if (y <= 1.3e-67) {
tmp = x;
} else if (y <= 1.85e-20) {
tmp = y;
} else if (y <= 4.3) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -550000000.0: tmp = 1.0 elif y <= -1.35e-49: tmp = y elif y <= 1.3e-67: tmp = x elif y <= 1.85e-20: tmp = y elif y <= 4.3: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -550000000.0) tmp = 1.0; elseif (y <= -1.35e-49) tmp = y; elseif (y <= 1.3e-67) tmp = x; elseif (y <= 1.85e-20) tmp = y; elseif (y <= 4.3) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -550000000.0) tmp = 1.0; elseif (y <= -1.35e-49) tmp = y; elseif (y <= 1.3e-67) tmp = x; elseif (y <= 1.85e-20) tmp = y; elseif (y <= 4.3) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -550000000.0], 1.0, If[LessEqual[y, -1.35e-49], y, If[LessEqual[y, 1.3e-67], x, If[LessEqual[y, 1.85e-20], y, If[LessEqual[y, 4.3], x, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -550000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{-49}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-67}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-20}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 4.3:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.5e8 or 4.29999999999999982 < y Initial program 100.0%
Taylor expanded in y around inf 75.3%
if -5.5e8 < y < -1.35e-49 or 1.2999999999999999e-67 < y < 1.85e-20Initial program 100.0%
Taylor expanded in x around 0 67.7%
+-commutative67.7%
Simplified67.7%
Taylor expanded in y around 0 67.8%
if -1.35e-49 < y < 1.2999999999999999e-67 or 1.85e-20 < y < 4.29999999999999982Initial program 100.0%
Taylor expanded in y around 0 83.0%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (or (<= x -6e+35) (not (<= x 1.05e+24))) (/ x (+ y 1.0)) (/ y (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -6e+35) || !(x <= 1.05e+24)) {
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 <= (-6d+35)) .or. (.not. (x <= 1.05d+24))) 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 <= -6e+35) || !(x <= 1.05e+24)) {
tmp = x / (y + 1.0);
} else {
tmp = y / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -6e+35) or not (x <= 1.05e+24): tmp = x / (y + 1.0) else: tmp = y / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -6e+35) || !(x <= 1.05e+24)) 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 <= -6e+35) || ~((x <= 1.05e+24))) tmp = x / (y + 1.0); else tmp = y / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -6e+35], N[Not[LessEqual[x, 1.05e+24]], $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 -6 \cdot 10^{+35} \lor \neg \left(x \leq 1.05 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{x}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + 1}\\
\end{array}
\end{array}
if x < -5.99999999999999981e35 or 1.0500000000000001e24 < x Initial program 100.0%
Taylor expanded in x around inf 86.0%
+-commutative86.0%
Simplified86.0%
if -5.99999999999999981e35 < x < 1.0500000000000001e24Initial program 100.0%
Taylor expanded in x around 0 74.9%
+-commutative74.9%
Simplified74.9%
Final simplification79.7%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y 3.5) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= 3.5) {
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.5d0) 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.5) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= 3.5: 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.5) 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.5) 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.5], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.5:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 3.5 < y Initial program 100.0%
Taylor expanded in y around inf 73.6%
if -1 < y < 3.5Initial program 100.0%
Taylor expanded in y around 0 75.4%
Final simplification74.5%
(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 37.3%
Final simplification37.3%
herbie shell --seed 2023202
(FPCore (x y)
:name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
:precision binary64
(/ (+ x y) (+ y 1.0)))