Average Error: 33.7 → 1.3
Time: 5.8s
Precision: binary64
\[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
\[\begin{array}{l} \mathbf{if}\;t \leq -1.342217695911771 \cdot 10^{+154}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{1}{t} \cdot \left(z \cdot \frac{z}{t}\right)\\ \mathbf{elif}\;t \leq -4.396223194186806 \cdot 10^{-140}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{z}{t \cdot t}\\ \mathbf{elif}\;t \leq 3.849433641532173 \cdot 10^{-306}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{1}{t} \cdot \left(z \cdot \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{\frac{z}{t}}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\\ \end{array}\]
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.342217695911771 \cdot 10^{+154}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{1}{t} \cdot \left(z \cdot \frac{z}{t}\right)\\

\mathbf{elif}\;t \leq -4.396223194186806 \cdot 10^{-140}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{z}{t \cdot t}\\

\mathbf{elif}\;t \leq 3.849433641532173 \cdot 10^{-306}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{1}{t} \cdot \left(z \cdot \frac{z}{t}\right)\\

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

\end{array}
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -1.342217695911771e+154)
   (+ (* (/ x y) (/ x y)) (* (/ 1.0 t) (* z (/ z t))))
   (if (<= t -4.396223194186806e-140)
     (+ (* (/ x y) (/ x y)) (* z (/ z (* t t))))
     (if (<= t 3.849433641532173e-306)
       (+ (* (/ x y) (/ x y)) (* (/ 1.0 t) (* z (/ z t))))
       (+ (* (/ x y) (/ x y)) (* (/ (/ z t) (sqrt t)) (/ z (sqrt t))))))))
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 tmp;
	if ((t <= -1.342217695911771e+154)) {
		tmp = ((double) (((double) ((x / y) * (x / y))) + ((double) ((1.0 / t) * ((double) (z * (z / t)))))));
	} else {
		double tmp_1;
		if ((t <= -4.396223194186806e-140)) {
			tmp_1 = ((double) (((double) ((x / y) * (x / y))) + ((double) (z * (z / ((double) (t * t)))))));
		} else {
			double tmp_2;
			if ((t <= 3.849433641532173e-306)) {
				tmp_2 = ((double) (((double) ((x / y) * (x / y))) + ((double) ((1.0 / t) * ((double) (z * (z / t)))))));
			} else {
				tmp_2 = ((double) (((double) ((x / y) * (x / y))) + ((double) (((z / t) / ((double) sqrt(t))) * (z / ((double) sqrt(t)))))));
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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.7
Target0.4
Herbie1.3
\[{\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -1.34221769591177092e154 or -4.39622319418680645e-140 < t < 3.84943364153217298e-306

    1. Initial program 42.9

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
    2. Using strategy rm
    3. Applied times-frac_binary6430.5

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t}\]
    4. Using strategy rm
    5. Applied times-frac_binary640.4

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\frac{z}{t} \cdot \frac{z}{t}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt_binary6463.8

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t} \cdot \frac{z}{\color{blue}{\sqrt{t} \cdot \sqrt{t}}}\]
    8. Applied *-un-lft-identity_binary6463.8

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

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

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{\color{blue}{\sqrt{t} \cdot \sqrt{t}}} \cdot \left(\frac{1}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\right)\]
    11. Applied *-un-lft-identity_binary6463.8

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{1 \cdot z}}{\sqrt{t} \cdot \sqrt{t}} \cdot \left(\frac{1}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\right)\]
    12. Applied times-frac_binary6463.8

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\left(\frac{1}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\right)} \cdot \left(\frac{1}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\right)\]
    13. Applied swap-sqr_binary6463.8

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

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

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

    if -1.34221769591177092e154 < t < -4.39622319418680645e-140

    1. Initial program 25.2

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
    2. Using strategy rm
    3. Applied times-frac_binary647.4

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t}\]
    4. Using strategy rm
    5. Applied times-frac_binary640.5

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\frac{z}{t} \cdot \frac{z}{t}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary640.5

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t} \cdot \frac{z}{\color{blue}{1 \cdot t}}\]
    8. Applied add-sqr-sqrt_binary6433.0

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

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t} \cdot \color{blue}{\left(\frac{\sqrt{z}}{1} \cdot \frac{\sqrt{z}}{t}\right)}\]
    10. Applied *-un-lft-identity_binary6433.0

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

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{1 \cdot t} \cdot \left(\frac{\sqrt{z}}{1} \cdot \frac{\sqrt{z}}{t}\right)\]
    12. Applied times-frac_binary6433.1

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\left(\frac{\sqrt{z}}{1} \cdot \frac{\sqrt{z}}{t}\right)} \cdot \left(\frac{\sqrt{z}}{1} \cdot \frac{\sqrt{z}}{t}\right)\]
    13. Applied swap-sqr_binary6433.1

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

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

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

    if 3.84943364153217298e-306 < t

    1. Initial program 33.3

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}\]
    2. Using strategy rm
    3. Applied times-frac_binary6418.9

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t}\]
    4. Using strategy rm
    5. Applied times-frac_binary640.4

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\frac{z}{t} \cdot \frac{z}{t}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt_binary640.5

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t} \cdot \frac{z}{\color{blue}{\sqrt{t} \cdot \sqrt{t}}}\]
    8. Applied *-un-lft-identity_binary640.5

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

      \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t} \cdot \color{blue}{\left(\frac{1}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\right)}\]
    10. Applied associate-*r*_binary640.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.342217695911771 \cdot 10^{+154}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{1}{t} \cdot \left(z \cdot \frac{z}{t}\right)\\ \mathbf{elif}\;t \leq -4.396223194186806 \cdot 10^{-140}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + z \cdot \frac{z}{t \cdot t}\\ \mathbf{elif}\;t \leq 3.849433641532173 \cdot 10^{-306}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{1}{t} \cdot \left(z \cdot \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{\frac{z}{t}}{\sqrt{t}} \cdot \frac{z}{\sqrt{t}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020205 
(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))))