?

Average Accuracy: 99.9% → 100.0%
Time: 6.3s
Precision: binary64
Cost: 6976

?

\[\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t \]
\[\mathsf{fma}\left(z, -0.5 \cdot y, 0.125 \cdot x\right) + t \]
(FPCore (x y z t)
 :precision binary64
 (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
(FPCore (x y z t) :precision binary64 (+ (fma z (* -0.5 y) (* 0.125 x)) t))
double code(double x, double y, double z, double t) {
	return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
double code(double x, double y, double z, double t) {
	return fma(z, (-0.5 * y), (0.125 * x)) + t;
}
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t)
end
function code(x, y, z, t)
	return Float64(fma(z, Float64(-0.5 * y), Float64(0.125 * x)) + t)
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(z * N[(-0.5 * y), $MachinePrecision] + N[(0.125 * x), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\mathsf{fma}\left(z, -0.5 \cdot y, 0.125 \cdot x\right) + t

Error?

Target

Original99.9%
Target100.0%
Herbie100.0%
\[\left(\frac{x}{8} + t\right) - \frac{z}{2} \cdot y \]

Derivation?

  1. Initial program 99.9%

    \[\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t \]
  2. Simplified100.0%

    \[\leadsto \color{blue}{\left(0.125 \cdot x - \frac{y}{2} \cdot z\right) + t} \]
    Proof

    [Start]99.9

    \[ \left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t \]

    associate-+l- [=>]99.9

    \[ \color{blue}{\frac{1}{8} \cdot x - \left(\frac{y \cdot z}{2} - t\right)} \]

    sub-neg [=>]99.9

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

    neg-mul-1 [=>]99.9

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

    *-commutative [=>]99.9

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

    cancel-sign-sub [<=]99.9

    \[ \color{blue}{\frac{1}{8} \cdot x - \left(-\left(\frac{y \cdot z}{2} - t\right)\right) \cdot -1} \]

    *-commutative [=>]99.9

    \[ \frac{1}{8} \cdot x - \color{blue}{-1 \cdot \left(-\left(\frac{y \cdot z}{2} - t\right)\right)} \]

    cancel-sign-sub-inv [=>]99.9

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

    metadata-eval [=>]99.9

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

    neg-sub0 [=>]99.9

    \[ \frac{1}{8} \cdot x + 1 \cdot \color{blue}{\left(0 - \left(\frac{y \cdot z}{2} - t\right)\right)} \]

    associate-+l- [<=]99.9

    \[ \frac{1}{8} \cdot x + 1 \cdot \color{blue}{\left(\left(0 - \frac{y \cdot z}{2}\right) + t\right)} \]

    neg-sub0 [<=]99.9

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

    distribute-lft-in [=>]99.9

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

    *-lft-identity [=>]99.9

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

    associate-+r+ [=>]99.9

    \[ \color{blue}{\left(\frac{1}{8} \cdot x + 1 \cdot \left(-\frac{y \cdot z}{2}\right)\right) + t} \]
  3. Taylor expanded in x around 0 99.9%

    \[\leadsto \color{blue}{\left(-0.5 \cdot \left(y \cdot z\right) + 0.125 \cdot x\right)} + t \]
  4. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, -0.5 \cdot y, 0.125 \cdot x\right)} + t \]
    Proof

    [Start]99.9

    \[ \left(-0.5 \cdot \left(y \cdot z\right) + 0.125 \cdot x\right) + t \]

    *-commutative [=>]99.9

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

    *-commutative [=>]99.9

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

    associate-*r* [<=]100.0

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

    fma-def [=>]100.0

    \[ \color{blue}{\mathsf{fma}\left(z, y \cdot -0.5, 0.125 \cdot x\right)} + t \]

    *-commutative [=>]100.0

    \[ \mathsf{fma}\left(z, \color{blue}{-0.5 \cdot y}, 0.125 \cdot x\right) + t \]
  5. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(z, -0.5 \cdot y, 0.125 \cdot x\right) + t \]

Alternatives

Alternative 1
Accuracy54.8%
Cost1244
\[\begin{array}{l} t_1 := z \cdot \left(-0.5 \cdot y\right)\\ \mathbf{if}\;t \leq -2.5 \cdot 10^{+18}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq -1.96 \cdot 10^{-162}:\\ \;\;\;\;0.125 \cdot x\\ \mathbf{elif}\;t \leq -1.16 \cdot 10^{-229}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-252}:\\ \;\;\;\;0.125 \cdot x\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{-171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{-96}:\\ \;\;\;\;0.125 \cdot x\\ \mathbf{elif}\;t \leq 12500000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 2
Accuracy85.9%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \cdot y \leq -1 \cdot 10^{+22} \lor \neg \left(z \cdot y \leq 400\right):\\ \;\;\;\;t - \left(z \cdot y\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.125 \cdot x + t\\ \end{array} \]
Alternative 3
Accuracy65.4%
Cost717
\[\begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{-96} \lor \neg \left(z \leq 1.7 \cdot 10^{+218}\right) \land z \leq 1.25 \cdot 10^{+252}:\\ \;\;\;\;z \cdot \left(-0.5 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;0.125 \cdot x + t\\ \end{array} \]
Alternative 4
Accuracy100.0%
Cost704
\[t + \left(0.125 \cdot x - z \cdot \frac{y}{2}\right) \]
Alternative 5
Accuracy56.8%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -5.8 \cdot 10^{+18}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 39000000000000:\\ \;\;\;\;0.125 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 6
Accuracy37.0%
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023129 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (- (+ (/ x 8.0) t) (* (/ z 2.0) y))

  (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))