Average Error: 34.3 → 0.4
Time: 4.3s
Precision: 64
\[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
\[\mathsf{hypot}\left(\frac{z}{t}, \left|\frac{x}{y}\right|\right) \cdot \mathsf{hypot}\left(\frac{z}{t}, \left|\frac{x}{y}\right|\right)\]
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\mathsf{hypot}\left(\frac{z}{t}, \left|\frac{x}{y}\right|\right) \cdot \mathsf{hypot}\left(\frac{z}{t}, \left|\frac{x}{y}\right|\right)
double f(double x, double y, double z, double t) {
        double r573850 = x;
        double r573851 = r573850 * r573850;
        double r573852 = y;
        double r573853 = r573852 * r573852;
        double r573854 = r573851 / r573853;
        double r573855 = z;
        double r573856 = r573855 * r573855;
        double r573857 = t;
        double r573858 = r573857 * r573857;
        double r573859 = r573856 / r573858;
        double r573860 = r573854 + r573859;
        return r573860;
}

double f(double x, double y, double z, double t) {
        double r573861 = z;
        double r573862 = t;
        double r573863 = r573861 / r573862;
        double r573864 = x;
        double r573865 = y;
        double r573866 = r573864 / r573865;
        double r573867 = fabs(r573866);
        double r573868 = hypot(r573863, r573867);
        double r573869 = r573868 * r573868;
        return r573869;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 34.3

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

    \[\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.5

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

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

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

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

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

    \[\leadsto \mathsf{hypot}\left(\frac{z}{t}, \left|\frac{x}{y}\right|\right) \cdot \color{blue}{\mathsf{hypot}\left(\frac{z}{t}, \left|\frac{x}{y}\right|\right)}\]
  11. Final simplification0.4

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

Reproduce

herbie shell --seed 2020036 +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))))