Average Error: 33.9 → 0.6
Time: 5.9s
Precision: 64
\[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
\[\sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \left(\frac{x}{y} \cdot \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right)\right) \cdot \sqrt[3]{\frac{x}{y}}\right)} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)\]
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \left(\frac{x}{y} \cdot \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right)\right) \cdot \sqrt[3]{\frac{x}{y}}\right)} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)
double f(double x, double y, double z, double t) {
        double r737363 = x;
        double r737364 = r737363 * r737363;
        double r737365 = y;
        double r737366 = r737365 * r737365;
        double r737367 = r737364 / r737366;
        double r737368 = z;
        double r737369 = r737368 * r737368;
        double r737370 = t;
        double r737371 = r737370 * r737370;
        double r737372 = r737369 / r737371;
        double r737373 = r737367 + r737372;
        return r737373;
}

double f(double x, double y, double z, double t) {
        double r737374 = z;
        double r737375 = t;
        double r737376 = r737374 / r737375;
        double r737377 = x;
        double r737378 = y;
        double r737379 = r737377 / r737378;
        double r737380 = cbrt(r737379);
        double r737381 = r737380 * r737380;
        double r737382 = r737379 * r737381;
        double r737383 = r737382 * r737380;
        double r737384 = fma(r737376, r737376, r737383);
        double r737385 = sqrt(r737384);
        double r737386 = hypot(r737376, r737379);
        double r737387 = r737385 * r737386;
        return r737387;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original33.9
Target0.4
Herbie0.6
\[{\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2}\]

Derivation

  1. Initial program 33.9

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
  2. Simplified19.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x \cdot x}{y \cdot y}\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt19.1

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x \cdot x}{y \cdot y}\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x \cdot x}{y \cdot y}\right)}}\]
  5. Simplified19.0

    \[\leadsto \color{blue}{\mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x \cdot x}{y \cdot y}\right)}\]
  6. Simplified0.4

    \[\leadsto \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right) \cdot \color{blue}{\mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)}\]
  7. Using strategy rm
  8. Applied hypot-udef0.4

    \[\leadsto \color{blue}{\sqrt{\frac{z}{t} \cdot \frac{z}{t} + \frac{x}{y} \cdot \frac{x}{y}}} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)\]
  9. Simplified0.4

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y} \cdot \frac{x}{y}\right)}} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)\]
  10. Using strategy rm
  11. Applied add-cube-cbrt0.6

    \[\leadsto \sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y} \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right) \cdot \sqrt[3]{\frac{x}{y}}\right)}\right)} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)\]
  12. Applied associate-*r*0.6

    \[\leadsto \sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\left(\frac{x}{y} \cdot \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right)\right) \cdot \sqrt[3]{\frac{x}{y}}}\right)} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)\]
  13. Final simplification0.6

    \[\leadsto \sqrt{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \left(\frac{x}{y} \cdot \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right)\right) \cdot \sqrt[3]{\frac{x}{y}}\right)} \cdot \mathsf{hypot}\left(\frac{z}{t}, \frac{x}{y}\right)\]

Reproduce

herbie shell --seed 2020083 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
  :precision binary64

  :herbie-target
  (+ (pow (/ x y) 2) (pow (/ z t) 2))

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