
(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 -4.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 <= -4.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 <= (-4.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 <= -4.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 <= -4.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 <= -4.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 <= -4.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, -4.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 -4:\\
\;\;\;\;-y\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < -4Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6444.3
Applied rewrites44.3%
if -4 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 2Initial program 100.0%
Taylor expanded in y around 0
lower--.f6498.5
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites98.3%
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.f6441.8
Applied rewrites41.8%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) 0.9999999933659599) (- 1.0 y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= 0.9999999933659599) {
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.9999999933659599d0) 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.9999999933659599) {
tmp = 1.0 - y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= 0.9999999933659599: 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.9999999933659599) 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.9999999933659599) 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.9999999933659599], 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.9999999933659599:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 0.999999993365959905Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites44.5%
if 0.999999993365959905 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6462.8
Applied rewrites62.8%
(FPCore (x y) :precision binary64 (if (<= (- (- 1.0 x) y) -4.0) (- y) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (((1.0 - x) - y) <= -4.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) <= (-4.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) <= -4.0) {
tmp = -y;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) - y) <= -4.0: tmp = -y else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) - y) <= -4.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) <= -4.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], -4.0], (-y), N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) - y \leq -4:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < -4Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6444.3
Applied rewrites44.3%
if -4 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6462.7
Applied rewrites62.7%
(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--.f6471.2
Applied rewrites71.2%
Taylor expanded in x around 0
Applied rewrites36.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
lower-neg.f6441.8
Applied rewrites41.8%
(FPCore (x y) :precision binary64 (if (<= y 1.0) (- 1.0 x) (- (- x) y)))
double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = 1.0 - x;
} else {
tmp = -x - y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.0d0) then
tmp = 1.0d0 - x
else
tmp = -x - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = 1.0 - x;
} else {
tmp = -x - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.0: tmp = 1.0 - x else: tmp = -x - y return tmp
function code(x, y) tmp = 0.0 if (y <= 1.0) tmp = Float64(1.0 - x); else tmp = Float64(Float64(-x) - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.0) tmp = 1.0 - x; else tmp = -x - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.0], N[(1.0 - x), $MachinePrecision], N[((-x) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) - y\\
\end{array}
\end{array}
if y < 1Initial program 100.0%
Taylor expanded in y around 0
lower--.f6470.4
Applied rewrites70.4%
if 1 < y Initial program 100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
(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--.f6460.0
Applied rewrites60.0%
Taylor expanded in x around 0
Applied rewrites23.9%
herbie shell --seed 2024254
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))