
(FPCore (x y) :precision binary64 (* (* x 27.0) y))
double code(double x, double y) {
return (x * 27.0) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 27.0d0) * y
end function
public static double code(double x, double y) {
return (x * 27.0) * y;
}
def code(x, y): return (x * 27.0) * y
function code(x, y) return Float64(Float64(x * 27.0) * y) end
function tmp = code(x, y) tmp = (x * 27.0) * y; end
code[x_, y_] := N[(N[(x * 27.0), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 27\right) \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* x 27.0) y))
double code(double x, double y) {
return (x * 27.0) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 27.0d0) * y
end function
public static double code(double x, double y) {
return (x * 27.0) * y;
}
def code(x, y): return (x * 27.0) * y
function code(x, y) return Float64(Float64(x * 27.0) * y) end
function tmp = code(x, y) tmp = (x * 27.0) * y; end
code[x_, y_] := N[(N[(x * 27.0), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 27\right) \cdot y
\end{array}
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m and y should be sorted in increasing order before calling this function. (FPCore (x_s x_m y) :precision binary64 (* x_s (* (* x_m 27.0) y)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y);
double code(double x_s, double x_m, double y) {
return x_s * ((x_m * 27.0) * y);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m and y should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = x_s * ((x_m * 27.0d0) * y)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y;
public static double code(double x_s, double x_m, double y) {
return x_s * ((x_m * 27.0) * y);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y] = sort([x_m, y]) def code(x_s, x_m, y): return x_s * ((x_m * 27.0) * y)
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y = sort([x_m, y]) function code(x_s, x_m, y) return Float64(x_s * Float64(Float64(x_m * 27.0) * y)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y = num2cell(sort([x_m, y])){:}
function tmp = code(x_s, x_m, y)
tmp = x_s * ((x_m * 27.0) * y);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m and y should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_] := N[(x$95$s * N[(N[(x$95$m * 27.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y] = \mathsf{sort}([x_m, y])\\
\\
x\_s \cdot \left(\left(x\_m \cdot 27\right) \cdot y\right)
\end{array}
Initial program 99.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m and y should be sorted in increasing order before calling this function. (FPCore (x_s x_m y) :precision binary64 (* x_s (* x_m (* 27.0 y))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y);
double code(double x_s, double x_m, double y) {
return x_s * (x_m * (27.0 * y));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m and y should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = x_s * (x_m * (27.0d0 * y))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y;
public static double code(double x_s, double x_m, double y) {
return x_s * (x_m * (27.0 * y));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y] = sort([x_m, y]) def code(x_s, x_m, y): return x_s * (x_m * (27.0 * y))
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y = sort([x_m, y]) function code(x_s, x_m, y) return Float64(x_s * Float64(x_m * Float64(27.0 * y))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y = num2cell(sort([x_m, y])){:}
function tmp = code(x_s, x_m, y)
tmp = x_s * (x_m * (27.0 * y));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m and y should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_] := N[(x$95$s * N[(x$95$m * N[(27.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y] = \mathsf{sort}([x_m, y])\\
\\
x\_s \cdot \left(x\_m \cdot \left(27 \cdot y\right)\right)
\end{array}
Initial program 99.3%
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6499.7
Applied egg-rr99.7%
Final simplification99.7%
herbie shell --seed 2024212
(FPCore (x y)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, F"
:precision binary64
(* (* x 27.0) y))