Average Error: 11.3 → 1.7
Time: 6.5s
Precision: binary64
Cost: 41677
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.813907353819147 \cdot 10^{+300}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.813907353819147 \cdot 10^{+300}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\

\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (<= (/ (* a1 a2) (* b1 b2)) -1.813907353819147e+300)
   (* (/ a1 b1) (/ a2 b2))
   (if (or (<= (/ (* a1 a2) (* b1 b2)) -4.052483451900385e-279)
           (and (not (<= (/ (* a1 a2) (* b1 b2)) 0.0))
                (<= (/ (* a1 a2) (* b1 b2)) 8.713922770277385e+306)))
     (/ (* a1 a2) (* b1 b2))
     (*
      (/ (* (cbrt a1) (cbrt a1)) (* (cbrt b1) (cbrt b1)))
      (* (/ a2 b2) (/ (cbrt a1) (cbrt 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 tmp;
	if (((a1 * a2) / (b1 * b2)) <= -1.813907353819147e+300) {
		tmp = (a1 / b1) * (a2 / b2);
	} else if ((((a1 * a2) / (b1 * b2)) <= -4.052483451900385e-279) || (!(((a1 * a2) / (b1 * b2)) <= 0.0) && (((a1 * a2) / (b1 * b2)) <= 8.713922770277385e+306))) {
		tmp = (a1 * a2) / (b1 * b2);
	} else {
		tmp = ((cbrt(a1) * cbrt(a1)) / (cbrt(b1) * cbrt(b1))) * ((a2 / b2) * (cbrt(a1) / cbrt(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.3
Target10.9
Herbie1.7
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Alternatives

Alternative 1
Error1.8
Cost41677
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.813907353819147 \cdot 10^{+300}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \end{array}\]
Alternative 2
Error1.6
Cost41489
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}\right):\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \end{array}\]
Alternative 3
Error1.7
Cost41489
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}\right):\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \end{array}\]
Alternative 4
Error1.9
Cost41866
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279}:\\ \;\;\;\;\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \left(\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\right)\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0 \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}\right):\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt{\frac{a1 \cdot a2}{b1 \cdot b2}}\\ \end{array}\]
Alternative 5
Error2.1
Cost41489
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}\right):\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \left(\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\right)\\ \end{array}\]
Alternative 6
Error7.8
Cost39360
\[\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\]

Error

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.81390735381914711e300

    1. Initial program 59.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac_binary64_383511.2

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Simplified11.2

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

    if -1.81390735381914711e300 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -4.0524834519003848e-279 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 8.71392277027738548e306

    1. Initial program 0.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Simplified0.9

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

    if -4.0524834519003848e-279 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0 or 8.71392277027738548e306 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 21.4

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac_binary64_38353.0

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary64_38643.3

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

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

      \[\leadsto \color{blue}{\left(\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)} \cdot \frac{a2}{b2}\]
    8. Applied associate-*l*_binary64_37702.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{\sqrt[3]{a1}}{\sqrt[3]{b1}} \cdot \frac{a2}{b2}\right)}\]
    9. Simplified2.0

      \[\leadsto \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \color{blue}{\left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)}\]
    10. Simplified2.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.813907353819147 \cdot 10^{+300}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -4.052483451900385 \cdot 10^{-279} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.713922770277385 \cdot 10^{+306}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \end{array}\]

Reproduce

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

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

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