
(FPCore (x) :precision binary64 (* (* x 0.5) x))
double code(double x) {
return (x * 0.5) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 0.5d0) * x
end function
public static double code(double x) {
return (x * 0.5) * x;
}
def code(x): return (x * 0.5) * x
function code(x) return Float64(Float64(x * 0.5) * x) end
function tmp = code(x) tmp = (x * 0.5) * x; end
code[x_] := N[(N[(x * 0.5), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5\right) \cdot x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (* x 0.5) x))
double code(double x) {
return (x * 0.5) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 0.5d0) * x
end function
public static double code(double x) {
return (x * 0.5) * x;
}
def code(x): return (x * 0.5) * x
function code(x) return Float64(Float64(x * 0.5) * x) end
function tmp = code(x) tmp = (x * 0.5) * x; end
code[x_] := N[(N[(x * 0.5), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5\right) \cdot x
\end{array}
(FPCore (x) :precision binary64 (* (* 0.5 x) x))
double code(double x) {
return (0.5 * x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 * x) * x
end function
public static double code(double x) {
return (0.5 * x) * x;
}
def code(x): return (0.5 * x) * x
function code(x) return Float64(Float64(0.5 * x) * x) end
function tmp = code(x) tmp = (0.5 * x) * x; end
code[x_] := N[(N[(0.5 * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot x\right) \cdot x
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 0.5)
double code(double x) {
return 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0
end function
public static double code(double x) {
return 0.5;
}
def code(x): return 0.5
function code(x) return 0.5 end
function tmp = code(x) tmp = 0.5; end
code[x_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
Applied rewrites4.3%
herbie shell --seed 2024332
(FPCore (x)
:name "System.Random.MWC.Distributions:blocks from mwc-random-0.13.3.2"
:precision binary64
(* (* x 0.5) x))