
(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 7 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 (let* ((t_0 (- (- 1.0 x) y))) (if (<= t_0 -2000.0) (- y) (if (<= t_0 2.0) 1.0 (- x)))))
double code(double x, double y) {
double t_0 = (1.0 - x) - y;
double tmp;
if (t_0 <= -2000.0) {
tmp = -y;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = -x;
}
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 = (1.0d0 - x) - y
if (t_0 <= (-2000.0d0)) then
tmp = -y
else if (t_0 <= 2.0d0) then
tmp = 1.0d0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (1.0 - x) - y;
double tmp;
if (t_0 <= -2000.0) {
tmp = -y;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): t_0 = (1.0 - x) - y tmp = 0 if t_0 <= -2000.0: tmp = -y elif t_0 <= 2.0: tmp = 1.0 else: tmp = -x return tmp
function code(x, y) t_0 = Float64(Float64(1.0 - x) - y) tmp = 0.0 if (t_0 <= -2000.0) tmp = Float64(-y); elseif (t_0 <= 2.0) tmp = 1.0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 - x) - y; tmp = 0.0; if (t_0 <= -2000.0) tmp = -y; elseif (t_0 <= 2.0) tmp = 1.0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$0, -2000.0], (-y), If[LessEqual[t$95$0, 2.0], 1.0, (-x)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - x\right) - y\\
\mathbf{if}\;t\_0 \leq -2000:\\
\;\;\;\;-y\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < -2e3Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6452.1
Applied rewrites52.1%
if -2e3 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 2Initial program 100.0%
Taylor expanded in y around 0
lower--.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites97.2%
if 2 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6445.6
Applied rewrites45.6%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) -2000.0) (- (- x) y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= -2000.0) {
tmp = -x - 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) <= (-2000.0d0)) then
tmp = -x - 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) <= -2000.0) {
tmp = -x - y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= -2000.0: tmp = -x - y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) - y) <= -2000.0) tmp = Float64(Float64(-x) - 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) <= -2000.0) tmp = -x - y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision], -2000.0], N[((-x) - y), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) - y \leq -2000:\\
\;\;\;\;\left(-x\right) - y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < -2e3Initial program 100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6498.9
Applied rewrites98.9%
if -2e3 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6474.3
Applied rewrites74.3%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) 0.9999999999999999) (- 1.0 y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= 0.9999999999999999) {
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.9999999999999999d0) 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.9999999999999999) {
tmp = 1.0 - y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= 0.9999999999999999: 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.9999999999999999) 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.9999999999999999) 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.9999999999999999], 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.9999999999999999:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 0.999999999999999889Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites53.3%
if 0.999999999999999889 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6473.9
Applied rewrites73.9%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) -2000.0) (- y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= -2000.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 (((1.0d0 - x) - y) <= (-2000.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 (((1.0 - x) - y) <= -2000.0) {
tmp = -y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= -2000.0: tmp = -y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) - y) <= -2000.0) tmp = Float64(-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) <= -2000.0) tmp = -y; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision], -2000.0], (-y), N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) - y \leq -2000:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < -2e3Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6452.1
Applied rewrites52.1%
if -2e3 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6474.3
Applied rewrites74.3%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) 2.0) 1.0 (- x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= 2.0) {
tmp = 1.0;
} 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 (((1.0d0 - x) - y) <= 2.0d0) then
tmp = 1.0d0
else
tmp = -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 = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= 2.0: tmp = 1.0 else: tmp = -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(-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 = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision], 2.0], 1.0, (-x)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) - y \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 2Initial program 100.0%
Taylor expanded in y around 0
lower--.f6473.0
Applied rewrites73.0%
Taylor expanded in x around 0
Applied rewrites49.6%
if 2 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6445.6
Applied rewrites45.6%
(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
lower--.f6464.8
Applied rewrites64.8%
Taylor expanded in x around 0
Applied rewrites35.6%
herbie shell --seed 2024240
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))