Rump's expression from Stadtherr's award speech

Percentage Accurate: 9.2% → 21.1%
Time: 7.4s
Alternatives: 5
Speedup: 17.3×

Specification

?
\[x = 77617 \land y = 33096\]
\[\begin{array}{l} \\ -0.8273960599468214 \end{array} \]
(FPCore (x y) :precision binary64 -0.8273960599468214)
double code(double x, double y) {
	return -0.8273960599468214;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -0.8273960599468214d0
end function
public static double code(double x, double y) {
	return -0.8273960599468214;
}
def code(x, y):
	return -0.8273960599468214
function code(x, y)
	return -0.8273960599468214
end
function tmp = code(x, y)
	tmp = -0.8273960599468214;
end
code[x_, y_] := -0.8273960599468214
\begin{array}{l}

\\
-0.8273960599468214
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 9.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y} \end{array} \]
(FPCore (x y)
 :precision binary64
 (+
  (+
   (+
    (* 333.75 (pow y 6.0))
    (*
     (* x x)
     (-
      (- (- (* (* (* (* 11.0 x) x) y) y) (pow y 6.0)) (* 121.0 (pow y 4.0)))
      2.0)))
   (* 5.5 (pow y 8.0)))
  (/ x (* 2.0 y))))
double code(double x, double y) {
	return (((333.75 * pow(y, 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - pow(y, 6.0)) - (121.0 * pow(y, 4.0))) - 2.0))) + (5.5 * pow(y, 8.0))) + (x / (2.0 * y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (((333.75d0 * (y ** 6.0d0)) + ((x * x) * (((((((11.0d0 * x) * x) * y) * y) - (y ** 6.0d0)) - (121.0d0 * (y ** 4.0d0))) - 2.0d0))) + (5.5d0 * (y ** 8.0d0))) + (x / (2.0d0 * y))
end function
public static double code(double x, double y) {
	return (((333.75 * Math.pow(y, 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - Math.pow(y, 6.0)) - (121.0 * Math.pow(y, 4.0))) - 2.0))) + (5.5 * Math.pow(y, 8.0))) + (x / (2.0 * y));
}
def code(x, y):
	return (((333.75 * math.pow(y, 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - math.pow(y, 6.0)) - (121.0 * math.pow(y, 4.0))) - 2.0))) + (5.5 * math.pow(y, 8.0))) + (x / (2.0 * y))
function code(x, y)
	return Float64(Float64(Float64(Float64(333.75 * (y ^ 6.0)) + Float64(Float64(x * x) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(11.0 * x) * x) * y) * y) - (y ^ 6.0)) - Float64(121.0 * (y ^ 4.0))) - 2.0))) + Float64(5.5 * (y ^ 8.0))) + Float64(x / Float64(2.0 * y)))
end
function tmp = code(x, y)
	tmp = (((333.75 * (y ^ 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - (y ^ 6.0)) - (121.0 * (y ^ 4.0))) - 2.0))) + (5.5 * (y ^ 8.0))) + (x / (2.0 * y));
end
code[x_, y_] := N[(N[(N[(N[(333.75 * N[Power[y, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(11.0 * x), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] - N[Power[y, 6.0], $MachinePrecision]), $MachinePrecision] - N[(121.0 * N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.5 * N[Power[y, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y}
\end{array}

Alternative 1: 21.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -2 \cdot \left(x \cdot x\right)\\ t_1 := \mathsf{fma}\left(\frac{x}{y}, 0.5, t\_0\right)\\ t_2 := \frac{x}{y} \cdot 0.5\\ t_3 := t\_0 - t\_2\\ t_4 := t\_3 \cdot {t\_0}^{2}\\ t_5 := t\_2 - t\_0\\ t_6 := \mathsf{fma}\left(0.0625, {\left({\left(\frac{x}{y}\right)}^{2} \cdot t\_5\right)}^{2}, \left(t\_3 \cdot \mathsf{hypot}\left(t\_2, t\_0\right)\right) \cdot t\_4\right)\\ t_7 := {t\_2}^{2}\\ \frac{t\_3 \cdot t\_7 - t\_4}{\frac{\frac{{t\_5}^{3} \cdot {t\_0}^{6}}{t\_6}}{t\_1} - \frac{\frac{{\left(t\_7 \cdot t\_5\right)}^{3}}{t\_6}}{t\_1}} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* -2.0 (* x x)))
        (t_1 (fma (/ x y) 0.5 t_0))
        (t_2 (* (/ x y) 0.5))
        (t_3 (- t_0 t_2))
        (t_4 (* t_3 (pow t_0 2.0)))
        (t_5 (- t_2 t_0))
        (t_6
         (fma
          0.0625
          (pow (* (pow (/ x y) 2.0) t_5) 2.0)
          (* (* t_3 (hypot t_2 t_0)) t_4)))
        (t_7 (pow t_2 2.0)))
   (/
    (- (* t_3 t_7) t_4)
    (-
     (/ (/ (* (pow t_5 3.0) (pow t_0 6.0)) t_6) t_1)
     (/ (/ (pow (* t_7 t_5) 3.0) t_6) t_1)))))
double code(double x, double y) {
	double t_0 = -2.0 * (x * x);
	double t_1 = fma((x / y), 0.5, t_0);
	double t_2 = (x / y) * 0.5;
	double t_3 = t_0 - t_2;
	double t_4 = t_3 * pow(t_0, 2.0);
	double t_5 = t_2 - t_0;
	double t_6 = fma(0.0625, pow((pow((x / y), 2.0) * t_5), 2.0), ((t_3 * hypot(t_2, t_0)) * t_4));
	double t_7 = pow(t_2, 2.0);
	return ((t_3 * t_7) - t_4) / ((((pow(t_5, 3.0) * pow(t_0, 6.0)) / t_6) / t_1) - ((pow((t_7 * t_5), 3.0) / t_6) / t_1));
}
function code(x, y)
	t_0 = Float64(-2.0 * Float64(x * x))
	t_1 = fma(Float64(x / y), 0.5, t_0)
	t_2 = Float64(Float64(x / y) * 0.5)
	t_3 = Float64(t_0 - t_2)
	t_4 = Float64(t_3 * (t_0 ^ 2.0))
	t_5 = Float64(t_2 - t_0)
	t_6 = fma(0.0625, (Float64((Float64(x / y) ^ 2.0) * t_5) ^ 2.0), Float64(Float64(t_3 * hypot(t_2, t_0)) * t_4))
	t_7 = t_2 ^ 2.0
	return Float64(Float64(Float64(t_3 * t_7) - t_4) / Float64(Float64(Float64(Float64((t_5 ^ 3.0) * (t_0 ^ 6.0)) / t_6) / t_1) - Float64(Float64((Float64(t_7 * t_5) ^ 3.0) / t_6) / t_1)))
end
code[x_, y_] := Block[{t$95$0 = N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * 0.5 + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 - t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 - t$95$0), $MachinePrecision]}, Block[{t$95$6 = N[(0.0625 * N[Power[N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] * t$95$5), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$3 * N[Sqrt[t$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[Power[t$95$2, 2.0], $MachinePrecision]}, N[(N[(N[(t$95$3 * t$95$7), $MachinePrecision] - t$95$4), $MachinePrecision] / N[(N[(N[(N[(N[Power[t$95$5, 3.0], $MachinePrecision] * N[Power[t$95$0, 6.0], $MachinePrecision]), $MachinePrecision] / t$95$6), $MachinePrecision] / t$95$1), $MachinePrecision] - N[(N[(N[Power[N[(t$95$7 * t$95$5), $MachinePrecision], 3.0], $MachinePrecision] / t$95$6), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -2 \cdot \left(x \cdot x\right)\\
t_1 := \mathsf{fma}\left(\frac{x}{y}, 0.5, t\_0\right)\\
t_2 := \frac{x}{y} \cdot 0.5\\
t_3 := t\_0 - t\_2\\
t_4 := t\_3 \cdot {t\_0}^{2}\\
t_5 := t\_2 - t\_0\\
t_6 := \mathsf{fma}\left(0.0625, {\left({\left(\frac{x}{y}\right)}^{2} \cdot t\_5\right)}^{2}, \left(t\_3 \cdot \mathsf{hypot}\left(t\_2, t\_0\right)\right) \cdot t\_4\right)\\
t_7 := {t\_2}^{2}\\
\frac{t\_3 \cdot t\_7 - t\_4}{\frac{\frac{{t\_5}^{3} \cdot {t\_0}^{6}}{t\_6}}{t\_1} - \frac{\frac{{\left(t\_7 \cdot t\_5\right)}^{3}}{t\_6}}{t\_1}}
\end{array}
\end{array}
Derivation
  1. Initial program 9.2%

    \[\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{-2 \cdot {x}^{2}} + \frac{x}{2 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    3. unpow2N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
    4. lower-*.f6410.8

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
  5. Applied rewrites10.8%

    \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2} + \frac{x}{2 \cdot y} \]
  6. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2 + \frac{x}{2 \cdot y}} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y} + \left(x \cdot x\right) \cdot -2} \]
    3. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    4. div-invN/A

      \[\leadsto \color{blue}{x \cdot \frac{1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    5. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{x \cdot 1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    6. lift-*.f64N/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    7. *-commutativeN/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{y \cdot 2}} + \left(x \cdot x\right) \cdot -2 \]
    8. times-fracN/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    9. metadata-evalN/A

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    10. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{1}{2}, \left(x \cdot x\right) \cdot -2\right)} \]
    11. lower-/.f6410.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, 0.5, \left(x \cdot x\right) \cdot -2\right) \]
  7. Applied rewrites10.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} \]
  8. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2} + -2 \cdot \left(x \cdot x\right)} \]
    2. flip-+N/A

      \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot \frac{1}{2}\right) \cdot \left(\frac{x}{y} \cdot \frac{1}{2}\right) - \left(-2 \cdot \left(x \cdot x\right)\right) \cdot \left(-2 \cdot \left(x \cdot x\right)\right)}{\frac{x}{y} \cdot \frac{1}{2} - -2 \cdot \left(x \cdot x\right)}} \]
  9. Applied rewrites10.8%

    \[\leadsto \color{blue}{\frac{{\left(0.5 \cdot \frac{x}{y}\right)}^{2} \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) - \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot {\left(\left(x \cdot x\right) \cdot -2\right)}^{2}}{\left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)}} \]
  10. Applied rewrites21.1%

    \[\leadsto \frac{{\left(0.5 \cdot \frac{x}{y}\right)}^{2} \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) - \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot {\left(\left(x \cdot x\right) \cdot -2\right)}^{2}}{\color{blue}{\frac{\frac{{\left(\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right) \cdot {\left(\frac{x}{y} \cdot 0.5\right)}^{2}\right)}^{3}}{\mathsf{fma}\left(0.0625, {\left({\left(\frac{x}{y}\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right)}^{2}, \left({\left(-2 \cdot \left(x \cdot x\right)\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right) \cdot \left(\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right) \cdot \mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} - \frac{\frac{{\left(-2 \cdot \left(x \cdot x\right)\right)}^{6} \cdot {\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)}^{3}}{\mathsf{fma}\left(0.0625, {\left({\left(\frac{x}{y}\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right)}^{2}, \left({\left(-2 \cdot \left(x \cdot x\right)\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right) \cdot \left(\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right) \cdot \mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)}}} \]
  11. Final simplification21.1%

    \[\leadsto \frac{\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot {\left(\frac{x}{y} \cdot 0.5\right)}^{2} - \left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot {\left(-2 \cdot \left(x \cdot x\right)\right)}^{2}}{\frac{\frac{{\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)}^{3} \cdot {\left(-2 \cdot \left(x \cdot x\right)\right)}^{6}}{\mathsf{fma}\left(0.0625, {\left({\left(\frac{x}{y}\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right)}^{2}, \left(\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot \mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)\right) \cdot \left(\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot {\left(-2 \cdot \left(x \cdot x\right)\right)}^{2}\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} - \frac{\frac{{\left({\left(\frac{x}{y} \cdot 0.5\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right)}^{3}}{\mathsf{fma}\left(0.0625, {\left({\left(\frac{x}{y}\right)}^{2} \cdot \left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)\right)}^{2}, \left(\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot \mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)\right) \cdot \left(\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot {\left(-2 \cdot \left(x \cdot x\right)\right)}^{2}\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)}} \]
  12. Add Preprocessing

Alternative 2: 21.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -2 \cdot \left(x \cdot x\right)\\ t_1 := \frac{x}{y} \cdot 0.5\\ t_2 := t\_0 - t\_1\\ t_3 := \frac{{\left(t\_1 - t\_0\right)}^{2}}{\mathsf{hypot}\left(t\_1, t\_0\right)}\\ t_4 := \mathsf{fma}\left(\frac{x}{y}, 0.5, t\_0\right)\\ \frac{t\_2 \cdot {t\_1}^{2} - t\_2 \cdot {t\_0}^{2}}{\frac{\frac{{t\_1}^{4}}{t\_2} \cdot t\_3}{t\_4} - \frac{\frac{{t\_0}^{4}}{t\_2} \cdot t\_3}{t\_4}} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* -2.0 (* x x)))
        (t_1 (* (/ x y) 0.5))
        (t_2 (- t_0 t_1))
        (t_3 (/ (pow (- t_1 t_0) 2.0) (hypot t_1 t_0)))
        (t_4 (fma (/ x y) 0.5 t_0)))
   (/
    (- (* t_2 (pow t_1 2.0)) (* t_2 (pow t_0 2.0)))
    (-
     (/ (* (/ (pow t_1 4.0) t_2) t_3) t_4)
     (/ (* (/ (pow t_0 4.0) t_2) t_3) t_4)))))
double code(double x, double y) {
	double t_0 = -2.0 * (x * x);
	double t_1 = (x / y) * 0.5;
	double t_2 = t_0 - t_1;
	double t_3 = pow((t_1 - t_0), 2.0) / hypot(t_1, t_0);
	double t_4 = fma((x / y), 0.5, t_0);
	return ((t_2 * pow(t_1, 2.0)) - (t_2 * pow(t_0, 2.0))) / ((((pow(t_1, 4.0) / t_2) * t_3) / t_4) - (((pow(t_0, 4.0) / t_2) * t_3) / t_4));
}
function code(x, y)
	t_0 = Float64(-2.0 * Float64(x * x))
	t_1 = Float64(Float64(x / y) * 0.5)
	t_2 = Float64(t_0 - t_1)
	t_3 = Float64((Float64(t_1 - t_0) ^ 2.0) / hypot(t_1, t_0))
	t_4 = fma(Float64(x / y), 0.5, t_0)
	return Float64(Float64(Float64(t_2 * (t_1 ^ 2.0)) - Float64(t_2 * (t_0 ^ 2.0))) / Float64(Float64(Float64(Float64((t_1 ^ 4.0) / t_2) * t_3) / t_4) - Float64(Float64(Float64((t_0 ^ 4.0) / t_2) * t_3) / t_4)))
end
code[x_, y_] := Block[{t$95$0 = N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[(t$95$1 - t$95$0), $MachinePrecision], 2.0], $MachinePrecision] / N[Sqrt[t$95$1 ^ 2 + t$95$0 ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(x / y), $MachinePrecision] * 0.5 + t$95$0), $MachinePrecision]}, N[(N[(N[(t$95$2 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[Power[t$95$1, 4.0], $MachinePrecision] / t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision] / t$95$4), $MachinePrecision] - N[(N[(N[(N[Power[t$95$0, 4.0], $MachinePrecision] / t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -2 \cdot \left(x \cdot x\right)\\
t_1 := \frac{x}{y} \cdot 0.5\\
t_2 := t\_0 - t\_1\\
t_3 := \frac{{\left(t\_1 - t\_0\right)}^{2}}{\mathsf{hypot}\left(t\_1, t\_0\right)}\\
t_4 := \mathsf{fma}\left(\frac{x}{y}, 0.5, t\_0\right)\\
\frac{t\_2 \cdot {t\_1}^{2} - t\_2 \cdot {t\_0}^{2}}{\frac{\frac{{t\_1}^{4}}{t\_2} \cdot t\_3}{t\_4} - \frac{\frac{{t\_0}^{4}}{t\_2} \cdot t\_3}{t\_4}}
\end{array}
\end{array}
Derivation
  1. Initial program 9.2%

    \[\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{-2 \cdot {x}^{2}} + \frac{x}{2 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    3. unpow2N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
    4. lower-*.f6410.8

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
  5. Applied rewrites10.8%

    \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2} + \frac{x}{2 \cdot y} \]
  6. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2 + \frac{x}{2 \cdot y}} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y} + \left(x \cdot x\right) \cdot -2} \]
    3. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    4. div-invN/A

      \[\leadsto \color{blue}{x \cdot \frac{1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    5. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{x \cdot 1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    6. lift-*.f64N/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    7. *-commutativeN/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{y \cdot 2}} + \left(x \cdot x\right) \cdot -2 \]
    8. times-fracN/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    9. metadata-evalN/A

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    10. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{1}{2}, \left(x \cdot x\right) \cdot -2\right)} \]
    11. lower-/.f6410.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, 0.5, \left(x \cdot x\right) \cdot -2\right) \]
  7. Applied rewrites10.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} \]
  8. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2} + -2 \cdot \left(x \cdot x\right)} \]
    2. flip-+N/A

      \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot \frac{1}{2}\right) \cdot \left(\frac{x}{y} \cdot \frac{1}{2}\right) - \left(-2 \cdot \left(x \cdot x\right)\right) \cdot \left(-2 \cdot \left(x \cdot x\right)\right)}{\frac{x}{y} \cdot \frac{1}{2} - -2 \cdot \left(x \cdot x\right)}} \]
  9. Applied rewrites10.8%

    \[\leadsto \color{blue}{\frac{{\left(0.5 \cdot \frac{x}{y}\right)}^{2} \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) - \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot {\left(\left(x \cdot x\right) \cdot -2\right)}^{2}}{\left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)}} \]
  10. Applied rewrites21.1%

    \[\leadsto \frac{{\left(0.5 \cdot \frac{x}{y}\right)}^{2} \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) - \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot {\left(\left(x \cdot x\right) \cdot -2\right)}^{2}}{\color{blue}{\frac{\frac{{\left(\frac{x}{y} \cdot 0.5\right)}^{4}}{\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)} \cdot \frac{{\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)}^{2}}{\mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} - \frac{\frac{{\left(-2 \cdot \left(x \cdot x\right)\right)}^{4}}{\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)} \cdot \frac{{\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)}^{2}}{\mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)}}} \]
  11. Final simplification21.1%

    \[\leadsto \frac{\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot {\left(\frac{x}{y} \cdot 0.5\right)}^{2} - \left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot {\left(-2 \cdot \left(x \cdot x\right)\right)}^{2}}{\frac{\frac{{\left(\frac{x}{y} \cdot 0.5\right)}^{4}}{-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5} \cdot \frac{{\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)}^{2}}{\mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} - \frac{\frac{{\left(-2 \cdot \left(x \cdot x\right)\right)}^{4}}{-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5} \cdot \frac{{\left(\frac{x}{y} \cdot 0.5 - -2 \cdot \left(x \cdot x\right)\right)}^{2}}{\mathsf{hypot}\left(\frac{x}{y} \cdot 0.5, -2 \cdot \left(x \cdot x\right)\right)}}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)}} \]
  12. Add Preprocessing

Alternative 3: 20.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\\ \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot 0.5\right), y, {x}^{3} \cdot 0.125\right)}{{y}^{3}}}{t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- (* -2.0 (* x x)) (* (/ x y) 0.5))))
   (/
    (/
     (fma
      (fma (* (pow x 5.0) y) -2.0 (* (pow x 4.0) 0.5))
      y
      (* (pow x 3.0) 0.125))
     (pow y 3.0))
    (* t_0 t_0))))
double code(double x, double y) {
	double t_0 = (-2.0 * (x * x)) - ((x / y) * 0.5);
	return (fma(fma((pow(x, 5.0) * y), -2.0, (pow(x, 4.0) * 0.5)), y, (pow(x, 3.0) * 0.125)) / pow(y, 3.0)) / (t_0 * t_0);
}
function code(x, y)
	t_0 = Float64(Float64(-2.0 * Float64(x * x)) - Float64(Float64(x / y) * 0.5))
	return Float64(Float64(fma(fma(Float64((x ^ 5.0) * y), -2.0, Float64((x ^ 4.0) * 0.5)), y, Float64((x ^ 3.0) * 0.125)) / (y ^ 3.0)) / Float64(t_0 * t_0))
end
code[x_, y_] := Block[{t$95$0 = N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[Power[x, 5.0], $MachinePrecision] * y), $MachinePrecision] * -2.0 + N[(N[Power[x, 4.0], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * y + N[(N[Power[x, 3.0], $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\\
\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot 0.5\right), y, {x}^{3} \cdot 0.125\right)}{{y}^{3}}}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 9.2%

    \[\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{-2 \cdot {x}^{2}} + \frac{x}{2 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    3. unpow2N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
    4. lower-*.f6410.8

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
  5. Applied rewrites10.8%

    \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2} + \frac{x}{2 \cdot y} \]
  6. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2 + \frac{x}{2 \cdot y}} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y} + \left(x \cdot x\right) \cdot -2} \]
    3. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    4. div-invN/A

      \[\leadsto \color{blue}{x \cdot \frac{1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    5. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{x \cdot 1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    6. lift-*.f64N/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    7. *-commutativeN/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{y \cdot 2}} + \left(x \cdot x\right) \cdot -2 \]
    8. times-fracN/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    9. metadata-evalN/A

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    10. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{1}{2}, \left(x \cdot x\right) \cdot -2\right)} \]
    11. lower-/.f6410.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, 0.5, \left(x \cdot x\right) \cdot -2\right) \]
  7. Applied rewrites10.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} \]
  8. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2} + -2 \cdot \left(x \cdot x\right)} \]
    2. flip-+N/A

      \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot \frac{1}{2}\right) \cdot \left(\frac{x}{y} \cdot \frac{1}{2}\right) - \left(-2 \cdot \left(x \cdot x\right)\right) \cdot \left(-2 \cdot \left(x \cdot x\right)\right)}{\frac{x}{y} \cdot \frac{1}{2} - -2 \cdot \left(x \cdot x\right)}} \]
  9. Applied rewrites10.8%

    \[\leadsto \color{blue}{\frac{{\left(0.5 \cdot \frac{x}{y}\right)}^{2} \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) - \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot {\left(\left(x \cdot x\right) \cdot -2\right)}^{2}}{\left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)}} \]
  10. Taylor expanded in y around 0

    \[\leadsto \frac{\color{blue}{\frac{\frac{1}{8} \cdot {x}^{3} + y \cdot \left(-2 \cdot \left({x}^{5} \cdot y\right) + \frac{1}{2} \cdot {x}^{4}\right)}{{y}^{3}}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
  11. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{8} \cdot {x}^{3} + y \cdot \left(-2 \cdot \left({x}^{5} \cdot y\right) + \frac{1}{2} \cdot {x}^{4}\right)}{{y}^{3}}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    2. +-commutativeN/A

      \[\leadsto \frac{\frac{\color{blue}{y \cdot \left(-2 \cdot \left({x}^{5} \cdot y\right) + \frac{1}{2} \cdot {x}^{4}\right) + \frac{1}{8} \cdot {x}^{3}}}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\frac{\color{blue}{\left(-2 \cdot \left({x}^{5} \cdot y\right) + \frac{1}{2} \cdot {x}^{4}\right) \cdot y} + \frac{1}{8} \cdot {x}^{3}}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    4. lower-fma.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(-2 \cdot \left({x}^{5} \cdot y\right) + \frac{1}{2} \cdot {x}^{4}, y, \frac{1}{8} \cdot {x}^{3}\right)}}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    5. *-commutativeN/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\color{blue}{\left({x}^{5} \cdot y\right) \cdot -2} + \frac{1}{2} \cdot {x}^{4}, y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    6. lower-fma.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left({x}^{5} \cdot y, -2, \frac{1}{2} \cdot {x}^{4}\right)}, y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{{x}^{5} \cdot y}, -2, \frac{1}{2} \cdot {x}^{4}\right), y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    8. lower-pow.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{{x}^{5}} \cdot y, -2, \frac{1}{2} \cdot {x}^{4}\right), y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    9. *-commutativeN/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, \color{blue}{{x}^{4} \cdot \frac{1}{2}}\right), y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    10. lower-*.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, \color{blue}{{x}^{4} \cdot \frac{1}{2}}\right), y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    11. lower-pow.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, \color{blue}{{x}^{4}} \cdot \frac{1}{2}\right), y, \frac{1}{8} \cdot {x}^{3}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    12. lower-*.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot \frac{1}{2}\right), y, \color{blue}{\frac{1}{8} \cdot {x}^{3}}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    13. lower-pow.f64N/A

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot \frac{1}{2}\right), y, \frac{1}{8} \cdot \color{blue}{{x}^{3}}\right)}{{y}^{3}}}{\left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(\frac{1}{2} \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
    14. lower-pow.f6420.2

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot 0.5\right), y, 0.125 \cdot {x}^{3}\right)}{\color{blue}{{y}^{3}}}}{\left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
  12. Applied rewrites20.2%

    \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot 0.5\right), y, 0.125 \cdot {x}^{3}\right)}{{y}^{3}}}}{\left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right) \cdot \left(0.5 \cdot \frac{x}{y} - \left(x \cdot x\right) \cdot -2\right)} \]
  13. Final simplification20.2%

    \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{5} \cdot y, -2, {x}^{4} \cdot 0.5\right), y, {x}^{3} \cdot 0.125\right)}{{y}^{3}}}{\left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right) \cdot \left(-2 \cdot \left(x \cdot x\right) - \frac{x}{y} \cdot 0.5\right)} \]
  14. Add Preprocessing

Alternative 4: 10.8% accurate, 17.3× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma (/ x y) 0.5 (* -2.0 (* x x))))
double code(double x, double y) {
	return fma((x / y), 0.5, (-2.0 * (x * x)));
}
function code(x, y)
	return fma(Float64(x / y), 0.5, Float64(-2.0 * Float64(x * x)))
end
code[x_, y_] := N[(N[(x / y), $MachinePrecision] * 0.5 + N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)
\end{array}
Derivation
  1. Initial program 9.2%

    \[\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{-2 \cdot {x}^{2}} + \frac{x}{2 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{{x}^{2} \cdot -2} + \frac{x}{2 \cdot y} \]
    3. unpow2N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
    4. lower-*.f6410.8

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot -2 + \frac{x}{2 \cdot y} \]
  5. Applied rewrites10.8%

    \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2} + \frac{x}{2 \cdot y} \]
  6. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -2 + \frac{x}{2 \cdot y}} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y} + \left(x \cdot x\right) \cdot -2} \]
    3. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    4. div-invN/A

      \[\leadsto \color{blue}{x \cdot \frac{1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    5. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{x \cdot 1}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    6. lift-*.f64N/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{2 \cdot y}} + \left(x \cdot x\right) \cdot -2 \]
    7. *-commutativeN/A

      \[\leadsto \frac{x \cdot 1}{\color{blue}{y \cdot 2}} + \left(x \cdot x\right) \cdot -2 \]
    8. times-fracN/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    9. metadata-evalN/A

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{1}{2}} + \left(x \cdot x\right) \cdot -2 \]
    10. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{1}{2}, \left(x \cdot x\right) \cdot -2\right)} \]
    11. lower-/.f6410.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, 0.5, \left(x \cdot x\right) \cdot -2\right) \]
  7. Applied rewrites10.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, 0.5, -2 \cdot \left(x \cdot x\right)\right)} \]
  8. Add Preprocessing

Alternative 5: 1.6% accurate, 28.5× speedup?

\[\begin{array}{l} \\ \frac{0.5}{y} \cdot x \end{array} \]
(FPCore (x y) :precision binary64 (* (/ 0.5 y) x))
double code(double x, double y) {
	return (0.5 / y) * x;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (0.5d0 / y) * x
end function
public static double code(double x, double y) {
	return (0.5 / y) * x;
}
def code(x, y):
	return (0.5 / y) * x
function code(x, y)
	return Float64(Float64(0.5 / y) * x)
end
function tmp = code(x, y)
	tmp = (0.5 / y) * x;
end
code[x_, y_] := N[(N[(0.5 / y), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\frac{0.5}{y} \cdot x
\end{array}
Derivation
  1. Initial program 9.2%

    \[\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{y}} \]
  4. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot x}{y}} \]
    2. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{y} \cdot x} \]
    3. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot 1}}{y} \cdot x \]
    4. associate-*r/N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{y}\right)} \cdot x \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{y}\right) \cdot x} \]
    6. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot 1}{y}} \cdot x \]
    7. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{1}{2}}}{y} \cdot x \]
    8. lower-/.f641.6

      \[\leadsto \color{blue}{\frac{0.5}{y}} \cdot x \]
  5. Applied rewrites1.6%

    \[\leadsto \color{blue}{\frac{0.5}{y} \cdot x} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024249 
(FPCore (x y)
  :name "Rump's expression from Stadtherr's award speech"
  :precision binary64
  :pre (and (== x 77617.0) (== y 33096.0))
  (+ (+ (+ (* 333.75 (pow y 6.0)) (* (* x x) (- (- (- (* (* (* (* 11.0 x) x) y) y) (pow y 6.0)) (* 121.0 (pow y 4.0))) 2.0))) (* 5.5 (pow y 8.0))) (/ x (* 2.0 y))))