
(FPCore (x y) :precision binary64 (- x (* (/ 3.0 8.0) y)))
double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x - ((3.0d0 / 8.0d0) * y)
end function
public static double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
def code(x, y): return x - ((3.0 / 8.0) * y)
function code(x, y) return Float64(x - Float64(Float64(3.0 / 8.0) * y)) end
function tmp = code(x, y) tmp = x - ((3.0 / 8.0) * y); end
code[x_, y_] := N[(x - N[(N[(3.0 / 8.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{3}{8} \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- x (* (/ 3.0 8.0) y)))
double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x - ((3.0d0 / 8.0d0) * y)
end function
public static double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
def code(x, y): return x - ((3.0 / 8.0) * y)
function code(x, y) return Float64(x - Float64(Float64(3.0 / 8.0) * y)) end
function tmp = code(x, y) tmp = x - ((3.0 / 8.0) * y); end
code[x_, y_] := N[(x - N[(N[(3.0 / 8.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{3}{8} \cdot y
\end{array}
(FPCore (x y) :precision binary64 (fma y -0.375 x))
double code(double x, double y) {
return fma(y, -0.375, x);
}
function code(x, y) return fma(y, -0.375, x) end
code[x_, y_] := N[(y * -0.375 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, -0.375, x\right)
\end{array}
Initial program 99.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval100.0
Applied rewrites100.0%
(FPCore (x y) :precision binary64 (* -0.375 y))
double code(double x, double y) {
return -0.375 * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (-0.375d0) * y
end function
public static double code(double x, double y) {
return -0.375 * y;
}
def code(x, y): return -0.375 * y
function code(x, y) return Float64(-0.375 * y) end
function tmp = code(x, y) tmp = -0.375 * y; end
code[x_, y_] := N[(-0.375 * y), $MachinePrecision]
\begin{array}{l}
\\
-0.375 \cdot y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6452.8
Applied rewrites52.8%
Final simplification52.8%
herbie shell --seed 2024273
(FPCore (x y)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, A"
:precision binary64
(- x (* (/ 3.0 8.0) y)))