Average Error: 0.5 → 0.3
Time: 17.5s
Precision: binary64
\[x1 + \left(\left(\left(\left(\left(\left(\left(2 \cdot x1\right) \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) \cdot \left(\frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1} - 3\right) + \left(x1 \cdot x1\right) \cdot \left(4 \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1} - 6\right)\right) \cdot \left(x1 \cdot x1 + 1\right) + \left(\left(3 \cdot x1\right) \cdot x1\right) \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) + \left(x1 \cdot x1\right) \cdot x1\right) + x1\right) + 3 \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 - 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)\\ \mathsf{fma}\left(x1, x1 \cdot \frac{3 \cdot t_0}{\mathsf{fma}\left(x1, x1, 1\right)}, \mathsf{fma}\left(x1, x1, 1\right) \cdot \left(x1 + \left(\frac{t_0 \cdot \mathsf{fma}\left(x1, \mathsf{fma}\left(2, \frac{t_0}{\mathsf{fma}\left(x1, x1, 1\right)}, -6\right), \left(x1 \cdot x1\right) \cdot 4\right)}{\mathsf{fma}\left(x1, x1, 1\right)} + x1 \cdot \left(x1 \cdot -6\right)\right)\right)\right) + \mathsf{fma}\left(3, \frac{x1 \cdot \left(x1 \cdot 3\right) - \mathsf{fma}\left(2, x2, x1\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, x1\right) \end{array} \]
(FPCore (x1 x2)
 :precision binary64
 (+
  x1
  (+
   (+
    (+
     (+
      (*
       (+
        (*
         (*
          (* 2.0 x1)
          (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)))
         (- (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)) 3.0))
        (*
         (* x1 x1)
         (-
          (* 4.0 (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)))
          6.0)))
       (+ (* x1 x1) 1.0))
      (*
       (* (* 3.0 x1) x1)
       (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))))
     (* (* x1 x1) x1))
    x1)
   (* 3.0 (/ (- (- (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))))))
(FPCore (x1 x2)
 :precision binary64
 (let* ((t_0 (fma 2.0 x2 (fma x1 (* x1 3.0) (- x1)))))
   (+
    (fma
     x1
     (* x1 (/ (* 3.0 t_0) (fma x1 x1 1.0)))
     (*
      (fma x1 x1 1.0)
      (+
       x1
       (+
        (/
         (*
          t_0
          (fma x1 (fma 2.0 (/ t_0 (fma x1 x1 1.0)) -6.0) (* (* x1 x1) 4.0)))
         (fma x1 x1 1.0))
        (* x1 (* x1 -6.0))))))
    (fma 3.0 (/ (- (* x1 (* x1 3.0)) (fma 2.0 x2 x1)) (fma x1 x1 1.0)) x1))))
double code(double x1, double x2) {
	return x1 + (((((((((2.0 * x1) * (((((3.0 * x1) * x1) + (2.0 * x2)) - x1) / ((x1 * x1) + 1.0))) * ((((((3.0 * x1) * x1) + (2.0 * x2)) - x1) / ((x1 * x1) + 1.0)) - 3.0)) + ((x1 * x1) * ((4.0 * (((((3.0 * x1) * x1) + (2.0 * x2)) - x1) / ((x1 * x1) + 1.0))) - 6.0))) * ((x1 * x1) + 1.0)) + (((3.0 * x1) * x1) * (((((3.0 * x1) * x1) + (2.0 * x2)) - x1) / ((x1 * x1) + 1.0)))) + ((x1 * x1) * x1)) + x1) + (3.0 * (((((3.0 * x1) * x1) - (2.0 * x2)) - x1) / ((x1 * x1) + 1.0))));
}
double code(double x1, double x2) {
	double t_0 = fma(2.0, x2, fma(x1, (x1 * 3.0), -x1));
	return fma(x1, (x1 * ((3.0 * t_0) / fma(x1, x1, 1.0))), (fma(x1, x1, 1.0) * (x1 + (((t_0 * fma(x1, fma(2.0, (t_0 / fma(x1, x1, 1.0)), -6.0), ((x1 * x1) * 4.0))) / fma(x1, x1, 1.0)) + (x1 * (x1 * -6.0)))))) + fma(3.0, (((x1 * (x1 * 3.0)) - fma(2.0, x2, x1)) / fma(x1, x1, 1.0)), x1);
}
function code(x1, x2)
	return Float64(x1 + Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(2.0 * x1) * Float64(Float64(Float64(Float64(Float64(3.0 * x1) * x1) + Float64(2.0 * x2)) - x1) / Float64(Float64(x1 * x1) + 1.0))) * Float64(Float64(Float64(Float64(Float64(Float64(3.0 * x1) * x1) + Float64(2.0 * x2)) - x1) / Float64(Float64(x1 * x1) + 1.0)) - 3.0)) + Float64(Float64(x1 * x1) * Float64(Float64(4.0 * Float64(Float64(Float64(Float64(Float64(3.0 * x1) * x1) + Float64(2.0 * x2)) - x1) / Float64(Float64(x1 * x1) + 1.0))) - 6.0))) * Float64(Float64(x1 * x1) + 1.0)) + Float64(Float64(Float64(3.0 * x1) * x1) * Float64(Float64(Float64(Float64(Float64(3.0 * x1) * x1) + Float64(2.0 * x2)) - x1) / Float64(Float64(x1 * x1) + 1.0)))) + Float64(Float64(x1 * x1) * x1)) + x1) + Float64(3.0 * Float64(Float64(Float64(Float64(Float64(3.0 * x1) * x1) - Float64(2.0 * x2)) - x1) / Float64(Float64(x1 * x1) + 1.0)))))
end
function code(x1, x2)
	t_0 = fma(2.0, x2, fma(x1, Float64(x1 * 3.0), Float64(-x1)))
	return Float64(fma(x1, Float64(x1 * Float64(Float64(3.0 * t_0) / fma(x1, x1, 1.0))), Float64(fma(x1, x1, 1.0) * Float64(x1 + Float64(Float64(Float64(t_0 * fma(x1, fma(2.0, Float64(t_0 / fma(x1, x1, 1.0)), -6.0), Float64(Float64(x1 * x1) * 4.0))) / fma(x1, x1, 1.0)) + Float64(x1 * Float64(x1 * -6.0)))))) + fma(3.0, Float64(Float64(Float64(x1 * Float64(x1 * 3.0)) - fma(2.0, x2, x1)) / fma(x1, x1, 1.0)), x1))
end
code[x1_, x2_] := N[(x1 + N[(N[(N[(N[(N[(N[(N[(N[(N[(2.0 * x1), $MachinePrecision] * N[(N[(N[(N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision] + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision] + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * N[(N[(4.0 * N[(N[(N[(N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision] + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision] * N[(N[(N[(N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision] + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * x1), $MachinePrecision]), $MachinePrecision] + x1), $MachinePrecision] + N[(3.0 * N[(N[(N[(N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision] - N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x1_, x2_] := Block[{t$95$0 = N[(2.0 * x2 + N[(x1 * N[(x1 * 3.0), $MachinePrecision] + (-x1)), $MachinePrecision]), $MachinePrecision]}, N[(N[(x1 * N[(x1 * N[(N[(3.0 * t$95$0), $MachinePrecision] / N[(x1 * x1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1 + 1.0), $MachinePrecision] * N[(x1 + N[(N[(N[(t$95$0 * N[(x1 * N[(2.0 * N[(t$95$0 / N[(x1 * x1 + 1.0), $MachinePrecision]), $MachinePrecision] + -6.0), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x1 * x1 + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x1 * N[(x1 * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(3.0 * N[(N[(N[(x1 * N[(x1 * 3.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 * x2 + x1), $MachinePrecision]), $MachinePrecision] / N[(x1 * x1 + 1.0), $MachinePrecision]), $MachinePrecision] + x1), $MachinePrecision]), $MachinePrecision]]
x1 + \left(\left(\left(\left(\left(\left(\left(2 \cdot x1\right) \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) \cdot \left(\frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1} - 3\right) + \left(x1 \cdot x1\right) \cdot \left(4 \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1} - 6\right)\right) \cdot \left(x1 \cdot x1 + 1\right) + \left(\left(3 \cdot x1\right) \cdot x1\right) \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) + \left(x1 \cdot x1\right) \cdot x1\right) + x1\right) + 3 \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 - 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right)
\begin{array}{l}
t_0 := \mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)\\
\mathsf{fma}\left(x1, x1 \cdot \frac{3 \cdot t_0}{\mathsf{fma}\left(x1, x1, 1\right)}, \mathsf{fma}\left(x1, x1, 1\right) \cdot \left(x1 + \left(\frac{t_0 \cdot \mathsf{fma}\left(x1, \mathsf{fma}\left(2, \frac{t_0}{\mathsf{fma}\left(x1, x1, 1\right)}, -6\right), \left(x1 \cdot x1\right) \cdot 4\right)}{\mathsf{fma}\left(x1, x1, 1\right)} + x1 \cdot \left(x1 \cdot -6\right)\right)\right)\right) + \mathsf{fma}\left(3, \frac{x1 \cdot \left(x1 \cdot 3\right) - \mathsf{fma}\left(2, x2, x1\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, x1\right)
\end{array}

Error

Bits error versus x1

Bits error versus x2

Derivation

  1. Initial program 0.5

    \[x1 + \left(\left(\left(\left(\left(\left(\left(2 \cdot x1\right) \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) \cdot \left(\frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1} - 3\right) + \left(x1 \cdot x1\right) \cdot \left(4 \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1} - 6\right)\right) \cdot \left(x1 \cdot x1 + 1\right) + \left(\left(3 \cdot x1\right) \cdot x1\right) \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 + 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) + \left(x1 \cdot x1\right) \cdot x1\right) + x1\right) + 3 \cdot \frac{\left(\left(3 \cdot x1\right) \cdot x1 - 2 \cdot x2\right) - x1}{x1 \cdot x1 + 1}\right) \]
  2. Simplified0.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(x1, x1 \cdot \frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right) \cdot 3}{\mathsf{fma}\left(x1, x1, 1\right)}, \mathsf{fma}\left(x1, x1, 1\right) \cdot \left(\left(\frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)}{\mathsf{fma}\left(x1, x1, 1\right)} \cdot \left(x1 \cdot \left(-6 + 2 \cdot \frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)}{\mathsf{fma}\left(x1, x1, 1\right)}\right) + \left(x1 \cdot x1\right) \cdot 4\right) + x1 \cdot \left(x1 \cdot -6\right)\right) + x1\right)\right) + \mathsf{fma}\left(3, \frac{x1 \cdot \left(x1 \cdot 3\right) - \mathsf{fma}\left(2, x2, x1\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, x1\right)} \]
  3. Applied egg-rr0.3

    \[\leadsto \mathsf{fma}\left(x1, x1 \cdot \frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right) \cdot 3}{\mathsf{fma}\left(x1, x1, 1\right)}, \mathsf{fma}\left(x1, x1, 1\right) \cdot \left(\left(\color{blue}{\frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right) \cdot \mathsf{fma}\left(x1, \mathsf{fma}\left(2, \frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, -6\right), \left(x1 \cdot x1\right) \cdot 4\right)}{\mathsf{fma}\left(x1, x1, 1\right)}} + x1 \cdot \left(x1 \cdot -6\right)\right) + x1\right)\right) + \mathsf{fma}\left(3, \frac{x1 \cdot \left(x1 \cdot 3\right) - \mathsf{fma}\left(2, x2, x1\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, x1\right) \]
  4. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(x1, x1 \cdot \frac{3 \cdot \mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, \mathsf{fma}\left(x1, x1, 1\right) \cdot \left(x1 + \left(\frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right) \cdot \mathsf{fma}\left(x1, \mathsf{fma}\left(2, \frac{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, -6\right), \left(x1 \cdot x1\right) \cdot 4\right)}{\mathsf{fma}\left(x1, x1, 1\right)} + x1 \cdot \left(x1 \cdot -6\right)\right)\right)\right) + \mathsf{fma}\left(3, \frac{x1 \cdot \left(x1 \cdot 3\right) - \mathsf{fma}\left(2, x2, x1\right)}{\mathsf{fma}\left(x1, x1, 1\right)}, x1\right) \]

Reproduce

herbie shell --seed 2022150 
(FPCore (x1 x2)
  :name "Rosa's FloatVsDoubleBenchmark"
  :precision binary64
  (+ x1 (+ (+ (+ (+ (* (+ (* (* (* 2.0 x1) (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))) (- (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)) 3.0)) (* (* x1 x1) (- (* 4.0 (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))) 6.0))) (+ (* x1 x1) 1.0)) (* (* (* 3.0 x1) x1) (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)))) (* (* x1 x1) x1)) x1) (* 3.0 (/ (- (- (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))))))