
(FPCore (x y) :precision binary64 (- (+ x y) x))
double code(double x, double y) {
return (x + y) - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) - x
end function
public static double code(double x, double y) {
return (x + y) - x;
}
def code(x, y): return (x + y) - x
function code(x, y) return Float64(Float64(x + y) - x) end
function tmp = code(x, y) tmp = (x + y) - x; end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (+ x y) x))
double code(double x, double y) {
return (x + y) - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) - x
end function
public static double code(double x, double y) {
return (x + y) - x;
}
def code(x, y): return (x + y) - x
function code(x, y) return Float64(Float64(x + y) - x) end
function tmp = code(x, y) tmp = (x + y) - x; end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - x
\end{array}
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m) :precision binary64 (* y_s (- (+ x y_m) x)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
return y_s * ((x + y_m) - x);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = y_s * ((x + y_m) - x)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m) {
return y_s * ((x + y_m) - x);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m): return y_s * ((x + y_m) - x)
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) return Float64(y_s * Float64(Float64(x + y_m) - x)) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m) tmp = y_s * ((x + y_m) - x); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * N[(N[(x + y$95$m), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(\left(x + y\_m\right) - x\right)
\end{array}
Initial program 58.7%
(FPCore (x y) :precision binary64 (- y 0.0))
double code(double x, double y) {
return y - 0.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y - 0.0d0
end function
public static double code(double x, double y) {
return y - 0.0;
}
def code(x, y): return y - 0.0
function code(x, y) return Float64(y - 0.0) end
function tmp = code(x, y) tmp = y - 0.0; end
code[x_, y_] := N[(y - 0.0), $MachinePrecision]
\begin{array}{l}
\\
y - 0
\end{array}
herbie shell --seed 2024154 -o setup:simplify
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Pie:renderPie from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (- y 0))
(- (+ x y) x))