
(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 6 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 (<= y 3600.0) (- 1.0 x) (- y)))
double code(double x, double y) {
double tmp;
if (y <= 3600.0) {
tmp = 1.0 - x;
} else {
tmp = -y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3600.0d0) then
tmp = 1.0d0 - x
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3600.0) {
tmp = 1.0 - x;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3600.0: tmp = 1.0 - x else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= 3600.0) tmp = Float64(1.0 - x); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3600.0) tmp = 1.0 - x; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3600.0], N[(1.0 - x), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3600:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 3600Initial program 100.0%
Taylor expanded in y around 0 79.8%
if 3600 < y Initial program 100.0%
Taylor expanded in y around inf 75.7%
neg-mul-175.7%
Simplified75.7%
Final simplification78.8%
(FPCore (x y) :precision binary64 (if (<= y 2.25e-13) (- 1.0 x) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if (y <= 2.25e-13) {
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 <= 2.25d-13) 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 <= 2.25e-13) {
tmp = 1.0 - x;
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.25e-13: tmp = 1.0 - x else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if (y <= 2.25e-13) 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 <= 2.25e-13) tmp = 1.0 - x; else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.25e-13], N[(1.0 - x), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.25 \cdot 10^{-13}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < 2.25e-13Initial program 100.0%
Taylor expanded in y around 0 79.6%
if 2.25e-13 < y Initial program 100.0%
Taylor expanded in x around 0 76.6%
Final simplification78.9%
(FPCore (x y) :precision binary64 (if (<= y 3600.0) (- x) (- y)))
double code(double x, double y) {
double tmp;
if (y <= 3600.0) {
tmp = -x;
} else {
tmp = -y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3600.0d0) then
tmp = -x
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3600.0) {
tmp = -x;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3600.0: tmp = -x else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= 3600.0) tmp = Float64(-x); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3600.0) tmp = -x; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3600.0], (-x), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3600:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 3600Initial program 100.0%
Taylor expanded in x around inf 49.1%
neg-mul-149.1%
Simplified49.1%
if 3600 < y Initial program 100.0%
Taylor expanded in y around inf 75.7%
neg-mul-175.7%
Simplified75.7%
Final simplification55.6%
(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 42.4%
neg-mul-142.4%
Simplified42.4%
Final simplification42.4%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 100.0%
associate--l-100.0%
flip--59.3%
metadata-eval59.3%
Applied egg-rr59.3%
sub-neg59.3%
+-commutative59.3%
distribute-rgt-neg-in59.3%
fma-def59.3%
+-commutative59.3%
distribute-neg-in59.3%
+-commutative59.3%
sub-neg59.3%
+-commutative59.3%
Simplified59.3%
fma-udef59.3%
+-commutative59.3%
add-sqr-sqrt29.6%
sqrt-unprod50.7%
sqr-neg50.7%
sqrt-unprod21.2%
add-sqr-sqrt43.9%
difference-of-squares43.6%
Applied egg-rr43.6%
+-commutative43.6%
difference-of-squares43.9%
fma-def43.9%
+-commutative43.9%
Simplified43.9%
Taylor expanded in y around inf 2.1%
Final simplification2.1%
herbie shell --seed 2023213
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))