Average Error: 0.1 → 0.1
Time: 3.1s
Precision: binary64
\[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
\[\mathsf{fma}\left(x, 0.5, y \cdot \left(0.5 \cdot \sqrt{z}\right)\right) \]
(FPCore (x y z) :precision binary64 (* (/ 1.0 2.0) (+ x (* y (sqrt z)))))
(FPCore (x y z) :precision binary64 (fma x 0.5 (* y (* 0.5 (sqrt z)))))
double code(double x, double y, double z) {
	return (1.0 / 2.0) * (x + (y * sqrt(z)));
}
double code(double x, double y, double z) {
	return fma(x, 0.5, (y * (0.5 * sqrt(z))));
}
function code(x, y, z)
	return Float64(Float64(1.0 / 2.0) * Float64(x + Float64(y * sqrt(z))))
end
function code(x, y, z)
	return fma(x, 0.5, Float64(y * Float64(0.5 * sqrt(z))))
end
code[x_, y_, z_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(x + N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * 0.5 + N[(y * N[(0.5 * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right)
\mathsf{fma}\left(x, 0.5, y \cdot \left(0.5 \cdot \sqrt{z}\right)\right)

Error

Derivation

  1. Initial program 0.1

    \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  2. Applied egg-rr0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 0.5, y \cdot \left(\sqrt{z} \cdot 0.5\right)\right)} \]
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \left(0.5 \cdot \sqrt{z}\right)\right) \]

Reproduce

herbie shell --seed 2022210 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, B"
  :precision binary64
  (* (/ 1.0 2.0) (+ x (* y (sqrt z)))))