
(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%
(FPCore (x y) :precision binary64 (if (<= x -0.00033) (- x) (if (<= x -3.2e-258) 1.0 (- y))))
double code(double x, double y) {
double tmp;
if (x <= -0.00033) {
tmp = -x;
} else if (x <= -3.2e-258) {
tmp = 1.0;
} 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 (x <= (-0.00033d0)) then
tmp = -x
else if (x <= (-3.2d-258)) then
tmp = 1.0d0
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.00033) {
tmp = -x;
} else if (x <= -3.2e-258) {
tmp = 1.0;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.00033: tmp = -x elif x <= -3.2e-258: tmp = 1.0 else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (x <= -0.00033) tmp = Float64(-x); elseif (x <= -3.2e-258) tmp = 1.0; else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.00033) tmp = -x; elseif (x <= -3.2e-258) tmp = 1.0; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.00033], (-x), If[LessEqual[x, -3.2e-258], 1.0, (-y)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00033:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-258}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if x < -3.3e-4Initial program 100.0%
Taylor expanded in x around inf 75.7%
neg-mul-175.7%
Simplified75.7%
if -3.3e-4 < x < -3.2000000000000002e-258Initial program 100.0%
associate--l-100.0%
flip3--76.6%
metadata-eval76.6%
metadata-eval76.6%
*-un-lft-identity76.6%
fma-define76.6%
Applied egg-rr76.6%
+-commutative76.6%
fma-undefine76.6%
distribute-lft1-in76.6%
+-commutative76.6%
*-commutative76.6%
+-commutative76.6%
associate-+r+76.6%
+-commutative76.6%
associate-+l+76.6%
Simplified76.6%
Taylor expanded in x around 0 72.6%
Taylor expanded in y around 0 51.9%
if -3.2000000000000002e-258 < x Initial program 100.0%
Taylor expanded in y around inf 46.0%
neg-mul-146.0%
Simplified46.0%
(FPCore (x y) :precision binary64 (if (<= y 12500.0) (- 1.0 x) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if (y <= 12500.0) {
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 <= 12500.0d0) 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 <= 12500.0) {
tmp = 1.0 - x;
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 12500.0: tmp = 1.0 - x else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if (y <= 12500.0) 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 <= 12500.0) tmp = 1.0 - x; else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 12500.0], N[(1.0 - x), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 12500:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < 12500Initial program 100.0%
Taylor expanded in y around 0 76.9%
if 12500 < y Initial program 100.0%
Taylor expanded in x around 0 82.8%
(FPCore (x y) :precision binary64 (if (<= y 7.1e+31) (- 1.0 x) (- y)))
double code(double x, double y) {
double tmp;
if (y <= 7.1e+31) {
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 <= 7.1d+31) 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 <= 7.1e+31) {
tmp = 1.0 - x;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.1e+31: tmp = 1.0 - x else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= 7.1e+31) tmp = Float64(1.0 - x); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.1e+31) tmp = 1.0 - x; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.1e+31], N[(1.0 - x), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.1 \cdot 10^{+31}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 7.09999999999999961e31Initial program 100.0%
Taylor expanded in y around 0 76.1%
if 7.09999999999999961e31 < y Initial program 100.0%
Taylor expanded in y around inf 82.2%
neg-mul-182.2%
Simplified82.2%
(FPCore (x y) :precision binary64 (if (<= x -0.00033) (- x) 1.0))
double code(double x, double y) {
double tmp;
if (x <= -0.00033) {
tmp = -x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.00033d0)) then
tmp = -x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.00033) {
tmp = -x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.00033: tmp = -x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.00033) tmp = Float64(-x); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.00033) tmp = -x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.00033], (-x), 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00033:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -3.3e-4Initial program 100.0%
Taylor expanded in x around inf 75.7%
neg-mul-175.7%
Simplified75.7%
if -3.3e-4 < x Initial program 100.0%
associate--l-100.0%
flip3--52.4%
metadata-eval52.4%
metadata-eval52.4%
*-un-lft-identity52.4%
fma-define52.4%
Applied egg-rr52.4%
+-commutative52.4%
fma-undefine52.4%
distribute-lft1-in52.4%
+-commutative52.4%
*-commutative52.4%
+-commutative52.4%
associate-+r+52.4%
+-commutative52.4%
associate-+l+52.4%
Simplified52.4%
Taylor expanded in x around 0 46.6%
Taylor expanded in y around 0 32.0%
(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%
associate--l-100.0%
flip3--44.4%
metadata-eval44.4%
metadata-eval44.4%
*-un-lft-identity44.4%
fma-define44.4%
Applied egg-rr44.4%
+-commutative44.4%
fma-undefine44.4%
distribute-lft1-in44.4%
+-commutative44.4%
*-commutative44.4%
+-commutative44.4%
associate-+r+44.4%
+-commutative44.4%
associate-+l+44.4%
Simplified44.4%
Taylor expanded in x around 0 35.5%
Taylor expanded in y around 0 24.4%
herbie shell --seed 2024101
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))