Average Error: 11.0 → 2.9
Time: 5.4s
Precision: binary64
\[[a1, a2]=\mathsf{sort}([a1, a2])\]
\[[b1, b2]=\mathsf{sort}([b1, b2])\]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a2}{\sqrt[3]{b1}}\\ t_1 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ t_2 := \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{t_2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{t_0}{\sqrt[3]{b2}}\\ \mathbf{elif}\;t_1 \leq -1.8818987516754908 \cdot 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_2 \cdot \frac{t_0}{b2}\\ \mathbf{elif}\;t_1 \leq 6.223294763088865 \cdot 10^{+283}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{\frac{b2}{a1}}}{b1}\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a2}{\sqrt[3]{b1}}\\
t_1 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_2 := \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{t_2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{t_0}{\sqrt[3]{b2}}\\

\mathbf{elif}\;t_1 \leq -1.8818987516754908 \cdot 10^{-272}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;t_2 \cdot \frac{t_0}{b2}\\

\mathbf{elif}\;t_1 \leq 6.223294763088865 \cdot 10^{+283}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2}{\frac{b2}{a1}}}{b1}\\


\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ a2 (cbrt b1)))
        (t_1 (/ (* a1 a2) (* b1 b2)))
        (t_2 (/ a1 (* (cbrt b1) (cbrt b1)))))
   (if (<= t_1 (- INFINITY))
     (* (/ t_2 (* (cbrt b2) (cbrt b2))) (/ t_0 (cbrt b2)))
     (if (<= t_1 -1.8818987516754908e-272)
       t_1
       (if (<= t_1 0.0)
         (* t_2 (/ t_0 b2))
         (if (<= t_1 6.223294763088865e+283) t_1 (/ (/ a2 (/ b2 a1)) b1)))))))
double code(double a1, double a2, double b1, double b2) {
	return (a1 * a2) / (b1 * b2);
}
double code(double a1, double a2, double b1, double b2) {
	double t_0 = a2 / cbrt(b1);
	double t_1 = (a1 * a2) / (b1 * b2);
	double t_2 = a1 / (cbrt(b1) * cbrt(b1));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (t_2 / (cbrt(b2) * cbrt(b2))) * (t_0 / cbrt(b2));
	} else if (t_1 <= -1.8818987516754908e-272) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = t_2 * (t_0 / b2);
	} else if (t_1 <= 6.223294763088865e+283) {
		tmp = t_1;
	} else {
		tmp = (a2 / (b2 / a1)) / b1;
	}
	return tmp;
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.0
Target11.1
Herbie2.9
\[\frac{a1}{b1} \cdot \frac{a2}{b2} \]

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0

    1. Initial program 64.0

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary6435.5

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \]
    3. Applied add-cube-cbrt_binary6436.1

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}} \]
    4. Applied add-cube-cbrt_binary6436.2

      \[\leadsto \frac{\frac{a1 \cdot a2}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}} \]
    5. Applied times-frac_binary6418.7

      \[\leadsto \frac{\color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}} \]
    6. Applied times-frac_binary6410.0

      \[\leadsto \color{blue}{\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{\sqrt[3]{b2}}} \]

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.881898751675491e-272 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 6.22329476308886536e283

    1. Initial program 0.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary647.8

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \]
    3. Applied clear-num_binary648.1

      \[\leadsto \color{blue}{\frac{1}{\frac{b2}{\frac{a1 \cdot a2}{b1}}}} \]
    4. Applied *-un-lft-identity_binary648.1

      \[\leadsto \frac{1}{\frac{b2}{\color{blue}{1 \cdot \frac{a1 \cdot a2}{b1}}}} \]
    5. Applied *-un-lft-identity_binary648.1

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot b2}}{1 \cdot \frac{a1 \cdot a2}{b1}}} \]
    6. Applied times-frac_binary648.1

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{b2}{\frac{a1 \cdot a2}{b1}}}} \]
    7. Applied add-cube-cbrt_binary648.1

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{b2}{\frac{a1 \cdot a2}{b1}}} \]
    8. Applied times-frac_binary648.1

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{b2}{\frac{a1 \cdot a2}{b1}}}} \]
    9. Simplified8.1

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{b2}{\frac{a1 \cdot a2}{b1}}} \]
    10. Simplified0.9

      \[\leadsto 1 \cdot \color{blue}{\frac{a1 \cdot a2}{b2 \cdot b1}} \]

    if -1.881898751675491e-272 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0

    1. Initial program 12.5

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary646.6

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \]
    3. Applied *-un-lft-identity_binary646.6

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{1 \cdot b2}} \]
    4. Applied add-cube-cbrt_binary646.8

      \[\leadsto \frac{\frac{a1 \cdot a2}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}}{1 \cdot b2} \]
    5. Applied times-frac_binary643.8

      \[\leadsto \frac{\color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}}{1 \cdot b2} \]
    6. Applied times-frac_binary642.7

      \[\leadsto \color{blue}{\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{1} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}} \]
    7. Simplified2.7

      \[\leadsto \color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2} \]

    if 6.22329476308886536e283 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 57.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary6444.9

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \]
    3. Applied clear-num_binary6444.9

      \[\leadsto \color{blue}{\frac{1}{\frac{b2}{\frac{a1 \cdot a2}{b1}}}} \]
    4. Applied associate-/r/_binary6446.0

      \[\leadsto \frac{1}{\color{blue}{\frac{b2}{a1 \cdot a2} \cdot b1}} \]
    5. Applied associate-/r*_binary6446.0

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{b2}{a1 \cdot a2}}}{b1}} \]
    6. Simplified15.8

      \[\leadsto \frac{\color{blue}{\frac{a2}{\frac{b2}{a1}}}}{b1} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.8818987516754908 \cdot 10^{-272}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 6.223294763088865 \cdot 10^{+283}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{\frac{b2}{a1}}}{b1}\\ \end{array} \]

Reproduce

herbie shell --seed 2022039 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

  :herbie-target
  (* (/ a1 b1) (/ a2 b2))

  (/ (* a1 a2) (* b1 b2)))