Average Error: 10.2 → 5.5
Time: 2.3s
Precision: binary64
\[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.0098576522032265 \cdot 10^{-302}:\\ \;\;\;\;3 \cdot \left(y \cdot {x}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(x \cdot \sqrt{y \cdot 3}\right)}^{2}\\ \end{array} \]
\left(\left(x \cdot 3\right) \cdot x\right) \cdot y
\begin{array}{l}
\mathbf{if}\;y \leq -1.0098576522032265 \cdot 10^{-302}:\\
\;\;\;\;3 \cdot \left(y \cdot {x}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;{\left(x \cdot \sqrt{y \cdot 3}\right)}^{2}\\


\end{array}
(FPCore (x y) :precision binary64 (* (* (* x 3.0) x) y))
(FPCore (x y)
 :precision binary64
 (if (<= y -1.0098576522032265e-302)
   (* 3.0 (* y (pow x 2.0)))
   (pow (* x (sqrt (* y 3.0))) 2.0)))
double code(double x, double y) {
	return ((x * 3.0) * x) * y;
}
double code(double x, double y) {
	double tmp;
	if (y <= -1.0098576522032265e-302) {
		tmp = 3.0 * (y * pow(x, 2.0));
	} else {
		tmp = pow((x * sqrt((y * 3.0))), 2.0);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.2
Target0.2
Herbie5.5
\[\left(x \cdot 3\right) \cdot \left(x \cdot y\right) \]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.00985765220322646e-302

    1. Initial program 9.8

      \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y \]
    2. Taylor expanded in x around 0 9.8

      \[\leadsto \color{blue}{3 \cdot \left(y \cdot {x}^{2}\right)} \]

    if -1.00985765220322646e-302 < y

    1. Initial program 10.5

      \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y \]
    2. Taylor expanded in x around 0 10.5

      \[\leadsto \color{blue}{3 \cdot \left(y \cdot {x}^{2}\right)} \]
    3. Applied egg-rr1.3

      \[\leadsto \color{blue}{{\left(\sqrt{y \cdot 3} \cdot x\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.0098576522032265 \cdot 10^{-302}:\\ \;\;\;\;3 \cdot \left(y \cdot {x}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(x \cdot \sqrt{y \cdot 3}\right)}^{2}\\ \end{array} \]

Reproduce

herbie shell --seed 2022125 
(FPCore (x y)
  :name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (* (* x 3.0) (* x y))

  (* (* (* x 3.0) x) y))