
(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%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
(FPCore (x y)
:precision binary64
(if (<= y -7.8e+25)
(* y x)
(if (<= y -3.1e-9)
y
(if (<= y 6.2e-92) (- 0.0 x) (if (<= y 2.65e+14) y (* y x))))))
double code(double x, double y) {
double tmp;
if (y <= -7.8e+25) {
tmp = y * x;
} else if (y <= -3.1e-9) {
tmp = y;
} else if (y <= 6.2e-92) {
tmp = 0.0 - x;
} else if (y <= 2.65e+14) {
tmp = y;
} 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 <= (-7.8d+25)) then
tmp = y * x
else if (y <= (-3.1d-9)) then
tmp = y
else if (y <= 6.2d-92) then
tmp = 0.0d0 - x
else if (y <= 2.65d+14) then
tmp = y
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7.8e+25) {
tmp = y * x;
} else if (y <= -3.1e-9) {
tmp = y;
} else if (y <= 6.2e-92) {
tmp = 0.0 - x;
} else if (y <= 2.65e+14) {
tmp = y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.8e+25: tmp = y * x elif y <= -3.1e-9: tmp = y elif y <= 6.2e-92: tmp = 0.0 - x elif y <= 2.65e+14: tmp = y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -7.8e+25) tmp = Float64(y * x); elseif (y <= -3.1e-9) tmp = y; elseif (y <= 6.2e-92) tmp = Float64(0.0 - x); elseif (y <= 2.65e+14) tmp = y; else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7.8e+25) tmp = y * x; elseif (y <= -3.1e-9) tmp = y; elseif (y <= 6.2e-92) tmp = 0.0 - x; elseif (y <= 2.65e+14) tmp = y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7.8e+25], N[(y * x), $MachinePrecision], If[LessEqual[y, -3.1e-9], y, If[LessEqual[y, 6.2e-92], N[(0.0 - x), $MachinePrecision], If[LessEqual[y, 2.65e+14], y, N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+25}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-92}:\\
\;\;\;\;0 - x\\
\mathbf{elif}\;y \leq 2.65 \cdot 10^{+14}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -7.8000000000000004e25 or 2.65e14 < y Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in x around inf
Simplified63.9%
if -7.8000000000000004e25 < y < -3.10000000000000005e-9 or 6.2000000000000002e-92 < y < 2.65e14Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified70.0%
if -3.10000000000000005e-9 < y < 6.2000000000000002e-92Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in y around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6481.3%
Simplified81.3%
sub0-negN/A
neg-lowering-neg.f6481.3%
Applied egg-rr81.3%
Final simplification72.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (+ x 1.0)))) (if (<= y -205.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 <= -205.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 <= (-205.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 <= -205.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 <= -205.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 <= -205.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 <= -205.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, -205.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 -205:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -205 or 1 < y Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6498.9%
Simplified98.9%
if -205 < y < 1Initial program 100.0%
Taylor expanded in x around 0
Simplified99.3%
(FPCore (x y) :precision binary64 (if (<= y -1.65e+22) (* y x) (if (<= y 69000000000.0) (- y x) (* y x))))
double code(double x, double y) {
double tmp;
if (y <= -1.65e+22) {
tmp = y * x;
} else if (y <= 69000000000.0) {
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 <= (-1.65d+22)) then
tmp = y * x
else if (y <= 69000000000.0d0) 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 <= -1.65e+22) {
tmp = y * x;
} else if (y <= 69000000000.0) {
tmp = y - x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.65e+22: tmp = y * x elif y <= 69000000000.0: tmp = y - x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.65e+22) tmp = Float64(y * x); elseif (y <= 69000000000.0) tmp = Float64(y - x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.65e+22) tmp = y * x; elseif (y <= 69000000000.0) tmp = y - x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.65e+22], N[(y * x), $MachinePrecision], If[LessEqual[y, 69000000000.0], N[(y - x), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+22}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 69000000000:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -1.6499999999999999e22 or 6.9e10 < y Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in x around inf
Simplified63.9%
if -1.6499999999999999e22 < y < 6.9e10Initial program 100.0%
Taylor expanded in x around 0
Simplified98.1%
(FPCore (x y) :precision binary64 (if (<= y -4.5e-12) y (if (<= y 1.1e-91) (- 0.0 x) y)))
double code(double x, double y) {
double tmp;
if (y <= -4.5e-12) {
tmp = y;
} else if (y <= 1.1e-91) {
tmp = 0.0 - x;
} else {
tmp = y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-4.5d-12)) then
tmp = y
else if (y <= 1.1d-91) then
tmp = 0.0d0 - x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4.5e-12) {
tmp = y;
} else if (y <= 1.1e-91) {
tmp = 0.0 - x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.5e-12: tmp = y elif y <= 1.1e-91: tmp = 0.0 - x else: tmp = y return tmp
function code(x, y) tmp = 0.0 if (y <= -4.5e-12) tmp = y; elseif (y <= 1.1e-91) tmp = Float64(0.0 - x); else tmp = y; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.5e-12) tmp = y; elseif (y <= 1.1e-91) tmp = 0.0 - x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.5e-12], y, If[LessEqual[y, 1.1e-91], N[(0.0 - x), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-12}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-91}:\\
\;\;\;\;0 - x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -4.49999999999999981e-12 or 1.1e-91 < y Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified45.3%
if -4.49999999999999981e-12 < y < 1.1e-91Initial program 100.0%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in y around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6481.3%
Simplified81.3%
sub0-negN/A
neg-lowering-neg.f6481.3%
Applied egg-rr81.3%
Final simplification61.5%
(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%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified33.8%
(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%
sub-negN/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
neg-mul-1N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in y around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6440.8%
Simplified40.8%
sub0-negN/A
neg-lowering-neg.f6440.8%
Applied egg-rr40.8%
neg-sub0N/A
flip3--N/A
metadata-evalN/A
neg-sub0N/A
cube-negN/A
sqr-powN/A
unpow-prod-downN/A
sqr-negN/A
pow-prod-downN/A
sqr-powN/A
metadata-evalN/A
+-lft-identityN/A
distribute-rgt-outN/A
+-commutativeN/A
+-lft-identityN/A
pow2N/A
pow-divN/A
metadata-evalN/A
unpow12.7%
Applied egg-rr2.7%
herbie shell --seed 2024145
(FPCore (x y)
:name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
:precision binary64
(- (* (+ x 1.0) y) x))