
(FPCore (x y) :precision binary64 (- (- 1.0 x) y))
double code(double x, double y) {
return (1.0 - x) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) - y
end function
public static double code(double x, double y) {
return (1.0 - x) - y;
}
def code(x, y): return (1.0 - x) - y
function code(x, y) return Float64(Float64(1.0 - x) - y) end
function tmp = code(x, y) tmp = (1.0 - x) - y; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) - y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (- 1.0 x) y))
double code(double x, double y) {
return (1.0 - x) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) - y
end function
public static double code(double x, double y) {
return (1.0 - x) - y;
}
def code(x, y): return (1.0 - x) - y
function code(x, y) return Float64(Float64(1.0 - x) - y) end
function tmp = code(x, y) tmp = (1.0 - x) - y; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) - y
\end{array}
(FPCore (x y) :precision binary64 (- (- 1.0 x) y))
double code(double x, double y) {
return (1.0 - x) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) - y
end function
public static double code(double x, double y) {
return (1.0 - x) - y;
}
def code(x, y): return (1.0 - x) - y
function code(x, y) return Float64(Float64(1.0 - x) - y) end
function tmp = code(x, y) tmp = (1.0 - x) - y; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) - y
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 2.6e-265) (- x) (if (<= y 5e-17) 1.0 (if (<= y 3e+49) (- x) (- y)))))
double code(double x, double y) {
double tmp;
if (y <= 2.6e-265) {
tmp = -x;
} else if (y <= 5e-17) {
tmp = 1.0;
} else if (y <= 3e+49) {
tmp = -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 <= 2.6d-265) then
tmp = -x
else if (y <= 5d-17) then
tmp = 1.0d0
else if (y <= 3d+49) then
tmp = -x
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.6e-265) {
tmp = -x;
} else if (y <= 5e-17) {
tmp = 1.0;
} else if (y <= 3e+49) {
tmp = -x;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.6e-265: tmp = -x elif y <= 5e-17: tmp = 1.0 elif y <= 3e+49: tmp = -x else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= 2.6e-265) tmp = Float64(-x); elseif (y <= 5e-17) tmp = 1.0; elseif (y <= 3e+49) tmp = Float64(-x); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.6e-265) tmp = -x; elseif (y <= 5e-17) tmp = 1.0; elseif (y <= 3e+49) tmp = -x; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.6e-265], (-x), If[LessEqual[y, 5e-17], 1.0, If[LessEqual[y, 3e+49], (-x), (-y)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.6 \cdot 10^{-265}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-17}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+49}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 2.6000000000000001e-265 or 4.9999999999999999e-17 < y < 3.0000000000000002e49Initial program 100.0%
Taylor expanded in x around inf 46.5%
neg-mul-146.5%
Simplified46.5%
if 2.6000000000000001e-265 < y < 4.9999999999999999e-17Initial program 100.0%
expm1-log1p-u85.2%
associate--l-85.2%
Applied egg-rr85.2%
Taylor expanded in x around 0 68.5%
Taylor expanded in y around 0 68.5%
if 3.0000000000000002e49 < y Initial program 100.0%
Taylor expanded in y around inf 80.2%
neg-mul-180.2%
Simplified80.2%
Final simplification58.1%
(FPCore (x y) :precision binary64 (if (<= (- 1.0 x) 1.0000000000002) (- 1.0 y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((1.0 - x) <= 1.0000000000002) {
tmp = 1.0 - y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((1.0d0 - x) <= 1.0000000000002d0) then
tmp = 1.0d0 - y
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((1.0 - x) <= 1.0000000000002) {
tmp = 1.0 - y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (1.0 - x) <= 1.0000000000002: tmp = 1.0 - y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if (Float64(1.0 - x) <= 1.0000000000002) tmp = Float64(1.0 - y); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((1.0 - x) <= 1.0000000000002) tmp = 1.0 - y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(1.0 - x), $MachinePrecision], 1.0000000000002], N[(1.0 - y), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \leq 1.0000000000002:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 1 x) < 1.00000000000020006Initial program 100.0%
Taylor expanded in x around 0 76.1%
if 1.00000000000020006 < (-.f64 1 x) Initial program 100.0%
Taylor expanded in y around 0 76.3%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (<= y 2e+49) (- 1.0 x) (- y)))
double code(double x, double y) {
double tmp;
if (y <= 2e+49) {
tmp = 1.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 <= 2d+49) then
tmp = 1.0d0 - x
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2e+49) {
tmp = 1.0 - x;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2e+49: tmp = 1.0 - x else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= 2e+49) tmp = Float64(1.0 - x); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2e+49) tmp = 1.0 - x; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2e+49], N[(1.0 - x), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+49}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.99999999999999989e49Initial program 100.0%
Taylor expanded in y around 0 76.1%
if 1.99999999999999989e49 < y Initial program 100.0%
Taylor expanded in y around inf 80.2%
neg-mul-180.2%
Simplified80.2%
Final simplification76.9%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (- x) 1.0))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
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 (x <= (-1.0d0)) then
tmp = -x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = -x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = -x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(-x); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = -x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], (-x), 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around inf 75.7%
neg-mul-175.7%
Simplified75.7%
if -1 < x Initial program 100.0%
expm1-log1p-u54.8%
associate--l-54.8%
Applied egg-rr54.8%
Taylor expanded in x around 0 54.0%
Taylor expanded in y around 0 35.7%
Final simplification45.7%
(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%
expm1-log1p-u60.6%
associate--l-60.6%
Applied egg-rr60.6%
Taylor expanded in x around 0 42.7%
Taylor expanded in y around 0 27.9%
Final simplification27.9%
herbie shell --seed 2023271
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))