ab-angle->ABCF D

Percentage Accurate: 81.9% → 99.7%
Time: 1.2s
Alternatives: 3
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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    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}

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: 81.9% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    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.7× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ b_m = \left|b\right| \\ [a_m, b_m] = \mathsf{sort}([a_m, b_m])\\ \\ \begin{array}{l} \mathbf{if}\;a\_m \leq 3.35 \cdot 10^{-155}:\\ \;\;\;\;\left(-a\_m\right) \cdot \left(\left(b\_m \cdot a\_m\right) \cdot b\_m\right)\\ \mathbf{else}:\\ \;\;\;\;-\left(\left(a\_m \cdot a\_m\right) \cdot b\_m\right) \cdot b\_m\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
b_m = (fabs.f64 b)
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
(FPCore (a_m b_m)
 :precision binary64
 (if (<= a_m 3.35e-155)
   (* (- a_m) (* (* b_m a_m) b_m))
   (- (* (* (* a_m a_m) b_m) b_m))))
a_m = fabs(a);
b_m = fabs(b);
assert(a_m < b_m);
double code(double a_m, double b_m) {
	double tmp;
	if (a_m <= 3.35e-155) {
		tmp = -a_m * ((b_m * a_m) * b_m);
	} else {
		tmp = -(((a_m * a_m) * b_m) * b_m);
	}
	return tmp;
}
a_m =     private
b_m =     private
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a_m, b_m)
use fmin_fmax_functions
    real(8), intent (in) :: a_m
    real(8), intent (in) :: b_m
    real(8) :: tmp
    if (a_m <= 3.35d-155) then
        tmp = -a_m * ((b_m * a_m) * b_m)
    else
        tmp = -(((a_m * a_m) * b_m) * b_m)
    end if
    code = tmp
end function
a_m = Math.abs(a);
b_m = Math.abs(b);
assert a_m < b_m;
public static double code(double a_m, double b_m) {
	double tmp;
	if (a_m <= 3.35e-155) {
		tmp = -a_m * ((b_m * a_m) * b_m);
	} else {
		tmp = -(((a_m * a_m) * b_m) * b_m);
	}
	return tmp;
}
a_m = math.fabs(a)
b_m = math.fabs(b)
[a_m, b_m] = sort([a_m, b_m])
def code(a_m, b_m):
	tmp = 0
	if a_m <= 3.35e-155:
		tmp = -a_m * ((b_m * a_m) * b_m)
	else:
		tmp = -(((a_m * a_m) * b_m) * b_m)
	return tmp
a_m = abs(a)
b_m = abs(b)
a_m, b_m = sort([a_m, b_m])
function code(a_m, b_m)
	tmp = 0.0
	if (a_m <= 3.35e-155)
		tmp = Float64(Float64(-a_m) * Float64(Float64(b_m * a_m) * b_m));
	else
		tmp = Float64(-Float64(Float64(Float64(a_m * a_m) * b_m) * b_m));
	end
	return tmp
end
a_m = abs(a);
b_m = abs(b);
a_m, b_m = num2cell(sort([a_m, b_m])){:}
function tmp_2 = code(a_m, b_m)
	tmp = 0.0;
	if (a_m <= 3.35e-155)
		tmp = -a_m * ((b_m * a_m) * b_m);
	else
		tmp = -(((a_m * a_m) * b_m) * b_m);
	end
	tmp_2 = tmp;
end
a_m = N[Abs[a], $MachinePrecision]
b_m = N[Abs[b], $MachinePrecision]
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
code[a$95$m_, b$95$m_] := If[LessEqual[a$95$m, 3.35e-155], N[((-a$95$m) * N[(N[(b$95$m * a$95$m), $MachinePrecision] * b$95$m), $MachinePrecision]), $MachinePrecision], (-N[(N[(N[(a$95$m * a$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision])]
\begin{array}{l}
a_m = \left|a\right|
\\
b_m = \left|b\right|
\\
[a_m, b_m] = \mathsf{sort}([a_m, b_m])\\
\\
\begin{array}{l}
\mathbf{if}\;a\_m \leq 3.35 \cdot 10^{-155}:\\
\;\;\;\;\left(-a\_m\right) \cdot \left(\left(b\_m \cdot a\_m\right) \cdot b\_m\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 3.35000000000000014e-155

    1. Initial program 81.9%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\left(\left(a \cdot a\right) \cdot b\right) \cdot b\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot b}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot b\right) \]
      4. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\left(\color{blue}{\left(a \cdot a\right)} \cdot b\right) \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(a \cdot \left(a \cdot b\right)\right)} \cdot b\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{a \cdot \left(\left(a \cdot b\right) \cdot b\right)}\right) \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\left(a \cdot b\right) \cdot b\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\left(a \cdot b\right) \cdot b\right)} \]
      9. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-a\right)} \cdot \left(\left(a \cdot b\right) \cdot b\right) \]
      10. lower-*.f64N/A

        \[\leadsto \left(-a\right) \cdot \color{blue}{\left(\left(a \cdot b\right) \cdot b\right)} \]
      11. *-commutativeN/A

        \[\leadsto \left(-a\right) \cdot \left(\color{blue}{\left(b \cdot a\right)} \cdot b\right) \]
      12. lower-*.f6494.1

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

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

    if 3.35000000000000014e-155 < a

    1. Initial program 81.9%

      \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.8% accurate, 1.0× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ b_m = \left|b\right| \\ [a_m, b_m] = \mathsf{sort}([a_m, b_m])\\ \\ \left(\left(-b\_m\right) \cdot a\_m\right) \cdot \left(b\_m \cdot a\_m\right) \end{array} \]
a_m = (fabs.f64 a)
b_m = (fabs.f64 b)
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
(FPCore (a_m b_m) :precision binary64 (* (* (- b_m) a_m) (* b_m a_m)))
a_m = fabs(a);
b_m = fabs(b);
assert(a_m < b_m);
double code(double a_m, double b_m) {
	return (-b_m * a_m) * (b_m * a_m);
}
a_m =     private
b_m =     private
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a_m, b_m)
use fmin_fmax_functions
    real(8), intent (in) :: a_m
    real(8), intent (in) :: b_m
    code = (-b_m * a_m) * (b_m * a_m)
end function
a_m = Math.abs(a);
b_m = Math.abs(b);
assert a_m < b_m;
public static double code(double a_m, double b_m) {
	return (-b_m * a_m) * (b_m * a_m);
}
a_m = math.fabs(a)
b_m = math.fabs(b)
[a_m, b_m] = sort([a_m, b_m])
def code(a_m, b_m):
	return (-b_m * a_m) * (b_m * a_m)
a_m = abs(a)
b_m = abs(b)
a_m, b_m = sort([a_m, b_m])
function code(a_m, b_m)
	return Float64(Float64(Float64(-b_m) * a_m) * Float64(b_m * a_m))
end
a_m = abs(a);
b_m = abs(b);
a_m, b_m = num2cell(sort([a_m, b_m])){:}
function tmp = code(a_m, b_m)
	tmp = (-b_m * a_m) * (b_m * a_m);
end
a_m = N[Abs[a], $MachinePrecision]
b_m = N[Abs[b], $MachinePrecision]
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
code[a$95$m_, b$95$m_] := N[(N[((-b$95$m) * a$95$m), $MachinePrecision] * N[(b$95$m * a$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
b_m = \left|b\right|
\\
[a_m, b_m] = \mathsf{sort}([a_m, b_m])\\
\\
\left(\left(-b\_m\right) \cdot a\_m\right) \cdot \left(b\_m \cdot a\_m\right)
\end{array}
Derivation
  1. Initial program 81.9%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\left(\left(a \cdot a\right) \cdot b\right) \cdot b\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(a \cdot a\right) \cdot b\right) \cdot b}\right) \]
    3. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(a \cdot a\right) \cdot b\right)} \cdot b\right) \]
    4. associate-*l*N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}\right) \]
    5. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(a \cdot a\right)} \cdot \left(b \cdot b\right)\right) \]
    6. unswap-sqrN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}\right) \]
    7. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)} \]
    8. *-commutativeN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{b \cdot a}\right)\right) \cdot \left(a \cdot b\right) \]
    9. distribute-rgt-neg-outN/A

      \[\leadsto \color{blue}{\left(b \cdot \left(\mathsf{neg}\left(a\right)\right)\right)} \cdot \left(a \cdot b\right) \]
    10. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(b \cdot \left(\mathsf{neg}\left(a\right)\right)\right) \cdot \left(a \cdot b\right)} \]
    11. distribute-rgt-neg-outN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(b \cdot a\right)\right)} \cdot \left(a \cdot b\right) \]
    12. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(b\right)\right) \cdot a\right)} \cdot \left(a \cdot b\right) \]
    13. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(b\right)\right) \cdot a\right)} \cdot \left(a \cdot b\right) \]
    14. lower-neg.f64N/A

      \[\leadsto \left(\color{blue}{\left(-b\right)} \cdot a\right) \cdot \left(a \cdot b\right) \]
    15. *-commutativeN/A

      \[\leadsto \left(\left(-b\right) \cdot a\right) \cdot \color{blue}{\left(b \cdot a\right)} \]
    16. lower-*.f6499.7

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

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

Alternative 3: 81.9% accurate, 1.0× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ b_m = \left|b\right| \\ [a_m, b_m] = \mathsf{sort}([a_m, b_m])\\ \\ -\left(\left(a\_m \cdot a\_m\right) \cdot b\_m\right) \cdot b\_m \end{array} \]
a_m = (fabs.f64 a)
b_m = (fabs.f64 b)
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
(FPCore (a_m b_m) :precision binary64 (- (* (* (* a_m a_m) b_m) b_m)))
a_m = fabs(a);
b_m = fabs(b);
assert(a_m < b_m);
double code(double a_m, double b_m) {
	return -(((a_m * a_m) * b_m) * b_m);
}
a_m =     private
b_m =     private
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a_m, b_m)
use fmin_fmax_functions
    real(8), intent (in) :: a_m
    real(8), intent (in) :: b_m
    code = -(((a_m * a_m) * b_m) * b_m)
end function
a_m = Math.abs(a);
b_m = Math.abs(b);
assert a_m < b_m;
public static double code(double a_m, double b_m) {
	return -(((a_m * a_m) * b_m) * b_m);
}
a_m = math.fabs(a)
b_m = math.fabs(b)
[a_m, b_m] = sort([a_m, b_m])
def code(a_m, b_m):
	return -(((a_m * a_m) * b_m) * b_m)
a_m = abs(a)
b_m = abs(b)
a_m, b_m = sort([a_m, b_m])
function code(a_m, b_m)
	return Float64(-Float64(Float64(Float64(a_m * a_m) * b_m) * b_m))
end
a_m = abs(a);
b_m = abs(b);
a_m, b_m = num2cell(sort([a_m, b_m])){:}
function tmp = code(a_m, b_m)
	tmp = -(((a_m * a_m) * b_m) * b_m);
end
a_m = N[Abs[a], $MachinePrecision]
b_m = N[Abs[b], $MachinePrecision]
NOTE: a_m and b_m should be sorted in increasing order before calling this function.
code[a$95$m_, b$95$m_] := (-N[(N[(N[(a$95$m * a$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision])
\begin{array}{l}
a_m = \left|a\right|
\\
b_m = \left|b\right|
\\
[a_m, b_m] = \mathsf{sort}([a_m, b_m])\\
\\
-\left(\left(a\_m \cdot a\_m\right) \cdot b\_m\right) \cdot b\_m
\end{array}
Derivation
  1. Initial program 81.9%

    \[-\left(\left(a \cdot a\right) \cdot b\right) \cdot b \]
  2. Add Preprocessing

Reproduce

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