
(FPCore (x y) :precision binary64 (- (* (+ x 1.0) y) x))
double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x + 1.0d0) * y) - x
end function
public static double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
def code(x, y): return ((x + 1.0) * y) - x
function code(x, y) return Float64(Float64(Float64(x + 1.0) * y) - x) end
function tmp = code(x, y) tmp = ((x + 1.0) * y) - x; end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 1\right) \cdot y - x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (* (+ x 1.0) y) x))
double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x + 1.0d0) * y) - x
end function
public static double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
def code(x, y): return ((x + 1.0) * y) - x
function code(x, y) return Float64(Float64(Float64(x + 1.0) * y) - x) end
function tmp = code(x, y) tmp = ((x + 1.0) * y) - x; end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 1\right) \cdot y - x
\end{array}
(FPCore (x y) :precision binary64 (+ y (* x (+ y -1.0))))
double code(double x, double y) {
return y + (x * (y + -1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + (x * (y + (-1.0d0)))
end function
public static double code(double x, double y) {
return y + (x * (y + -1.0));
}
def code(x, y): return y + (x * (y + -1.0))
function code(x, y) return Float64(y + Float64(x * Float64(y + -1.0))) end
function tmp = code(x, y) tmp = y + (x * (y + -1.0)); end
code[x_, y_] := N[(y + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + x \cdot \left(y + -1\right)
\end{array}
Initial program 100.0%
Simplified0
(FPCore (x y)
:precision binary64
(if (<= y -7e+289)
y
(if (<= y -1.55e+127)
(* y x)
(if (<= y -4.6e-30) y (if (<= y 1.0) (- x) (* y x))))))
double code(double x, double y) {
double tmp;
if (y <= -7e+289) {
tmp = y;
} else if (y <= -1.55e+127) {
tmp = y * x;
} else if (y <= -4.6e-30) {
tmp = y;
} else if (y <= 1.0) {
tmp = -x;
} else {
tmp = y * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-7d+289)) then
tmp = y
else if (y <= (-1.55d+127)) then
tmp = y * x
else if (y <= (-4.6d-30)) then
tmp = y
else if (y <= 1.0d0) then
tmp = -x
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7e+289) {
tmp = y;
} else if (y <= -1.55e+127) {
tmp = y * x;
} else if (y <= -4.6e-30) {
tmp = y;
} else if (y <= 1.0) {
tmp = -x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7e+289: tmp = y elif y <= -1.55e+127: tmp = y * x elif y <= -4.6e-30: tmp = y elif y <= 1.0: tmp = -x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -7e+289) tmp = y; elseif (y <= -1.55e+127) tmp = Float64(y * x); elseif (y <= -4.6e-30) tmp = y; elseif (y <= 1.0) tmp = Float64(-x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7e+289) tmp = y; elseif (y <= -1.55e+127) tmp = y * x; elseif (y <= -4.6e-30) tmp = y; elseif (y <= 1.0) tmp = -x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7e+289], y, If[LessEqual[y, -1.55e+127], N[(y * x), $MachinePrecision], If[LessEqual[y, -4.6e-30], y, If[LessEqual[y, 1.0], (-x), N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+289}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{+127}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -4.6 \cdot 10^{-30}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -7.00000000000000043e289 or -1.5500000000000001e127 < y < -4.59999999999999968e-30Initial program 100.0%
Simplified0
Taylor expanded in x around 0 0
Simplified0
if -7.00000000000000043e289 < y < -1.5500000000000001e127 or 1 < y Initial program 100.0%
Simplified0
Taylor expanded in y around inf 0
Simplified0
Taylor expanded in x around inf 0
Simplified0
if -4.59999999999999968e-30 < y < 1Initial program 100.0%
Simplified0
Taylor expanded in y around 0 0
Simplified0
Applied egg-rr0
(FPCore (x y) :precision binary64 (if (<= y -2.85e+289) y (if (<= y -4.4e+194) (* y x) (if (<= y 1.06e+19) (- y x) (* y x)))))
double code(double x, double y) {
double tmp;
if (y <= -2.85e+289) {
tmp = y;
} else if (y <= -4.4e+194) {
tmp = y * x;
} else if (y <= 1.06e+19) {
tmp = y - x;
} else {
tmp = y * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.85d+289)) then
tmp = y
else if (y <= (-4.4d+194)) then
tmp = y * x
else if (y <= 1.06d+19) then
tmp = y - x
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.85e+289) {
tmp = y;
} else if (y <= -4.4e+194) {
tmp = y * x;
} else if (y <= 1.06e+19) {
tmp = y - x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.85e+289: tmp = y elif y <= -4.4e+194: tmp = y * x elif y <= 1.06e+19: tmp = y - x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -2.85e+289) tmp = y; elseif (y <= -4.4e+194) tmp = Float64(y * x); elseif (y <= 1.06e+19) tmp = Float64(y - x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.85e+289) tmp = y; elseif (y <= -4.4e+194) tmp = y * x; elseif (y <= 1.06e+19) tmp = y - x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.85e+289], y, If[LessEqual[y, -4.4e+194], N[(y * x), $MachinePrecision], If[LessEqual[y, 1.06e+19], N[(y - x), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.85 \cdot 10^{+289}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{+194}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 1.06 \cdot 10^{+19}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -2.8499999999999999e289Initial program 100.0%
Simplified0
Taylor expanded in x around 0 0
Simplified0
if -2.8499999999999999e289 < y < -4.4000000000000002e194 or 1.06e19 < y Initial program 100.0%
Simplified0
Taylor expanded in y around inf 0
Simplified0
Taylor expanded in x around inf 0
Simplified0
if -4.4000000000000002e194 < y < 1.06e19Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (+ x 1.0)))) (if (<= y -1.0) t_0 (if (<= y 1.0) (- y x) t_0))))
double code(double x, double y) {
double t_0 = y * (x + 1.0);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = y - 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 = y * (x + 1.0d0)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 1.0d0) then
tmp = y - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (x + 1.0);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = y - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * (x + 1.0) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 1.0: tmp = y - x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * Float64(x + 1.0)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(y - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (x + 1.0); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = y - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(y - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x + 1\right)\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Simplified0
Taylor expanded in y around inf 0
Simplified0
if -1 < y < 1Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y) :precision binary64 (if (<= x -1.6e-49) (- x) (if (<= x 6.2e-36) y (- x))))
double code(double x, double y) {
double tmp;
if (x <= -1.6e-49) {
tmp = -x;
} else if (x <= 6.2e-36) {
tmp = y;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.6d-49)) then
tmp = -x
else if (x <= 6.2d-36) then
tmp = y
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.6e-49) {
tmp = -x;
} else if (x <= 6.2e-36) {
tmp = y;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.6e-49: tmp = -x elif x <= 6.2e-36: tmp = y else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.6e-49) tmp = Float64(-x); elseif (x <= 6.2e-36) tmp = y; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.6e-49) tmp = -x; elseif (x <= 6.2e-36) tmp = y; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.6e-49], (-x), If[LessEqual[x, 6.2e-36], y, (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-49}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-36}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -1.60000000000000001e-49 or 6.1999999999999997e-36 < x Initial program 100.0%
Simplified0
Taylor expanded in y around 0 0
Simplified0
Applied egg-rr0
if -1.60000000000000001e-49 < x < 6.1999999999999997e-36Initial program 100.0%
Simplified0
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 100.0%
Simplified0
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Simplified0
Taylor expanded in y around 0 0
Simplified0
Applied egg-rr0
herbie shell --seed 2024110
(FPCore (x y)
:name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
:precision binary64
(- (* (+ x 1.0) y) x))