
(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%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) 0.9999999999999996) (- 1.0 y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= 0.9999999999999996) {
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) - y) <= 0.9999999999999996d0) 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) - y) <= 0.9999999999999996) {
tmp = 1.0 - y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= 0.9999999999999996: tmp = 1.0 - y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) - y) <= 0.9999999999999996) 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) - y) <= 0.9999999999999996) tmp = 1.0 - y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision], 0.9999999999999996], N[(1.0 - y), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) - y \leq 0.9999999999999996:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 0.99999999999999956Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f6453.1
Simplified53.1%
if 0.99999999999999956 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6471.3
Simplified71.3%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) 2.0) 1.0 (- 0.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= 2.0) {
tmp = 1.0;
} else {
tmp = 0.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) - y) <= 2.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= 2.0) {
tmp = 1.0;
} else {
tmp = 0.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= 2.0: tmp = 1.0 else: tmp = 0.0 - x return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) - y) <= 2.0) tmp = 1.0; else tmp = Float64(0.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((1.0 - x) - y) <= 2.0) tmp = 1.0; else tmp = 0.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision], 2.0], 1.0, N[(0.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) - y \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 2Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6470.7
Simplified70.7%
Taylor expanded in x around 0
Simplified41.4%
if 2 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6449.9
Simplified49.9%
sub0-negN/A
neg-lowering-neg.f6449.9
Applied egg-rr49.9%
Final simplification44.5%
(FPCore (x y) :precision binary64 (- 1.0 x))
double code(double x, double y) {
return 1.0 - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - x
end function
public static double code(double x, double y) {
return 1.0 - x;
}
def code(x, y): return 1.0 - x
function code(x, y) return Float64(1.0 - x) end
function tmp = code(x, y) tmp = 1.0 - x; end
code[x_, y_] := N[(1.0 - x), $MachinePrecision]
\begin{array}{l}
\\
1 - x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6463.7
Simplified63.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%
Taylor expanded in y around 0
--lowering--.f6463.7
Simplified63.7%
Taylor expanded in x around 0
Simplified28.1%
herbie shell --seed 2024198
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))