
(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 -5.2e+136)
(* y x)
(if (<= y -8.2e-42)
y
(if (<= y 4.2e-46) (- 0.0 x) (if (<= y 1.55e+91) y (* y x))))))
double code(double x, double y) {
double tmp;
if (y <= -5.2e+136) {
tmp = y * x;
} else if (y <= -8.2e-42) {
tmp = y;
} else if (y <= 4.2e-46) {
tmp = 0.0 - x;
} else if (y <= 1.55e+91) {
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 <= (-5.2d+136)) then
tmp = y * x
else if (y <= (-8.2d-42)) then
tmp = y
else if (y <= 4.2d-46) then
tmp = 0.0d0 - x
else if (y <= 1.55d+91) 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 <= -5.2e+136) {
tmp = y * x;
} else if (y <= -8.2e-42) {
tmp = y;
} else if (y <= 4.2e-46) {
tmp = 0.0 - x;
} else if (y <= 1.55e+91) {
tmp = y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.2e+136: tmp = y * x elif y <= -8.2e-42: tmp = y elif y <= 4.2e-46: tmp = 0.0 - x elif y <= 1.55e+91: tmp = y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -5.2e+136) tmp = Float64(y * x); elseif (y <= -8.2e-42) tmp = y; elseif (y <= 4.2e-46) tmp = Float64(0.0 - x); elseif (y <= 1.55e+91) tmp = y; else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.2e+136) tmp = y * x; elseif (y <= -8.2e-42) tmp = y; elseif (y <= 4.2e-46) tmp = 0.0 - x; elseif (y <= 1.55e+91) tmp = y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.2e+136], N[(y * x), $MachinePrecision], If[LessEqual[y, -8.2e-42], y, If[LessEqual[y, 4.2e-46], N[(0.0 - x), $MachinePrecision], If[LessEqual[y, 1.55e+91], y, N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+136}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-42}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-46}:\\
\;\;\;\;0 - x\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+91}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -5.2000000000000003e136 or 1.54999999999999999e91 < 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 inf
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f6465.8%
Simplified65.8%
Taylor expanded in y around inf
*-lowering-*.f6465.8%
Simplified65.8%
if -5.2000000000000003e136 < y < -8.2000000000000003e-42 or 4.19999999999999975e-46 < y < 1.54999999999999999e91Initial 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
Simplified63.9%
if -8.2000000000000003e-42 < y < 4.19999999999999975e-46Initial 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--.f6484.7%
Simplified84.7%
sub0-negN/A
neg-lowering-neg.f6484.7%
Applied egg-rr84.7%
Final simplification73.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ y (* y x)))) (if (<= y -1.0) t_0 (if (<= y 5.1e-8) (- y x) t_0))))
double code(double x, double y) {
double t_0 = y + (y * x);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 5.1e-8) {
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 + (y * x)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 5.1d-8) 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 + (y * x);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 5.1e-8) {
tmp = y - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y + (y * x) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 5.1e-8: tmp = y - x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y + Float64(y * x)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 5.1e-8) tmp = Float64(y - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y + (y * x); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 5.1e-8) tmp = y - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 5.1e-8], N[(y - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + y \cdot x\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-8}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 5.10000000000000001e-8 < 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-*.f6499.2%
Simplified99.2%
if -1 < y < 5.10000000000000001e-8Initial program 100.0%
Taylor expanded in x around 0
Simplified99.8%
Final simplification99.4%
(FPCore (x y) :precision binary64 (let* ((t_0 (* x (+ y -1.0)))) (if (<= x -4.5) t_0 (if (<= x 0.0126) (- y x) t_0))))
double code(double x, double y) {
double t_0 = x * (y + -1.0);
double tmp;
if (x <= -4.5) {
tmp = t_0;
} else if (x <= 0.0126) {
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 = x * (y + (-1.0d0))
if (x <= (-4.5d0)) then
tmp = t_0
else if (x <= 0.0126d0) 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 = x * (y + -1.0);
double tmp;
if (x <= -4.5) {
tmp = t_0;
} else if (x <= 0.0126) {
tmp = y - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (y + -1.0) tmp = 0 if x <= -4.5: tmp = t_0 elif x <= 0.0126: tmp = y - x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(y + -1.0)) tmp = 0.0 if (x <= -4.5) tmp = t_0; elseif (x <= 0.0126) tmp = Float64(y - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (y + -1.0); tmp = 0.0; if (x <= -4.5) tmp = t_0; elseif (x <= 0.0126) tmp = y - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.5], t$95$0, If[LessEqual[x, 0.0126], N[(y - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y + -1\right)\\
\mathbf{if}\;x \leq -4.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.0126:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.5 or 0.0126 < x 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 inf
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f6499.2%
Simplified99.2%
if -4.5 < x < 0.0126Initial program 100.0%
Taylor expanded in x around 0
Simplified98.6%
Final simplification98.9%
(FPCore (x y) :precision binary64 (if (<= y -7e+136) (* y x) (if (<= y 3.4e+90) (- y x) (* y x))))
double code(double x, double y) {
double tmp;
if (y <= -7e+136) {
tmp = y * x;
} else if (y <= 3.4e+90) {
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 <= (-7d+136)) then
tmp = y * x
else if (y <= 3.4d+90) 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 <= -7e+136) {
tmp = y * x;
} else if (y <= 3.4e+90) {
tmp = y - x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7e+136: tmp = y * x elif y <= 3.4e+90: tmp = y - x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -7e+136) tmp = Float64(y * x); elseif (y <= 3.4e+90) tmp = Float64(y - x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7e+136) tmp = y * x; elseif (y <= 3.4e+90) tmp = y - x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7e+136], N[(y * x), $MachinePrecision], If[LessEqual[y, 3.4e+90], N[(y - x), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+136}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+90}:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -7.00000000000000002e136 or 3.40000000000000018e90 < 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 inf
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f6465.8%
Simplified65.8%
Taylor expanded in y around inf
*-lowering-*.f6465.8%
Simplified65.8%
if -7.00000000000000002e136 < y < 3.40000000000000018e90Initial program 100.0%
Taylor expanded in x around 0
Simplified87.1%
Final simplification81.1%
(FPCore (x y) :precision binary64 (if (<= y -8.2e-42) y (if (<= y 4.2e-46) (- 0.0 x) y)))
double code(double x, double y) {
double tmp;
if (y <= -8.2e-42) {
tmp = y;
} else if (y <= 4.2e-46) {
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 <= (-8.2d-42)) then
tmp = y
else if (y <= 4.2d-46) 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 <= -8.2e-42) {
tmp = y;
} else if (y <= 4.2e-46) {
tmp = 0.0 - x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.2e-42: tmp = y elif y <= 4.2e-46: tmp = 0.0 - x else: tmp = y return tmp
function code(x, y) tmp = 0.0 if (y <= -8.2e-42) tmp = y; elseif (y <= 4.2e-46) tmp = Float64(0.0 - x); else tmp = y; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8.2e-42) tmp = y; elseif (y <= 4.2e-46) tmp = 0.0 - x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.2e-42], y, If[LessEqual[y, 4.2e-46], N[(0.0 - x), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{-42}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-46}:\\
\;\;\;\;0 - x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -8.2000000000000003e-42 or 4.19999999999999975e-46 < 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
Simplified50.2%
if -8.2000000000000003e-42 < y < 4.19999999999999975e-46Initial 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--.f6484.7%
Simplified84.7%
sub0-negN/A
neg-lowering-neg.f6484.7%
Applied egg-rr84.7%
Final simplification65.4%
(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
Simplified35.5%
herbie shell --seed 2024150
(FPCore (x y)
:name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
:precision binary64
(- (* (+ x 1.0) y) x))