
(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 5 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 (<= (- 1.0 x) -2e+161)
(- x)
(if (<= (- 1.0 x) -2e+92)
(- y)
(if (or (<= (- 1.0 x) -4000000000.0) (not (<= (- 1.0 x) 2.0)))
(- 1.0 x)
(- 1.0 y)))))
double code(double x, double y) {
double tmp;
if ((1.0 - x) <= -2e+161) {
tmp = -x;
} else if ((1.0 - x) <= -2e+92) {
tmp = -y;
} else if (((1.0 - x) <= -4000000000.0) || !((1.0 - x) <= 2.0)) {
tmp = 1.0 - x;
} else {
tmp = 1.0 - y;
}
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) <= (-2d+161)) then
tmp = -x
else if ((1.0d0 - x) <= (-2d+92)) then
tmp = -y
else if (((1.0d0 - x) <= (-4000000000.0d0)) .or. (.not. ((1.0d0 - x) <= 2.0d0))) then
tmp = 1.0d0 - x
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((1.0 - x) <= -2e+161) {
tmp = -x;
} else if ((1.0 - x) <= -2e+92) {
tmp = -y;
} else if (((1.0 - x) <= -4000000000.0) || !((1.0 - x) <= 2.0)) {
tmp = 1.0 - x;
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (1.0 - x) <= -2e+161: tmp = -x elif (1.0 - x) <= -2e+92: tmp = -y elif ((1.0 - x) <= -4000000000.0) or not ((1.0 - x) <= 2.0): tmp = 1.0 - x else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if (Float64(1.0 - x) <= -2e+161) tmp = Float64(-x); elseif (Float64(1.0 - x) <= -2e+92) tmp = Float64(-y); elseif ((Float64(1.0 - x) <= -4000000000.0) || !(Float64(1.0 - x) <= 2.0)) tmp = Float64(1.0 - x); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((1.0 - x) <= -2e+161) tmp = -x; elseif ((1.0 - x) <= -2e+92) tmp = -y; elseif (((1.0 - x) <= -4000000000.0) || ~(((1.0 - x) <= 2.0))) tmp = 1.0 - x; else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(1.0 - x), $MachinePrecision], -2e+161], (-x), If[LessEqual[N[(1.0 - x), $MachinePrecision], -2e+92], (-y), If[Or[LessEqual[N[(1.0 - x), $MachinePrecision], -4000000000.0], N[Not[LessEqual[N[(1.0 - x), $MachinePrecision], 2.0]], $MachinePrecision]], N[(1.0 - x), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \leq -2 \cdot 10^{+161}:\\
\;\;\;\;-x\\
\mathbf{elif}\;1 - x \leq -2 \cdot 10^{+92}:\\
\;\;\;\;-y\\
\mathbf{elif}\;1 - x \leq -4000000000 \lor \neg \left(1 - x \leq 2\right):\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if (-.f64 1 x) < -2.0000000000000001e161Initial program 100.0%
Taylor expanded in x around inf 89.1%
neg-mul-189.1%
Simplified89.1%
if -2.0000000000000001e161 < (-.f64 1 x) < -2.0000000000000001e92Initial program 100.0%
Taylor expanded in y around inf 75.0%
neg-mul-175.0%
Simplified75.0%
if -2.0000000000000001e92 < (-.f64 1 x) < -4e9 or 2 < (-.f64 1 x) Initial program 100.0%
Taylor expanded in y around 0 75.2%
if -4e9 < (-.f64 1 x) < 2Initial program 100.0%
Taylor expanded in x around 0 99.6%
Final simplification89.4%
(FPCore (x y) :precision binary64 (if (or (<= y -2400000.0) (not (<= y 3350.0))) (- y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -2400000.0) || !(y <= 3350.0)) {
tmp = -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 ((y <= (-2400000.0d0)) .or. (.not. (y <= 3350.0d0))) then
tmp = -y
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2400000.0) || !(y <= 3350.0)) {
tmp = -y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2400000.0) or not (y <= 3350.0): tmp = -y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -2400000.0) || !(y <= 3350.0)) tmp = Float64(-y); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2400000.0) || ~((y <= 3350.0))) tmp = -y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2400000.0], N[Not[LessEqual[y, 3350.0]], $MachinePrecision]], (-y), N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2400000 \lor \neg \left(y \leq 3350\right):\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -2.4e6 or 3350 < y Initial program 100.0%
Taylor expanded in y around inf 72.8%
neg-mul-172.8%
Simplified72.8%
if -2.4e6 < y < 3350Initial program 100.0%
Taylor expanded in y around 0 99.1%
Final simplification85.7%
(FPCore (x y) :precision binary64 (if (or (<= y -10000000.0) (not (<= y 19500.0))) (- y) (- x)))
double code(double x, double y) {
double tmp;
if ((y <= -10000000.0) || !(y <= 19500.0)) {
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 ((y <= (-10000000.0d0)) .or. (.not. (y <= 19500.0d0))) then
tmp = -y
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -10000000.0) || !(y <= 19500.0)) {
tmp = -y;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -10000000.0) or not (y <= 19500.0): tmp = -y else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if ((y <= -10000000.0) || !(y <= 19500.0)) tmp = Float64(-y); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -10000000.0) || ~((y <= 19500.0))) tmp = -y; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -10000000.0], N[Not[LessEqual[y, 19500.0]], $MachinePrecision]], (-y), (-x)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -10000000 \lor \neg \left(y \leq 19500\right):\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if y < -1e7 or 19500 < y Initial program 100.0%
Taylor expanded in y around inf 72.8%
neg-mul-172.8%
Simplified72.8%
if -1e7 < y < 19500Initial program 100.0%
Taylor expanded in x around inf 46.2%
neg-mul-146.2%
Simplified46.2%
Final simplification59.7%
(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 Float64(-x) end
function tmp = code(x, y) tmp = -x; end
code[x_, y_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 36.5%
neg-mul-136.5%
Simplified36.5%
Final simplification36.5%
herbie shell --seed 2023305
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))