Average Error: 28.8 → 0.1
Time: 6.3s
Precision: 64
\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
\[0.5 \cdot \left(1 \cdot \mathsf{fma}\left(\frac{{x}^{1}}{y}, x, y\right) - z \cdot \frac{z}{y}\right)\]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
0.5 \cdot \left(1 \cdot \mathsf{fma}\left(\frac{{x}^{1}}{y}, x, y\right) - z \cdot \frac{z}{y}\right)
double f(double x, double y, double z) {
        double r622864 = x;
        double r622865 = r622864 * r622864;
        double r622866 = y;
        double r622867 = r622866 * r622866;
        double r622868 = r622865 + r622867;
        double r622869 = z;
        double r622870 = r622869 * r622869;
        double r622871 = r622868 - r622870;
        double r622872 = 2.0;
        double r622873 = r622866 * r622872;
        double r622874 = r622871 / r622873;
        return r622874;
}

double f(double x, double y, double z) {
        double r622875 = 0.5;
        double r622876 = 1.0;
        double r622877 = x;
        double r622878 = pow(r622877, r622876);
        double r622879 = y;
        double r622880 = r622878 / r622879;
        double r622881 = fma(r622880, r622877, r622879);
        double r622882 = r622876 * r622881;
        double r622883 = z;
        double r622884 = r622883 / r622879;
        double r622885 = r622883 * r622884;
        double r622886 = r622882 - r622885;
        double r622887 = r622875 * r622886;
        return r622887;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original28.8
Target0.2
Herbie0.1
\[y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)\]

Derivation

  1. Initial program 28.8

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

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{2}}{y}}\]
  3. Taylor expanded around 0 12.9

    \[\leadsto \color{blue}{\left(0.5 \cdot y + 0.5 \cdot \frac{{x}^{2}}{y}\right) - 0.5 \cdot \frac{{z}^{2}}{y}}\]
  4. Simplified12.9

    \[\leadsto \color{blue}{0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \frac{{z}^{2}}{y}\right)}\]
  5. Using strategy rm
  6. Applied sqr-pow12.9

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{\color{blue}{{x}^{\left(\frac{2}{2}\right)} \cdot {x}^{\left(\frac{2}{2}\right)}}}{y}\right) - \frac{{z}^{2}}{y}\right)\]
  7. Applied associate-/l*7.0

    \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{{x}^{\left(\frac{2}{2}\right)}}}}\right) - \frac{{z}^{2}}{y}\right)\]
  8. Simplified7.0

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\color{blue}{\frac{y}{x}}}\right) - \frac{{z}^{2}}{y}\right)\]
  9. Using strategy rm
  10. Applied *-un-lft-identity7.0

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - \frac{{z}^{2}}{\color{blue}{1 \cdot y}}\right)\]
  11. Applied add-sqr-sqrt35.7

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - \frac{{\color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}^{2}}{1 \cdot y}\right)\]
  12. Applied unpow-prod-down35.7

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - \frac{\color{blue}{{\left(\sqrt{z}\right)}^{2} \cdot {\left(\sqrt{z}\right)}^{2}}}{1 \cdot y}\right)\]
  13. Applied times-frac32.3

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - \color{blue}{\frac{{\left(\sqrt{z}\right)}^{2}}{1} \cdot \frac{{\left(\sqrt{z}\right)}^{2}}{y}}\right)\]
  14. Simplified32.2

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - \color{blue}{z} \cdot \frac{{\left(\sqrt{z}\right)}^{2}}{y}\right)\]
  15. Simplified0.1

    \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - z \cdot \color{blue}{\frac{z}{y}}\right)\]
  16. Using strategy rm
  17. Applied *-un-lft-identity0.1

    \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{1 \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}}\right) - z \cdot \frac{z}{y}\right)\]
  18. Applied *-un-lft-identity0.1

    \[\leadsto 0.5 \cdot \left(\left(\color{blue}{1 \cdot y} + 1 \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right) - z \cdot \frac{z}{y}\right)\]
  19. Applied distribute-lft-out0.1

    \[\leadsto 0.5 \cdot \left(\color{blue}{1 \cdot \left(y + \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{y}{x}}\right)} - z \cdot \frac{z}{y}\right)\]
  20. Simplified0.1

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

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

Reproduce

herbie shell --seed 2020081 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

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

  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2)))