
(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 1 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}
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x and y_m should be sorted in increasing order before calling this function. (FPCore (y_s x y_m) :precision binary64 (* y_s (* y_m (* 27.0 x))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m);
double code(double y_s, double x, double y_m) {
return y_s * (y_m * (27.0 * x));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x and y_m should be sorted in increasing order before calling this function.
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 * (y_m * (27.0d0 * x))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m;
public static double code(double y_s, double x, double y_m) {
return y_s * (y_m * (27.0 * x));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m] = sort([x, y_m]) def code(y_s, x, y_m): return y_s * (y_m * (27.0 * x))
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m = sort([x, y_m]) function code(y_s, x, y_m) return Float64(y_s * Float64(y_m * Float64(27.0 * x))) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m = num2cell(sort([x, y_m])){:}
function tmp = code(y_s, x, y_m)
tmp = y_s * (y_m * (27.0 * 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]
NOTE: x and y_m should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * N[(y$95$m * N[(27.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m] = \mathsf{sort}([x, y_m])\\
\\
y\_s \cdot \left(y\_m \cdot \left(27 \cdot x\right)\right)
\end{array}
Initial program 99.4%
Final simplification99.4%
herbie shell --seed 2024273
(FPCore (x y)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, F"
:precision binary64
(* (* x 27.0) y))