ab-angle->ABCF D

Percentage Accurate: 82.7% → 99.7%
Time: 12.5s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ -\left(\left(a \cdot a\right) \cdot b\right) \cdot b \end{array} \]
(FPCore (a b) :precision binary64 (- (* (* (* a a) b) b)))
double code(double a, double b) {
	return -(((a * a) * b) * b);
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -(((a * a) * b) * b)
end function
public static double code(double a, double b) {
	return -(((a * a) * b) * b);
}
def code(a, b):
	return -(((a * a) * b) * b)
function code(a, b)
	return Float64(-Float64(Float64(Float64(a * a) * b) * b))
end
function tmp = code(a, b)
	tmp = -(((a * a) * b) * b);
end
code[a_, b_] := (-N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision])
\begin{array}{l}

\\
-\left(\left(a \cdot a\right) \cdot b\right) \cdot b
\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 10 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: 82.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ -\left(\left(a \cdot a\right) \cdot b\right) \cdot b \end{array} \]
(FPCore (a b) :precision binary64 (- (* (* (* a a) b) b)))
double code(double a, double b) {
	return -(((a * a) * b) * b);
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -(((a * a) * b) * b)
end function
public static double code(double a, double b) {
	return -(((a * a) * b) * b);
}
def code(a, b):
	return -(((a * a) * b) * b)
function code(a, b)
	return Float64(-Float64(Float64(Float64(a * a) * b) * b))
end
function tmp = code(a, b)
	tmp = -(((a * a) * b) * b);
end
code[a_, b_] := (-N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision])
\begin{array}{l}

\\
-\left(\left(a \cdot a\right) \cdot b\right) \cdot b
\end{array}

Alternative 1: 99.7% accurate, 0.9× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right) \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (* (/ a (/ -1.0 b)) (* a b)))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return (a / (-1.0 / b)) * (a * b);
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (a / ((-1.0d0) / b)) * (a * b)
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return (a / (-1.0 / b)) * (a * b);
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return (a / (-1.0 / b)) * (a * b)
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return Float64(Float64(a / Float64(-1.0 / b)) * Float64(a * b))
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = (a / (-1.0 / b)) * (a * b);
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := N[(N[(a / N[(-1.0 / b), $MachinePrecision]), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right)
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. distribute-rgt-neg-in81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
    2. associate-*l*92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
  3. Simplified92.7%

    \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6452.9%

      \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right) \cdot \left(-b\right)} \]
  5. Applied rewrite-once52.9%

    \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right)} \cdot \left(-b\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    2. associate-*r*81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot \left(-b\right) \]
    3. associate-*l*73.0%

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)} \]
    4. /-rgt-identity73.0%

      \[\leadsto \color{blue}{\frac{a \cdot a}{1}} \cdot \left(b \cdot \left(-b\right)\right) \]
    5. associate-/l*73.0%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{a}}} \cdot \left(b \cdot \left(-b\right)\right) \]
    6. associate-*l/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  7. Applied egg-rr79.5%

    \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  8. Step-by-step derivation
    1. associate-/l*79.5%

      \[\leadsto \color{blue}{\frac{a}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    2. div-inv79.5%

      \[\leadsto \color{blue}{a \cdot \frac{1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    3. associate-*r/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot 1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    4. div-inv79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{\color{blue}{1 \cdot \frac{1}{a}}}{b \cdot \left(-b\right)}} \]
    5. *-commutative79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{1 \cdot \frac{1}{a}}{\color{blue}{\left(-b\right) \cdot b}}} \]
    6. times-frac91.9%

      \[\leadsto \frac{a \cdot 1}{\color{blue}{\frac{1}{-b} \cdot \frac{\frac{1}{a}}{b}}} \]
    7. times-frac99.6%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{-b}} \cdot \frac{1}{\frac{\frac{1}{a}}{b}}} \]
    8. associate-/r*99.6%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot b}}} \]
    9. clear-num99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\frac{a \cdot b}{1}} \]
    10. /-rgt-identity99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\left(a \cdot b\right)} \]
    11. neg-mul-199.7%

      \[\leadsto \frac{a}{\frac{1}{\color{blue}{-1 \cdot b}}} \cdot \left(a \cdot b\right) \]
    12. associate-/r*99.7%

      \[\leadsto \frac{a}{\color{blue}{\frac{\frac{1}{-1}}{b}}} \cdot \left(a \cdot b\right) \]
    13. metadata-eval99.7%

      \[\leadsto \frac{a}{\frac{\color{blue}{-1}}{b}} \cdot \left(a \cdot b\right) \]
  9. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right)} \]
  10. Final simplification99.7%

    \[\leadsto \frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right) \]

Alternative 2: 86.7% accurate, 0.8× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(b \cdot \left(a \cdot \left(-a\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
 :precision binary64
 (if (<= b 1.35e+154) (* a (* a (- (* b b)))) (* b (* b (* a (- a))))))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (b <= 1.35e+154) {
		tmp = a * (a * -(b * b));
	} else {
		tmp = b * (b * (a * -a));
	}
	return tmp;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 1.35d+154) then
        tmp = a * (a * -(b * b))
    else
        tmp = b * (b * (a * -a))
    end if
    code = tmp
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (b <= 1.35e+154) {
		tmp = a * (a * -(b * b));
	} else {
		tmp = b * (b * (a * -a));
	}
	return tmp;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if b <= 1.35e+154:
		tmp = a * (a * -(b * b))
	else:
		tmp = b * (b * (a * -a))
	return tmp
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (b <= 1.35e+154)
		tmp = Float64(a * Float64(a * Float64(-Float64(b * b))));
	else
		tmp = Float64(b * Float64(b * Float64(a * Float64(-a))));
	end
	return tmp
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 1.35e+154)
		tmp = a * (a * -(b * b));
	else
		tmp = b * (b * (a * -a));
	end
	tmp_2 = tmp;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[b, 1.35e+154], N[(a * N[(a * (-N[(b * b), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(b * N[(b * N[(a * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;a \cdot \left(a \cdot \left(-b \cdot b\right)\right)\\

\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(a \cdot \left(-a\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.35000000000000003e154

    1. Initial program 82.8%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
    2. Step-by-step derivation
      1. associate-*l*76.9%

        \[\leadsto -\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)} \]
      2. distribute-rgt-neg-in76.9%

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(-b \cdot b\right)} \]
      3. associate-*r*84.4%

        \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b \cdot b\right)\right)} \]
    3. Simplified84.4%

      \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b \cdot b\right)\right)} \]

    if 1.35000000000000003e154 < b

    1. Initial program 71.2%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(b \cdot \left(a \cdot \left(-a\right)\right)\right)\\ \end{array} \]

Alternative 3: 93.4% accurate, 0.8× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(\left(a \cdot b\right) \cdot \left(-a\right)\right)\\ \end{array} \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
 :precision binary64
 (if (<= b 1.35e+154) (* a (* a (- (* b b)))) (* b (* (* a b) (- a)))))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (b <= 1.35e+154) {
		tmp = a * (a * -(b * b));
	} else {
		tmp = b * ((a * b) * -a);
	}
	return tmp;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 1.35d+154) then
        tmp = a * (a * -(b * b))
    else
        tmp = b * ((a * b) * -a)
    end if
    code = tmp
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (b <= 1.35e+154) {
		tmp = a * (a * -(b * b));
	} else {
		tmp = b * ((a * b) * -a);
	}
	return tmp;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if b <= 1.35e+154:
		tmp = a * (a * -(b * b))
	else:
		tmp = b * ((a * b) * -a)
	return tmp
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (b <= 1.35e+154)
		tmp = Float64(a * Float64(a * Float64(-Float64(b * b))));
	else
		tmp = Float64(b * Float64(Float64(a * b) * Float64(-a)));
	end
	return tmp
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 1.35e+154)
		tmp = a * (a * -(b * b));
	else
		tmp = b * ((a * b) * -a);
	end
	tmp_2 = tmp;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[b, 1.35e+154], N[(a * N[(a * (-N[(b * b), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(a * b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;a \cdot \left(a \cdot \left(-b \cdot b\right)\right)\\

\mathbf{else}:\\
\;\;\;\;b \cdot \left(\left(a \cdot b\right) \cdot \left(-a\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.35000000000000003e154

    1. Initial program 82.8%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
    2. Step-by-step derivation
      1. associate-*l*76.9%

        \[\leadsto -\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)} \]
      2. distribute-rgt-neg-in76.9%

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(-b \cdot b\right)} \]
      3. associate-*r*84.4%

        \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b \cdot b\right)\right)} \]
    3. Simplified84.4%

      \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b \cdot b\right)\right)} \]

    if 1.35000000000000003e154 < b

    1. Initial program 71.2%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
    2. Step-by-step derivation
      1. distribute-rgt-neg-in71.2%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
      2. associate-*l*92.0%

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    3. Simplified92.0%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(\left(a \cdot b\right) \cdot \left(-a\right)\right)\\ \end{array} \]

Alternative 4: 82.7% accurate, 1.0× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ b \cdot \left(b \cdot \left(a \cdot \left(-a\right)\right)\right) \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (* b (* b (* a (- a)))))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return b * (b * (a * -a));
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = b * (b * (a * -a))
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return b * (b * (a * -a));
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return b * (b * (a * -a))
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return Float64(b * Float64(b * Float64(a * Float64(-a))))
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = b * (b * (a * -a));
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := N[(b * N[(b * N[(a * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
b \cdot \left(b \cdot \left(a \cdot \left(-a\right)\right)\right)
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Final simplification81.1%

    \[\leadsto b \cdot \left(b \cdot \left(a \cdot \left(-a\right)\right)\right) \]

Alternative 5: 99.7% accurate, 1.0× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ -\left(a \cdot b\right) \cdot \left(a \cdot b\right) \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (- (* (* a b) (* a b))))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return -((a * b) * (a * b));
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -((a * b) * (a * b))
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return -((a * b) * (a * b));
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return -((a * b) * (a * b))
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return Float64(-Float64(Float64(a * b) * Float64(a * b)))
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = -((a * b) * (a * b));
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := (-N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision])
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
-\left(a \cdot b\right) \cdot \left(a \cdot b\right)
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. distribute-rgt-neg-in81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
    2. associate-*l*92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
  3. Simplified92.7%

    \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6452.9%

      \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right) \cdot \left(-b\right)} \]
  5. Applied rewrite-once52.9%

    \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right)} \cdot \left(-b\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    2. associate-*r*81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot \left(-b\right) \]
    3. associate-*l*73.0%

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)} \]
    4. /-rgt-identity73.0%

      \[\leadsto \color{blue}{\frac{a \cdot a}{1}} \cdot \left(b \cdot \left(-b\right)\right) \]
    5. associate-/l*73.0%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{a}}} \cdot \left(b \cdot \left(-b\right)\right) \]
    6. associate-*l/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  7. Applied egg-rr79.5%

    \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  8. Step-by-step derivation
    1. clear-num79.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{a}}{a \cdot \left(b \cdot \left(-b\right)\right)}}} \]
    2. associate-/r/79.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{a}} \cdot \left(a \cdot \left(b \cdot \left(-b\right)\right)\right)} \]
    3. remove-double-div79.5%

      \[\leadsto \color{blue}{a} \cdot \left(a \cdot \left(b \cdot \left(-b\right)\right)\right) \]
    4. distribute-rgt-neg-out79.5%

      \[\leadsto a \cdot \left(a \cdot \color{blue}{\left(-b \cdot b\right)}\right) \]
    5. distribute-rgt-neg-out79.5%

      \[\leadsto a \cdot \color{blue}{\left(-a \cdot \left(b \cdot b\right)\right)} \]
    6. distribute-lft-neg-out79.5%

      \[\leadsto a \cdot \color{blue}{\left(\left(-a\right) \cdot \left(b \cdot b\right)\right)} \]
    7. associate-*l*73.0%

      \[\leadsto \color{blue}{\left(a \cdot \left(-a\right)\right) \cdot \left(b \cdot b\right)} \]
    8. associate-*r*81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot \left(-a\right)\right) \cdot b\right) \cdot b} \]
    9. *-commutative81.1%

      \[\leadsto \color{blue}{b \cdot \left(\left(a \cdot \left(-a\right)\right) \cdot b\right)} \]
    10. *-commutative81.1%

      \[\leadsto b \cdot \left(\color{blue}{\left(\left(-a\right) \cdot a\right)} \cdot b\right) \]
    11. associate-*l*92.7%

      \[\leadsto b \cdot \color{blue}{\left(\left(-a\right) \cdot \left(a \cdot b\right)\right)} \]
    12. associate-*r*99.7%

      \[\leadsto \color{blue}{\left(b \cdot \left(-a\right)\right) \cdot \left(a \cdot b\right)} \]
  9. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\left(b \cdot \left(-a\right)\right) \cdot \left(a \cdot b\right)} \]
  10. Final simplification99.7%

    \[\leadsto -\left(a \cdot b\right) \cdot \left(a \cdot b\right) \]

Alternative 6: 40.3% accurate, 1.3× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 8 \cdot 10^{-7}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(-a\right)\\ \end{array} \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (if (<= b 8e-7) 0.0 (* a (- a))))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (b <= 8e-7) {
		tmp = 0.0;
	} else {
		tmp = a * -a;
	}
	return tmp;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 8d-7) then
        tmp = 0.0d0
    else
        tmp = a * -a
    end if
    code = tmp
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (b <= 8e-7) {
		tmp = 0.0;
	} else {
		tmp = a * -a;
	}
	return tmp;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if b <= 8e-7:
		tmp = 0.0
	else:
		tmp = a * -a
	return tmp
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (b <= 8e-7)
		tmp = 0.0;
	else
		tmp = Float64(a * Float64(-a));
	end
	return tmp
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 8e-7)
		tmp = 0.0;
	else
		tmp = a * -a;
	end
	tmp_2 = tmp;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[b, 8e-7], 0.0, N[(a * (-a)), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-7}:\\
\;\;\;\;0\\

\mathbf{else}:\\
\;\;\;\;a \cdot \left(-a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 7.9999999999999996e-7

    1. Initial program 82.1%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
    2. Step-by-step derivation
      1. distribute-rgt-neg-in82.1%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
      2. associate-*l*92.9%

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    3. Simplified92.9%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt_binary6440.4%

        \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right) \cdot \left(-b\right)} \]
    5. Applied rewrite-once40.4%

      \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right)} \cdot \left(-b\right) \]
    6. Step-by-step derivation
      1. rem-square-sqrt92.9%

        \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
      2. associate-*r*82.1%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot \left(-b\right) \]
      3. associate-*l*75.4%

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)} \]
      4. /-rgt-identity75.4%

        \[\leadsto \color{blue}{\frac{a \cdot a}{1}} \cdot \left(b \cdot \left(-b\right)\right) \]
      5. associate-/l*75.4%

        \[\leadsto \color{blue}{\frac{a}{\frac{1}{a}}} \cdot \left(b \cdot \left(-b\right)\right) \]
      6. associate-*l/82.3%

        \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
    7. Applied egg-rr82.3%

      \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
    8. Step-by-step derivation
      1. associate-/l*82.4%

        \[\leadsto \color{blue}{\frac{a}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
      2. div-inv82.3%

        \[\leadsto \color{blue}{a \cdot \frac{1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
      3. associate-*r/82.4%

        \[\leadsto \color{blue}{\frac{a \cdot 1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
      4. div-inv82.4%

        \[\leadsto \frac{a \cdot 1}{\frac{\color{blue}{1 \cdot \frac{1}{a}}}{b \cdot \left(-b\right)}} \]
      5. *-commutative82.4%

        \[\leadsto \frac{a \cdot 1}{\frac{1 \cdot \frac{1}{a}}{\color{blue}{\left(-b\right) \cdot b}}} \]
      6. times-frac91.9%

        \[\leadsto \frac{a \cdot 1}{\color{blue}{\frac{1}{-b} \cdot \frac{\frac{1}{a}}{b}}} \]
      7. times-frac99.6%

        \[\leadsto \color{blue}{\frac{a}{\frac{1}{-b}} \cdot \frac{1}{\frac{\frac{1}{a}}{b}}} \]
      8. associate-/r*99.7%

        \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot b}}} \]
      9. clear-num99.7%

        \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\frac{a \cdot b}{1}} \]
      10. /-rgt-identity99.7%

        \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\left(a \cdot b\right)} \]
      11. neg-mul-199.7%

        \[\leadsto \frac{a}{\frac{1}{\color{blue}{-1 \cdot b}}} \cdot \left(a \cdot b\right) \]
      12. associate-/r*99.7%

        \[\leadsto \frac{a}{\color{blue}{\frac{\frac{1}{-1}}{b}}} \cdot \left(a \cdot b\right) \]
      13. metadata-eval99.7%

        \[\leadsto \frac{a}{\frac{\color{blue}{-1}}{b}} \cdot \left(a \cdot b\right) \]
    9. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right)} \]
    10. Applied egg-rr39.0%

      \[\leadsto \color{blue}{0} \]

    if 7.9999999999999996e-7 < b

    1. Initial program 78.2%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
    2. Step-by-step derivation
      1. associate-*l*65.5%

        \[\leadsto -\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)} \]
      2. distribute-rgt-neg-in65.5%

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(-b \cdot b\right)} \]
      3. associate-*r*70.6%

        \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b \cdot b\right)\right)} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b \cdot b\right)\right)} \]
    4. Applied egg-rr34.9%

      \[\leadsto a \cdot \color{blue}{\left(\left(-a\right) + 0\right)} \]
    5. Step-by-step derivation
      1. +-rgt-identity34.9%

        \[\leadsto a \cdot \color{blue}{\left(-a\right)} \]
    6. Simplified34.9%

      \[\leadsto a \cdot \color{blue}{\left(-a\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification38.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 8 \cdot 10^{-7}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(-a\right)\\ \end{array} \]

Alternative 7: 47.1% accurate, 1.3× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \left(a \cdot b\right) \cdot \left(-a\right) \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (* (* a b) (- a)))
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return (a * b) * -a;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (a * b) * -a
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return (a * b) * -a;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return (a * b) * -a
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return Float64(Float64(a * b) * Float64(-a))
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = (a * b) * -a;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := N[(N[(a * b), $MachinePrecision] * (-a)), $MachinePrecision]
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(a \cdot b\right) \cdot \left(-a\right)
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. distribute-rgt-neg-in81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
    2. associate-*l*92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
  3. Simplified92.7%

    \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  4. Applied egg-rr31.6%

    \[\leadsto \color{blue}{\left(a \cdot a + 0\right)} \cdot \left(-b\right) \]
  5. Step-by-step derivation
    1. +-rgt-identity31.6%

      \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(-b\right) \]
  6. Simplified31.6%

    \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(-b\right) \]
  7. Taylor expanded in a around 0 31.6%

    \[\leadsto \color{blue}{-1 \cdot \left({a}^{2} \cdot b\right)} \]
  8. Step-by-step derivation
    1. mul-1-neg31.6%

      \[\leadsto \color{blue}{-{a}^{2} \cdot b} \]
    2. unpow231.6%

      \[\leadsto -\color{blue}{\left(a \cdot a\right)} \cdot b \]
    3. distribute-rgt-neg-out31.6%

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(-b\right)} \]
    4. associate-*l*31.6%

      \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b\right)\right)} \]
  9. Simplified31.6%

    \[\leadsto \color{blue}{a \cdot \left(a \cdot \left(-b\right)\right)} \]
  10. Final simplification31.6%

    \[\leadsto \left(a \cdot b\right) \cdot \left(-a\right) \]

Alternative 8: 4.2% accurate, 8.0× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ -9 \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 -9.0)
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return -9.0;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -9.0d0
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return -9.0;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return -9.0
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return -9.0
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = -9.0;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := -9.0
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
-9
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. distribute-rgt-neg-in81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
    2. associate-*l*92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
  3. Simplified92.7%

    \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6452.9%

      \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right) \cdot \left(-b\right)} \]
  5. Applied rewrite-once52.9%

    \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right)} \cdot \left(-b\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    2. associate-*r*81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot \left(-b\right) \]
    3. associate-*l*73.0%

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)} \]
    4. /-rgt-identity73.0%

      \[\leadsto \color{blue}{\frac{a \cdot a}{1}} \cdot \left(b \cdot \left(-b\right)\right) \]
    5. associate-/l*73.0%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{a}}} \cdot \left(b \cdot \left(-b\right)\right) \]
    6. associate-*l/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  7. Applied egg-rr79.5%

    \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  8. Step-by-step derivation
    1. associate-/l*79.5%

      \[\leadsto \color{blue}{\frac{a}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    2. div-inv79.5%

      \[\leadsto \color{blue}{a \cdot \frac{1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    3. associate-*r/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot 1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    4. div-inv79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{\color{blue}{1 \cdot \frac{1}{a}}}{b \cdot \left(-b\right)}} \]
    5. *-commutative79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{1 \cdot \frac{1}{a}}{\color{blue}{\left(-b\right) \cdot b}}} \]
    6. times-frac91.9%

      \[\leadsto \frac{a \cdot 1}{\color{blue}{\frac{1}{-b} \cdot \frac{\frac{1}{a}}{b}}} \]
    7. times-frac99.6%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{-b}} \cdot \frac{1}{\frac{\frac{1}{a}}{b}}} \]
    8. associate-/r*99.6%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot b}}} \]
    9. clear-num99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\frac{a \cdot b}{1}} \]
    10. /-rgt-identity99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\left(a \cdot b\right)} \]
    11. neg-mul-199.7%

      \[\leadsto \frac{a}{\frac{1}{\color{blue}{-1 \cdot b}}} \cdot \left(a \cdot b\right) \]
    12. associate-/r*99.7%

      \[\leadsto \frac{a}{\color{blue}{\frac{\frac{1}{-1}}{b}}} \cdot \left(a \cdot b\right) \]
    13. metadata-eval99.7%

      \[\leadsto \frac{a}{\frac{\color{blue}{-1}}{b}} \cdot \left(a \cdot b\right) \]
  9. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right)} \]
  10. Applied egg-rr4.0%

    \[\leadsto \color{blue}{-9} \]
  11. Final simplification4.0%

    \[\leadsto -9 \]

Alternative 9: 4.2% accurate, 8.0× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ -0.125 \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 -0.125)
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return -0.125;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -0.125d0
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return -0.125;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return -0.125
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return -0.125
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = -0.125;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := -0.125
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
-0.125
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. distribute-rgt-neg-in81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
    2. associate-*l*92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
  3. Simplified92.7%

    \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6452.9%

      \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right) \cdot \left(-b\right)} \]
  5. Applied rewrite-once52.9%

    \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right)} \cdot \left(-b\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    2. associate-*r*81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot \left(-b\right) \]
    3. associate-*l*73.0%

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)} \]
    4. /-rgt-identity73.0%

      \[\leadsto \color{blue}{\frac{a \cdot a}{1}} \cdot \left(b \cdot \left(-b\right)\right) \]
    5. associate-/l*73.0%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{a}}} \cdot \left(b \cdot \left(-b\right)\right) \]
    6. associate-*l/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  7. Applied egg-rr79.5%

    \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  8. Step-by-step derivation
    1. associate-/l*79.5%

      \[\leadsto \color{blue}{\frac{a}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    2. div-inv79.5%

      \[\leadsto \color{blue}{a \cdot \frac{1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    3. associate-*r/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot 1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    4. div-inv79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{\color{blue}{1 \cdot \frac{1}{a}}}{b \cdot \left(-b\right)}} \]
    5. *-commutative79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{1 \cdot \frac{1}{a}}{\color{blue}{\left(-b\right) \cdot b}}} \]
    6. times-frac91.9%

      \[\leadsto \frac{a \cdot 1}{\color{blue}{\frac{1}{-b} \cdot \frac{\frac{1}{a}}{b}}} \]
    7. times-frac99.6%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{-b}} \cdot \frac{1}{\frac{\frac{1}{a}}{b}}} \]
    8. associate-/r*99.6%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot b}}} \]
    9. clear-num99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\frac{a \cdot b}{1}} \]
    10. /-rgt-identity99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\left(a \cdot b\right)} \]
    11. neg-mul-199.7%

      \[\leadsto \frac{a}{\frac{1}{\color{blue}{-1 \cdot b}}} \cdot \left(a \cdot b\right) \]
    12. associate-/r*99.7%

      \[\leadsto \frac{a}{\color{blue}{\frac{\frac{1}{-1}}{b}}} \cdot \left(a \cdot b\right) \]
    13. metadata-eval99.7%

      \[\leadsto \frac{a}{\frac{\color{blue}{-1}}{b}} \cdot \left(a \cdot b\right) \]
  9. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right)} \]
  10. Applied egg-rr4.0%

    \[\leadsto \color{blue}{-0.125} \]
  11. Final simplification4.0%

    \[\leadsto -0.125 \]

Alternative 10: 29.4% accurate, 8.0× speedup?

\[\begin{array}{l} a = |a|\\ [a, b] = \mathsf{sort}([a, b])\\ \\ 0 \end{array} \]
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 0.0)
a = abs(a);
assert(a < b);
double code(double a, double b) {
	return 0.0;
}
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = 0.0d0
end function
a = Math.abs(a);
assert a < b;
public static double code(double a, double b) {
	return 0.0;
}
a = abs(a)
[a, b] = sort([a, b])
def code(a, b):
	return 0.0
a = abs(a)
a, b = sort([a, b])
function code(a, b)
	return 0.0
end
a = abs(a)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = 0.0;
end
NOTE: a should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := 0.0
\begin{array}{l}
a = |a|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
0
\end{array}
Derivation
  1. Initial program 81.1%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. distribute-rgt-neg-in81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)} \]
    2. associate-*l*92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
  3. Simplified92.7%

    \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6452.9%

      \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right) \cdot \left(-b\right)} \]
  5. Applied rewrite-once52.9%

    \[\leadsto \color{blue}{\left(\sqrt{a \cdot \left(a \cdot b\right)} \cdot \sqrt{a \cdot \left(a \cdot b\right)}\right)} \cdot \left(-b\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt92.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot \left(-b\right) \]
    2. associate-*r*81.1%

      \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot \left(-b\right) \]
    3. associate-*l*73.0%

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)} \]
    4. /-rgt-identity73.0%

      \[\leadsto \color{blue}{\frac{a \cdot a}{1}} \cdot \left(b \cdot \left(-b\right)\right) \]
    5. associate-/l*73.0%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{a}}} \cdot \left(b \cdot \left(-b\right)\right) \]
    6. associate-*l/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  7. Applied egg-rr79.5%

    \[\leadsto \color{blue}{\frac{a \cdot \left(b \cdot \left(-b\right)\right)}{\frac{1}{a}}} \]
  8. Step-by-step derivation
    1. associate-/l*79.5%

      \[\leadsto \color{blue}{\frac{a}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    2. div-inv79.5%

      \[\leadsto \color{blue}{a \cdot \frac{1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    3. associate-*r/79.5%

      \[\leadsto \color{blue}{\frac{a \cdot 1}{\frac{\frac{1}{a}}{b \cdot \left(-b\right)}}} \]
    4. div-inv79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{\color{blue}{1 \cdot \frac{1}{a}}}{b \cdot \left(-b\right)}} \]
    5. *-commutative79.5%

      \[\leadsto \frac{a \cdot 1}{\frac{1 \cdot \frac{1}{a}}{\color{blue}{\left(-b\right) \cdot b}}} \]
    6. times-frac91.9%

      \[\leadsto \frac{a \cdot 1}{\color{blue}{\frac{1}{-b} \cdot \frac{\frac{1}{a}}{b}}} \]
    7. times-frac99.6%

      \[\leadsto \color{blue}{\frac{a}{\frac{1}{-b}} \cdot \frac{1}{\frac{\frac{1}{a}}{b}}} \]
    8. associate-/r*99.6%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \frac{1}{\color{blue}{\frac{1}{a \cdot b}}} \]
    9. clear-num99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\frac{a \cdot b}{1}} \]
    10. /-rgt-identity99.7%

      \[\leadsto \frac{a}{\frac{1}{-b}} \cdot \color{blue}{\left(a \cdot b\right)} \]
    11. neg-mul-199.7%

      \[\leadsto \frac{a}{\frac{1}{\color{blue}{-1 \cdot b}}} \cdot \left(a \cdot b\right) \]
    12. associate-/r*99.7%

      \[\leadsto \frac{a}{\color{blue}{\frac{\frac{1}{-1}}{b}}} \cdot \left(a \cdot b\right) \]
    13. metadata-eval99.7%

      \[\leadsto \frac{a}{\frac{\color{blue}{-1}}{b}} \cdot \left(a \cdot b\right) \]
  9. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{a}{\frac{-1}{b}} \cdot \left(a \cdot b\right)} \]
  10. Applied egg-rr33.2%

    \[\leadsto \color{blue}{0} \]
  11. Final simplification33.2%

    \[\leadsto 0 \]

Reproduce

?
herbie shell --seed 2023297 
(FPCore (a b)
  :name "ab-angle->ABCF D"
  :precision binary64
  (- (* (* (* a a) b) b)))