
(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 (or (<= y -2.6e+32) (not (<= y 1.6e+38))) (- y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -2.6e+32) || !(y <= 1.6e+38)) {
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 <= (-2.6d+32)) .or. (.not. (y <= 1.6d+38))) 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 <= -2.6e+32) || !(y <= 1.6e+38)) {
tmp = -y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.6e+32) or not (y <= 1.6e+38): tmp = -y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.6e+32) || !(y <= 1.6e+38)) tmp = Float64(-y); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.6e+32) || ~((y <= 1.6e+38))) tmp = -y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.6e+32], N[Not[LessEqual[y, 1.6e+38]], $MachinePrecision]], (-y), N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+32} \lor \neg \left(y \leq 1.6 \cdot 10^{+38}\right):\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -2.6000000000000002e32 or 1.59999999999999993e38 < y Initial program 100.0%
Taylor expanded in y around inf 79.0%
neg-mul-179.0%
Simplified79.0%
if -2.6000000000000002e32 < y < 1.59999999999999993e38Initial program 100.0%
Taylor expanded in y around 0 98.4%
Final simplification88.3%
(FPCore (x y) :precision binary64 (if (<= y -4.4e+29) (- y) (if (<= y 1.5e+40) (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
double tmp;
if (y <= -4.4e+29) {
tmp = -y;
} else if (y <= 1.5e+40) {
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 (y <= (-4.4d+29)) then
tmp = -y
else if (y <= 1.5d+40) 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 (y <= -4.4e+29) {
tmp = -y;
} else if (y <= 1.5e+40) {
tmp = 1.0 - x;
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.4e+29: tmp = -y elif y <= 1.5e+40: tmp = 1.0 - x else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if (y <= -4.4e+29) tmp = Float64(-y); elseif (y <= 1.5e+40) 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 (y <= -4.4e+29) tmp = -y; elseif (y <= 1.5e+40) tmp = 1.0 - x; else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.4e+29], (-y), If[LessEqual[y, 1.5e+40], N[(1.0 - x), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.4 \cdot 10^{+29}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+40}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < -4.4000000000000003e29Initial program 100.0%
Taylor expanded in y around inf 81.2%
neg-mul-181.2%
Simplified81.2%
if -4.4000000000000003e29 < y < 1.5000000000000001e40Initial program 100.0%
Taylor expanded in y around 0 98.4%
if 1.5000000000000001e40 < y Initial program 100.0%
Taylor expanded in x around 0 76.6%
Final simplification88.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.65e+30) (not (<= y 2.45e+72))) (- y) (- x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.65e+30) || !(y <= 2.45e+72)) {
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 <= (-1.65d+30)) .or. (.not. (y <= 2.45d+72))) then
tmp = -y
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.65e+30) || !(y <= 2.45e+72)) {
tmp = -y;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.65e+30) or not (y <= 2.45e+72): tmp = -y else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.65e+30) || !(y <= 2.45e+72)) tmp = Float64(-y); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.65e+30) || ~((y <= 2.45e+72))) tmp = -y; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.65e+30], N[Not[LessEqual[y, 2.45e+72]], $MachinePrecision]], (-y), (-x)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+30} \lor \neg \left(y \leq 2.45 \cdot 10^{+72}\right):\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if y < -1.65000000000000013e30 or 2.45000000000000003e72 < y Initial program 100.0%
Taylor expanded in y around inf 80.8%
neg-mul-180.8%
Simplified80.8%
if -1.65000000000000013e30 < y < 2.45000000000000003e72Initial program 100.0%
Taylor expanded in x around inf 55.3%
neg-mul-155.3%
Simplified55.3%
Final simplification67.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 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 37.8%
neg-mul-137.8%
Simplified37.8%
Final simplification37.8%
herbie shell --seed 2023310
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))