
(FPCore (x y) :precision binary64 (/ (* x 100.0) (+ x y)))
double code(double x, double y) {
return (x * 100.0) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 100.0d0) / (x + y)
end function
public static double code(double x, double y) {
return (x * 100.0) / (x + y);
}
def code(x, y): return (x * 100.0) / (x + y)
function code(x, y) return Float64(Float64(x * 100.0) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x * 100.0) / (x + y); end
code[x_, y_] := N[(N[(x * 100.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 100}{x + y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x 100.0) (+ x y)))
double code(double x, double y) {
return (x * 100.0) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 100.0d0) / (x + y)
end function
public static double code(double x, double y) {
return (x * 100.0) / (x + y);
}
def code(x, y): return (x * 100.0) / (x + y)
function code(x, y) return Float64(Float64(x * 100.0) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x * 100.0) / (x + y); end
code[x_, y_] := N[(N[(x * 100.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 100}{x + y}
\end{array}
(FPCore (x y) :precision binary64 (/ (* x 100.0) (+ x y)))
double code(double x, double y) {
return (x * 100.0) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 100.0d0) / (x + y)
end function
public static double code(double x, double y) {
return (x * 100.0) / (x + y);
}
def code(x, y): return (x * 100.0) / (x + y)
function code(x, y) return Float64(Float64(x * 100.0) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x * 100.0) / (x + y); end
code[x_, y_] := N[(N[(x * 100.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 100}{x + y}
\end{array}
Initial program 98.9%
(FPCore (x y) :precision binary64 (* x 100.0))
double code(double x, double y) {
return x * 100.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * 100.0d0
end function
public static double code(double x, double y) {
return x * 100.0;
}
def code(x, y): return x * 100.0
function code(x, y) return Float64(x * 100.0) end
function tmp = code(x, y) tmp = x * 100.0; end
code[x_, y_] := N[(x * 100.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 100
\end{array}
Initial program 98.9%
Taylor expanded in x around 0
Applied rewrites4.2%
(FPCore (x y) :precision binary64 (+ x y))
double code(double x, double y) {
return x + y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + y
end function
public static double code(double x, double y) {
return x + y;
}
def code(x, y): return x + y
function code(x, y) return Float64(x + y) end
function tmp = code(x, y) tmp = x + y; end
code[x_, y_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 98.9%
Taylor expanded in x around 0
Applied rewrites3.1%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ 100.0 (+ x y))))
double code(double x, double y) {
return (x / 1.0) * (100.0 / (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / 1.0d0) * (100.0d0 / (x + y))
end function
public static double code(double x, double y) {
return (x / 1.0) * (100.0 / (x + y));
}
def code(x, y): return (x / 1.0) * (100.0 / (x + y))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(100.0 / Float64(x + y))) end
function tmp = code(x, y) tmp = (x / 1.0) * (100.0 / (x + y)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(100.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{100}{x + y}
\end{array}
herbie shell --seed 2024321
(FPCore (x y)
:name "Development.Shake.Progress:message from shake-0.15.5"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (* (/ x 1) (/ 100 (+ x y))))
(/ (* x 100.0) (+ x y)))