Rump's expression from Stadtherr's award speech

Percentage Accurate: 1.4% → 18.9%
Time: 16.8s
Alternatives: 3
Speedup: 87.8×

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 3 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: 1.4% 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: 18.9% accurate, 5.4× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_0 := -2 \cdot \left(x \cdot y\right) + -0.5\\ \frac{\frac{0.125 + \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot -8\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)}{\frac{y}{x}}}{0.015625 + \left(\left(y \cdot t\_0\right) \cdot \left(x \cdot -2\right)\right) \cdot \left(\left(x \cdot \left(x \cdot \frac{y}{\frac{0.25}{y}}\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\right)} \cdot \left(0.0625 + y \cdot \left(x \cdot -0.25 + y \cdot \left(\left(x \cdot \left(\left(x \cdot x\right) \cdot y\right)\right) \cdot 8\right)\right)\right) \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (* -2.0 (* x y)) -0.5)))
   (*
    (/
     (/ (+ 0.125 (* (* (* x (* x x)) -8.0) (* y (* y y)))) (/ y x))
     (+
      0.015625
      (*
       (* (* y t_0) (* x -2.0))
       (* (* x (* x (/ y (/ 0.25 y)))) (* t_0 t_0)))))
    (+ 0.0625 (* y (+ (* x -0.25) (* y (* (* x (* (* x x) y)) 8.0))))))))
assert(x < y);
double code(double x, double y) {
	double t_0 = (-2.0 * (x * y)) + -0.5;
	return (((0.125 + (((x * (x * x)) * -8.0) * (y * (y * y)))) / (y / x)) / (0.015625 + (((y * t_0) * (x * -2.0)) * ((x * (x * (y / (0.25 / y)))) * (t_0 * t_0))))) * (0.0625 + (y * ((x * -0.25) + (y * ((x * ((x * x) * y)) * 8.0)))));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    t_0 = ((-2.0d0) * (x * y)) + (-0.5d0)
    code = (((0.125d0 + (((x * (x * x)) * (-8.0d0)) * (y * (y * y)))) / (y / x)) / (0.015625d0 + (((y * t_0) * (x * (-2.0d0))) * ((x * (x * (y / (0.25d0 / y)))) * (t_0 * t_0))))) * (0.0625d0 + (y * ((x * (-0.25d0)) + (y * ((x * ((x * x) * y)) * 8.0d0)))))
end function
assert x < y;
public static double code(double x, double y) {
	double t_0 = (-2.0 * (x * y)) + -0.5;
	return (((0.125 + (((x * (x * x)) * -8.0) * (y * (y * y)))) / (y / x)) / (0.015625 + (((y * t_0) * (x * -2.0)) * ((x * (x * (y / (0.25 / y)))) * (t_0 * t_0))))) * (0.0625 + (y * ((x * -0.25) + (y * ((x * ((x * x) * y)) * 8.0)))));
}
[x, y] = sort([x, y])
def code(x, y):
	t_0 = (-2.0 * (x * y)) + -0.5
	return (((0.125 + (((x * (x * x)) * -8.0) * (y * (y * y)))) / (y / x)) / (0.015625 + (((y * t_0) * (x * -2.0)) * ((x * (x * (y / (0.25 / y)))) * (t_0 * t_0))))) * (0.0625 + (y * ((x * -0.25) + (y * ((x * ((x * x) * y)) * 8.0)))))
x, y = sort([x, y])
function code(x, y)
	t_0 = Float64(Float64(-2.0 * Float64(x * y)) + -0.5)
	return Float64(Float64(Float64(Float64(0.125 + Float64(Float64(Float64(x * Float64(x * x)) * -8.0) * Float64(y * Float64(y * y)))) / Float64(y / x)) / Float64(0.015625 + Float64(Float64(Float64(y * t_0) * Float64(x * -2.0)) * Float64(Float64(x * Float64(x * Float64(y / Float64(0.25 / y)))) * Float64(t_0 * t_0))))) * Float64(0.0625 + Float64(y * Float64(Float64(x * -0.25) + Float64(y * Float64(Float64(x * Float64(Float64(x * x) * y)) * 8.0))))))
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
	t_0 = (-2.0 * (x * y)) + -0.5;
	tmp = (((0.125 + (((x * (x * x)) * -8.0) * (y * (y * y)))) / (y / x)) / (0.015625 + (((y * t_0) * (x * -2.0)) * ((x * (x * (y / (0.25 / y)))) * (t_0 * t_0))))) * (0.0625 + (y * ((x * -0.25) + (y * ((x * ((x * x) * y)) * 8.0)))));
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(-2.0 * N[(x * y), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]}, N[(N[(N[(N[(0.125 + N[(N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision] * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(0.015625 + N[(N[(N[(y * t$95$0), $MachinePrecision] * N[(x * -2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(x * N[(x * N[(y / N[(0.25 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.0625 + N[(y * N[(N[(x * -0.25), $MachinePrecision] + N[(y * N[(N[(x * N[(N[(x * x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := -2 \cdot \left(x \cdot y\right) + -0.5\\
\frac{\frac{0.125 + \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot -8\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)}{\frac{y}{x}}}{0.015625 + \left(\left(y \cdot t\_0\right) \cdot \left(x \cdot -2\right)\right) \cdot \left(\left(x \cdot \left(x \cdot \frac{y}{\frac{0.25}{y}}\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\right)} \cdot \left(0.0625 + y \cdot \left(x \cdot -0.25 + y \cdot \left(\left(x \cdot \left(\left(x \cdot x\right) \cdot y\right)\right) \cdot 8\right)\right)\right)
\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. Simplified3.1%

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\left(-2 \cdot {x}^{2}\right) \cdot y + \frac{1}{2} \cdot x\right), y\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{2} \cdot x + \left(-2 \cdot {x}^{2}\right) \cdot y\right), y\right) \]
    4. *-commutativeN/A

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

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + -2 \cdot \left({x}^{2} \cdot y\right)\right), y\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left({x}^{2} \cdot y\right) \cdot -2\right), y\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left(\left(x \cdot x\right) \cdot y\right) \cdot -2\right), y\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left(x \cdot \left(x \cdot y\right)\right) \cdot -2\right), y\right) \]
    9. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + x \cdot \left(\left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    10. distribute-lft-outN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\frac{1}{2} + \left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{1}{2} + \left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    12. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot y\right) \cdot -2\right)\right)\right), y\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(y \cdot x\right) \cdot -2\right)\right)\right), y\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(y \cdot x\right), -2\right)\right)\right), y\right) \]
    15. *-lowering-*.f6410.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, x\right), -2\right)\right)\right), y\right) \]
  6. Simplified10.8%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot y\right) \cdot -2\right)\right), \left(\frac{y}{x}\right)\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(x \cdot \left(y \cdot -2\right)\right)\right), \left(\frac{y}{x}\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \left(y \cdot -2\right)\right)\right), \left(\frac{y}{x}\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, -2\right)\right)\right), \left(\frac{y}{x}\right)\right) \]
    11. /-lowering-/.f6410.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, -2\right)\right)\right), \mathsf{/.f64}\left(y, \color{blue}{x}\right)\right) \]
  8. Applied egg-rr10.8%

    \[\leadsto \color{blue}{\frac{0.5 + x \cdot \left(y \cdot -2\right)}{\frac{y}{x}}} \]
  9. Applied egg-rr10.8%

    \[\leadsto \color{blue}{\frac{\frac{0.125 + \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot -8\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)}{\frac{y}{x}}}{0.015625 + \left(\left(-2 \cdot x\right) \cdot \left(y \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right)\right) \cdot \left(\left(x \cdot \left(x \cdot \frac{y}{\frac{0.25}{y}}\right)\right) \cdot \left(\left(-2 \cdot \left(x \cdot y\right) + -0.5\right) \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right)\right)} \cdot \left(0.0625 + \left(\left(-2 \cdot x\right) \cdot \left(y \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right)\right) \cdot \left(\left(-2 \cdot x\right) \cdot \left(y \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right) - 0.25\right)\right)} \]
  10. Taylor expanded in y around 0

    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right), -8\right), \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, y\right)\right)\right)\right), \mathsf{/.f64}\left(y, x\right)\right), \mathsf{+.f64}\left(\frac{1}{64}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-2, x\right), \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{*.f64}\left(x, y\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(y, \mathsf{/.f64}\left(\frac{1}{4}, y\right)\right)\right)\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{*.f64}\left(x, y\right)\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{*.f64}\left(x, y\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{16}, \color{blue}{\left(y \cdot \left(\frac{-1}{4} \cdot x + y \cdot \left(-2 \cdot \left(x \cdot \left(\frac{-1}{2} \cdot x + \frac{1}{2} \cdot x\right)\right) + 8 \cdot \left({x}^{3} \cdot y\right)\right)\right)\right)}\right)\right) \]
  11. Simplified17.8%

    \[\leadsto \frac{\frac{0.125 + \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot -8\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)}{\frac{y}{x}}}{0.015625 + \left(\left(-2 \cdot x\right) \cdot \left(y \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right)\right) \cdot \left(\left(x \cdot \left(x \cdot \frac{y}{\frac{0.25}{y}}\right)\right) \cdot \left(\left(-2 \cdot \left(x \cdot y\right) + -0.5\right) \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right)\right)} \cdot \left(0.0625 + \color{blue}{y \cdot \left(\left(x \cdot -0.25 + 0\right) + y \cdot \left(\left(x \cdot \left(y \cdot \left(x \cdot x\right)\right)\right) \cdot 8\right)\right)}\right) \]
  12. Final simplification17.8%

    \[\leadsto \frac{\frac{0.125 + \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot -8\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)}{\frac{y}{x}}}{0.015625 + \left(\left(y \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right) \cdot \left(x \cdot -2\right)\right) \cdot \left(\left(x \cdot \left(x \cdot \frac{y}{\frac{0.25}{y}}\right)\right) \cdot \left(\left(-2 \cdot \left(x \cdot y\right) + -0.5\right) \cdot \left(-2 \cdot \left(x \cdot y\right) + -0.5\right)\right)\right)} \cdot \left(0.0625 + y \cdot \left(x \cdot -0.25 + y \cdot \left(\left(x \cdot \left(\left(x \cdot x\right) \cdot y\right)\right) \cdot 8\right)\right)\right) \]
  13. Add Preprocessing

Alternative 2: 11.0% accurate, 48.8× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ x \cdot \left(x \cdot -2 + \frac{0.5}{y}\right) \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y) :precision binary64 (* x (+ (* x -2.0) (/ 0.5 y))))
assert(x < y);
double code(double x, double y) {
	return x * ((x * -2.0) + (0.5 / y));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x * ((x * (-2.0d0)) + (0.5d0 / y))
end function
assert x < y;
public static double code(double x, double y) {
	return x * ((x * -2.0) + (0.5 / y));
}
[x, y] = sort([x, y])
def code(x, y):
	return x * ((x * -2.0) + (0.5 / y))
x, y = sort([x, y])
function code(x, y)
	return Float64(x * Float64(Float64(x * -2.0) + Float64(0.5 / y)))
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
	tmp = x * ((x * -2.0) + (0.5 / y));
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := N[(x * N[(N[(x * -2.0), $MachinePrecision] + N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x \cdot \left(x \cdot -2 + \frac{0.5}{y}\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. Simplified3.1%

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\left(-2 \cdot {x}^{2}\right) \cdot y + \frac{1}{2} \cdot x\right), y\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{2} \cdot x + \left(-2 \cdot {x}^{2}\right) \cdot y\right), y\right) \]
    4. *-commutativeN/A

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

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + -2 \cdot \left({x}^{2} \cdot y\right)\right), y\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left({x}^{2} \cdot y\right) \cdot -2\right), y\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left(\left(x \cdot x\right) \cdot y\right) \cdot -2\right), y\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left(x \cdot \left(x \cdot y\right)\right) \cdot -2\right), y\right) \]
    9. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + x \cdot \left(\left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    10. distribute-lft-outN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\frac{1}{2} + \left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{1}{2} + \left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    12. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot y\right) \cdot -2\right)\right)\right), y\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(y \cdot x\right) \cdot -2\right)\right)\right), y\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(y \cdot x\right), -2\right)\right)\right), y\right) \]
    15. *-lowering-*.f6410.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, x\right), -2\right)\right)\right), y\right) \]
  6. Simplified10.8%

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\left(x \cdot -2\right), \left(\color{blue}{\frac{1}{2}} \cdot \frac{1}{y}\right)\right)\right) \]
    4. *-lowering-*.f64N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, -2\right), \left(\frac{\frac{1}{2}}{y}\right)\right)\right) \]
    7. /-lowering-/.f6410.8%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, -2\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{y}\right)\right)\right) \]
  9. Simplified10.8%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot -2 + \frac{0.5}{y}\right)} \]
  10. Add Preprocessing

Alternative 3: 11.0% accurate, 87.8× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \left(x \cdot x\right) \cdot -2 \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y) :precision binary64 (* (* x x) -2.0))
assert(x < y);
double code(double x, double y) {
	return (x * x) * -2.0;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * x) * (-2.0d0)
end function
assert x < y;
public static double code(double x, double y) {
	return (x * x) * -2.0;
}
[x, y] = sort([x, y])
def code(x, y):
	return (x * x) * -2.0
x, y = sort([x, y])
function code(x, y)
	return Float64(Float64(x * x) * -2.0)
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
	tmp = (x * x) * -2.0;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\left(x \cdot x\right) \cdot -2
\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. Simplified3.1%

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\left(-2 \cdot {x}^{2}\right) \cdot y + \frac{1}{2} \cdot x\right), y\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{2} \cdot x + \left(-2 \cdot {x}^{2}\right) \cdot y\right), y\right) \]
    4. *-commutativeN/A

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

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + -2 \cdot \left({x}^{2} \cdot y\right)\right), y\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left({x}^{2} \cdot y\right) \cdot -2\right), y\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left(\left(x \cdot x\right) \cdot y\right) \cdot -2\right), y\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + \left(x \cdot \left(x \cdot y\right)\right) \cdot -2\right), y\right) \]
    9. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{2} + x \cdot \left(\left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    10. distribute-lft-outN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\frac{1}{2} + \left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{1}{2} + \left(x \cdot y\right) \cdot -2\right)\right), y\right) \]
    12. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot y\right) \cdot -2\right)\right)\right), y\right) \]
    13. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(y \cdot x\right) \cdot -2\right)\right)\right), y\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(y \cdot x\right), -2\right)\right)\right), y\right) \]
    15. *-lowering-*.f6410.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, x\right), -2\right)\right)\right), y\right) \]
  6. Simplified10.8%

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

    \[\leadsto \color{blue}{-2 \cdot {x}^{2}} \]
  8. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(-2, \color{blue}{\left({x}^{2}\right)}\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(-2, \left(x \cdot \color{blue}{x}\right)\right) \]
    3. *-lowering-*.f6410.8%

      \[\leadsto \mathsf{*.f64}\left(-2, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right) \]
  9. Simplified10.8%

    \[\leadsto \color{blue}{-2 \cdot \left(x \cdot x\right)} \]
  10. Final simplification10.8%

    \[\leadsto \left(x \cdot x\right) \cdot -2 \]
  11. Add Preprocessing

Reproduce

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