simple fma test

?

Percentage Accurate: 29.5% → 100.0%
Time: 2.9s
Precision: binary64
Cost: 64

?

\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right) \]
\[-1 \]
(FPCore (x y z) :precision binary64 (- (fma x y z) (+ 1.0 (+ (* x y) z))))
(FPCore (x y z) :precision binary64 -1.0)
double code(double x, double y, double z) {
	return fma(x, y, z) - (1.0 + ((x * y) + z));
}
double code(double x, double y, double z) {
	return -1.0;
}
function code(x, y, z)
	return Float64(fma(x, y, z) - Float64(1.0 + Float64(Float64(x * y) + z)))
end
function code(x, y, z)
	return -1.0
end
code[x_, y_, z_] := N[(N[(x * y + z), $MachinePrecision] - N[(1.0 + N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := -1.0
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
-1

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Target

Original29.5%
Target100.0%
Herbie100.0%
\[-1 \]

Derivation?

  1. Initial program 33.1%

    \[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right) \]
  2. Simplified100.0%

    \[\leadsto \color{blue}{-1} \]
    Step-by-step derivation

    [Start]33.1

    \[ \mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right) \]

    fma-def [<=]33.1

    \[ \color{blue}{\left(x \cdot y + z\right)} - \left(1 + \left(x \cdot y + z\right)\right) \]

    +-commutative [=>]33.1

    \[ \left(x \cdot y + z\right) - \color{blue}{\left(\left(x \cdot y + z\right) + 1\right)} \]

    associate--r+ [=>]89.1

    \[ \color{blue}{\left(\left(x \cdot y + z\right) - \left(x \cdot y + z\right)\right) - 1} \]

    +-inverses [=>]100.0

    \[ \color{blue}{0} - 1 \]

    metadata-eval [=>]100.0

    \[ \color{blue}{-1} \]
  3. Final simplification100.0%

    \[\leadsto -1 \]

Reproduce?

herbie shell --seed 2023160 
(FPCore (x y z)
  :name "simple fma test"
  :precision binary64

  :herbie-target
  -1.0

  (- (fma x y z) (+ 1.0 (+ (* x y) z))))