Average Error: 33.4 → 2.2
Time: 5.6s
Precision: binary64
\[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 5.6706044911068 \cdot 10^{+264}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{z \cdot \frac{z}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{1}{t \cdot \frac{t}{z}}\\ \end{array}\]
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5.6706044911068 \cdot 10^{+264}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{z \cdot \frac{z}{t}}{t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{1}{t \cdot \frac{t}{z}}\\

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) ((((double) (x * x)) / ((double) (y * y))) + (((double) (z * z)) / ((double) (t * t)))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((((double) (z * z)) <= 5.6706044911068e+264)) {
		VAR = ((double) (((double) ((x / y) * (x / y))) + (((double) (z * (z / t))) / t)));
	} else {
		VAR = ((double) (((double) ((x / y) * (x / y))) + ((double) (z * (1.0 / ((double) (t * (t / z))))))));
	}
	return VAR;
}

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

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

Derivation

  1. Split input into 2 regimes
  2. if (* z z) < 5.6706044911067997e264

    1. Initial program 28.8

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
    2. Simplified22.7

      \[\leadsto \color{blue}{x \cdot \frac{x}{y \cdot y} + z \cdot \frac{z}{t \cdot t}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt43.1

      \[\leadsto x \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot y} + z \cdot \frac{z}{t \cdot t}\]
    5. Applied times-frac39.1

      \[\leadsto x \cdot \color{blue}{\left(\frac{\sqrt{x}}{y} \cdot \frac{\sqrt{x}}{y}\right)} + z \cdot \frac{z}{t \cdot t}\]
    6. Applied add-sqr-sqrt39.1

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \left(\frac{\sqrt{x}}{y} \cdot \frac{\sqrt{x}}{y}\right) + z \cdot \frac{z}{t \cdot t}\]
    7. Applied unswap-sqr37.2

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

      \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(\sqrt{x} \cdot \frac{\sqrt{x}}{y}\right) + z \cdot \frac{z}{t \cdot t}\]
    9. Simplified10.8

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} + z \cdot \frac{z}{t \cdot t}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity10.8

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{\color{blue}{1 \cdot z}}{t \cdot t}\]
    12. Applied times-frac4.1

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + z \cdot \color{blue}{\left(\frac{1}{t} \cdot \frac{z}{t}\right)}\]
    13. Using strategy rm
    14. Applied associate-*r/4.1

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + z \cdot \color{blue}{\frac{\frac{1}{t} \cdot z}{t}}\]
    15. Applied associate-*r/1.7

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

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{z \cdot \frac{z}{t}}}{t}\]

    if 5.6706044911067997e264 < (* z z)

    1. Initial program 58.5

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
    2. Simplified32.1

      \[\leadsto \color{blue}{x \cdot \frac{x}{y \cdot y} + z \cdot \frac{z}{t \cdot t}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt47.9

      \[\leadsto x \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot y} + z \cdot \frac{z}{t \cdot t}\]
    5. Applied times-frac45.3

      \[\leadsto x \cdot \color{blue}{\left(\frac{\sqrt{x}}{y} \cdot \frac{\sqrt{x}}{y}\right)} + z \cdot \frac{z}{t \cdot t}\]
    6. Applied add-sqr-sqrt45.3

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \left(\frac{\sqrt{x}}{y} \cdot \frac{\sqrt{x}}{y}\right) + z \cdot \frac{z}{t \cdot t}\]
    7. Applied unswap-sqr43.9

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \frac{\sqrt{x}}{y}\right) \cdot \left(\sqrt{x} \cdot \frac{\sqrt{x}}{y}\right)} + z \cdot \frac{z}{t \cdot t}\]
    8. Simplified43.9

      \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(\sqrt{x} \cdot \frac{\sqrt{x}}{y}\right) + z \cdot \frac{z}{t \cdot t}\]
    9. Simplified24.1

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} + z \cdot \frac{z}{t \cdot t}\]
    10. Using strategy rm
    11. Applied clear-num24.1

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + z \cdot \color{blue}{\frac{1}{\frac{t \cdot t}{z}}}\]
    12. Simplified5.2

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{1}{\color{blue}{t \cdot \frac{t}{z}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 5.6706044911068 \cdot 10^{+264}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{z \cdot \frac{z}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{1}{t \cdot \frac{t}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020199 
(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.0) (pow (/ z t) 2.0))

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