Average Error: 7.0 → 0.1
Time: 7.5s
Precision: binary64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\mathsf{fma}\left(\frac{y}{x + 1}, {\left(t - \frac{x}{z}\right)}^{-1}, \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\right) \]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\mathsf{fma}\left(\frac{y}{x + 1}, {\left(t - \frac{x}{z}\right)}^{-1}, \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\right)
(FPCore (x y z t)
 :precision binary64
 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
(FPCore (x y z t)
 :precision binary64
 (fma
  (/ y (+ x 1.0))
  (pow (- t (/ x z)) -1.0)
  (/ (- x (/ x (- (* t z) x))) (+ x 1.0))))
double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
double code(double x, double y, double z, double t) {
	return fma((y / (x + 1.0)), pow((t - (x / z)), -1.0), ((x - (x / ((t * z) - x))) / (x + 1.0)));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.0
Target0.3
Herbie0.1
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation

  1. Initial program 7.0

    \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
  2. Taylor expanded in y around 0 7.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{x + 1}, \frac{z}{t \cdot z - x}, \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\right)} \]
  4. Applied egg-rr1.8

    \[\leadsto \mathsf{fma}\left(\frac{y}{x + 1}, \color{blue}{{\left(\frac{z \cdot t - x}{z}\right)}^{-1}}, \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\right) \]
  5. Taylor expanded in z around 0 0.1

    \[\leadsto \mathsf{fma}\left(\frac{y}{x + 1}, {\color{blue}{\left(t - \frac{x}{z}\right)}}^{-1}, \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\right) \]
  6. Final simplification0.1

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

Reproduce

herbie shell --seed 2022125 
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"
  :precision binary64

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

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