(FPCore (x y z) :precision binary64 (* x (* y z)))
double code(double x, double y, double z) { return x * (y * z); }
real(8) function code(x, y, z) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z code = x * (y * z) end function
public static double code(double x, double y, double z) { return x * (y * z); }
def code(x, y, z): return x * (y * z)
function code(x, y, z) return Float64(x * Float64(y * z)) end
function tmp = code(x, y, z) tmp = x * (y * z); end
code[x_, y_, z_] := N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ x \cdot \left(y \cdot z\right) \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x y z) :precision binary64 (* x (* y z)))
double code(double x, double y, double z) { return x * (y * z); }
real(8) function code(x, y, z) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z code = x * (y * z) end function
public static double code(double x, double y, double z) { return x * (y * z); }
def code(x, y, z): return x * (y * z)
function code(x, y, z) return Float64(x * Float64(y * z)) end
function tmp = code(x, y, z) tmp = x * (y * z); end
code[x_, y_, z_] := N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ x \cdot \left(y \cdot z\right) \end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* y (* x z)))
assert(x < y && y < z); double code(double x, double y, double z) { return y * (x * z); }
NOTE: x, y, and z should be sorted in increasing order before calling this function. real(8) function code(x, y, z) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z code = y * (x * z) end function
assert x < y && y < z; public static double code(double x, double y, double z) { return y * (x * z); }
[x, y, z] = sort([x, y, z]) def code(x, y, z): return y * (x * z)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(y * Float64(x * z)) end
x, y, z = num2cell(sort([x, y, z])){:} function tmp = code(x, y, z) tmp = y * (x * z); end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ y \cdot \left(x \cdot z\right) \end{array}
Initial program 99.6%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*r*
N/A
*-commutative
N/A
associate-*r*
N/A
lower-*.f64
N/A
lower-*.f64
99.6
Applied rewrites99.6%
Final simplification99.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (* y z) x))
assert(x < y && y < z); double code(double x, double y, double z) { return (y * z) * x; }
NOTE: x, y, and z should be sorted in increasing order before calling this function. real(8) function code(x, y, z) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z code = (y * z) * x end function
assert x < y && y < z; public static double code(double x, double y, double z) { return (y * z) * x; }
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (y * z) * x
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(y * z) * x) end
x, y, z = num2cell(sort([x, y, z])){:} function tmp = code(x, y, z) tmp = (y * z) * x; end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \left(y \cdot z\right) \cdot x \end{array}
Initial program 99.6%
Final simplification99.6%
herbie shell --seed 1
(FPCore (x y z)
:name "x y z"
:precision binary64
:pre (and (and (and (<= 0.1 x) (<= x 15.0)) (and (<= 0.022 y) (<= y 0.034))) (and (<= 1.0 z) (<= z 2.0)))
(* x (* y z)))