Expression, p6

Percentage Accurate: 94.3% → 99.6%
Time: 2.3min
Alternatives: 5
Speedup: N/A×

Specification

?
\[\left(\left(\left(-14 \leq a \land a \leq -13\right) \land \left(-3 \leq b \land b \leq -2\right)\right) \land \left(3 \leq c \land c \leq 3.5\right)\right) \land \left(12.5 \leq d \land d \leq 13.5\right)\]
\[\begin{array}{l} \\ \left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \end{array} \]
(FPCore (a b c d) :precision binary64 (* (+ a (+ b (+ c d))) 2.0))
double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
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, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = (a + (b + (c + d))) * 2.0d0
end function
public static double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
def code(a, b, c, d):
	return (a + (b + (c + d))) * 2.0
function code(a, b, c, d)
	return Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0)
end
function tmp = code(a, b, c, d)
	tmp = (a + (b + (c + d))) * 2.0;
end
code[a_, b_, c_, d_] := N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 alternatives:

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

Initial Program: 94.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \end{array} \]
(FPCore (a b c d) :precision binary64 (* (+ a (+ b (+ c d))) 2.0))
double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
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, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = (a + (b + (c + d))) * 2.0d0
end function
public static double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
def code(a, b, c, d):
	return (a + (b + (c + d))) * 2.0
function code(a, b, c, d)
	return Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0)
end
function tmp = code(a, b, c, d)
	tmp = (a + (b + (c + d))) * 2.0;
end
code[a_, b_, c_, d_] := N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
\end{array}

Alternative 1: 99.6% accurate, N/A× speedup?

\[\begin{array}{l} \\ \left(b + c \cdot \left(1 + \frac{a + d}{c}\right)\right) \cdot 2 \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (* (+ b (* c (+ 1.0 (/ (+ a d) c)))) 2.0))
double code(double a, double b, double c, double d) {
	return (b + (c * (1.0 + ((a + d) / c)))) * 2.0;
}
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, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = (b + (c * (1.0d0 + ((a + d) / c)))) * 2.0d0
end function
public static double code(double a, double b, double c, double d) {
	return (b + (c * (1.0 + ((a + d) / c)))) * 2.0;
}
def code(a, b, c, d):
	return (b + (c * (1.0 + ((a + d) / c)))) * 2.0
function code(a, b, c, d)
	return Float64(Float64(b + Float64(c * Float64(1.0 + Float64(Float64(a + d) / c)))) * 2.0)
end
function tmp = code(a, b, c, d)
	tmp = (b + (c * (1.0 + ((a + d) / c)))) * 2.0;
end
code[a_, b_, c_, d_] := N[(N[(b + N[(c * N[(1.0 + N[(N[(a + d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\left(b + c \cdot \left(1 + \frac{a + d}{c}\right)\right) \cdot 2
\end{array}
Derivation
  1. Initial program 94.3%

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Add Preprocessing
  3. Taylor expanded in c around inf

    \[\leadsto \color{blue}{\left(c \cdot \left(1 + \left(\frac{a}{c} + \left(\frac{b}{c} + \frac{d}{c}\right)\right)\right)\right)} \cdot 2 \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(\left(1 + \left(\frac{a}{c} + \left(\frac{b}{c} + \frac{d}{c}\right)\right)\right) \cdot \color{blue}{c}\right) \cdot 2 \]
    2. lower-*.f64N/A

      \[\leadsto \left(\left(1 + \left(\frac{a}{c} + \left(\frac{b}{c} + \frac{d}{c}\right)\right)\right) \cdot \color{blue}{c}\right) \cdot 2 \]
    3. div-add-revN/A

      \[\leadsto \left(\left(1 + \left(\frac{a}{c} + \frac{b + d}{c}\right)\right) \cdot c\right) \cdot 2 \]
    4. div-addN/A

      \[\leadsto \left(\left(1 + \frac{a + \left(b + d\right)}{c}\right) \cdot c\right) \cdot 2 \]
    5. +-commutativeN/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} + 1\right) \cdot c\right) \cdot 2 \]
    6. metadata-evalN/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} + 1 \cdot 1\right) \cdot c\right) \cdot 2 \]
    7. fp-cancel-sign-sub-invN/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right) \cdot c\right) \cdot 2 \]
    8. metadata-evalN/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} - -1 \cdot 1\right) \cdot c\right) \cdot 2 \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} - -1\right) \cdot c\right) \cdot 2 \]
    10. lower--.f64N/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} - -1\right) \cdot c\right) \cdot 2 \]
    11. lower-/.f64N/A

      \[\leadsto \left(\left(\frac{a + \left(b + d\right)}{c} - -1\right) \cdot c\right) \cdot 2 \]
    12. +-commutativeN/A

      \[\leadsto \left(\left(\frac{\left(b + d\right) + a}{c} - -1\right) \cdot c\right) \cdot 2 \]
    13. lower-+.f64N/A

      \[\leadsto \left(\left(\frac{\left(b + d\right) + a}{c} - -1\right) \cdot c\right) \cdot 2 \]
    14. +-commutativeN/A

      \[\leadsto \left(\left(\frac{\left(d + b\right) + a}{c} - -1\right) \cdot c\right) \cdot 2 \]
    15. lower-+.f6495.2

      \[\leadsto \left(\left(\frac{\left(d + b\right) + a}{c} - -1\right) \cdot c\right) \cdot 2 \]
  5. Applied rewrites95.2%

    \[\leadsto \color{blue}{\left(\left(\frac{\left(d + b\right) + a}{c} - -1\right) \cdot c\right)} \cdot 2 \]
  6. Taylor expanded in b around 0

    \[\leadsto \left(b + \color{blue}{c \cdot \left(1 + \left(\frac{a}{c} + \frac{d}{c}\right)\right)}\right) \cdot 2 \]
  7. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \left(b + c \cdot \color{blue}{\left(1 + \left(\frac{a}{c} + \frac{d}{c}\right)\right)}\right) \cdot 2 \]
    2. lower-*.f64N/A

      \[\leadsto \left(b + c \cdot \left(1 + \color{blue}{\left(\frac{a}{c} + \frac{d}{c}\right)}\right)\right) \cdot 2 \]
    3. lower-+.f64N/A

      \[\leadsto \left(b + c \cdot \left(1 + \left(\frac{a}{c} + \color{blue}{\frac{d}{c}}\right)\right)\right) \cdot 2 \]
    4. div-add-revN/A

      \[\leadsto \left(b + c \cdot \left(1 + \frac{a + d}{c}\right)\right) \cdot 2 \]
    5. lower-/.f64N/A

      \[\leadsto \left(b + c \cdot \left(1 + \frac{a + d}{c}\right)\right) \cdot 2 \]
    6. lower-+.f6499.4

      \[\leadsto \left(b + c \cdot \left(1 + \frac{a + d}{c}\right)\right) \cdot 2 \]
  8. Applied rewrites99.4%

    \[\leadsto \left(b + \color{blue}{c \cdot \left(1 + \frac{a + d}{c}\right)}\right) \cdot 2 \]
  9. Add Preprocessing

Alternative 2: 97.0% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\\ t_1 := \frac{d \cdot d}{t\_0}\\ \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, t\_1, t\_1\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{t\_0}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (fma d d (pow (+ a b) 2.0)) (* d (+ a b))))
        (t_1 (/ (* d d) t_0)))
   (fma
    2.0
    (*
     c
     (-
      (fma 2.0 t_1 t_1)
      (/
       (* (+ (pow d 3.0) (pow (+ a b) 3.0)) (- (* 2.0 d) (+ a b)))
       (pow t_0 2.0))))
    (* b (+ 2.0 (* 2.0 (/ (+ a d) b)))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, pow((a + b), 2.0)) - (d * (a + b));
	double t_1 = (d * d) / t_0;
	return fma(2.0, (c * (fma(2.0, t_1, t_1) - (((pow(d, 3.0) + pow((a + b), 3.0)) * ((2.0 * d) - (a + b))) / pow(t_0, 2.0)))), (b * (2.0 + (2.0 * ((a + d) / b)))));
}
function code(a, b, c, d)
	t_0 = Float64(fma(d, d, (Float64(a + b) ^ 2.0)) - Float64(d * Float64(a + b)))
	t_1 = Float64(Float64(d * d) / t_0)
	return fma(2.0, Float64(c * Float64(fma(2.0, t_1, t_1) - Float64(Float64(Float64((d ^ 3.0) + (Float64(a + b) ^ 3.0)) * Float64(Float64(2.0 * d) - Float64(a + b))) / (t_0 ^ 2.0)))), Float64(b * Float64(2.0 + Float64(2.0 * Float64(Float64(a + d) / b)))))
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * d + N[Power[N[(a + b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(d * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d * d), $MachinePrecision] / t$95$0), $MachinePrecision]}, N[(2.0 * N[(c * N[(N[(2.0 * t$95$1 + t$95$1), $MachinePrecision] - N[(N[(N[(N[Power[d, 3.0], $MachinePrecision] + N[Power[N[(a + b), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * d), $MachinePrecision] - N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(2.0 + N[(2.0 * N[(N[(a + d), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\\
t_1 := \frac{d \cdot d}{t\_0}\\
\mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, t\_1, t\_1\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{t\_0}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 94.3%

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(a + \left(b + \left(c + d\right)\right)\right)} \cdot 2 \]
    2. lift-+.f64N/A

      \[\leadsto \left(a + \left(b + \color{blue}{\left(c + d\right)}\right)\right) \cdot 2 \]
    3. lift-+.f64N/A

      \[\leadsto \left(a + \color{blue}{\left(b + \left(c + d\right)\right)}\right) \cdot 2 \]
    4. associate-+r+N/A

      \[\leadsto \color{blue}{\left(\left(a + b\right) + \left(c + d\right)\right)} \cdot 2 \]
    5. flip3-+N/A

      \[\leadsto \color{blue}{\frac{{\left(a + b\right)}^{3} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)}} \cdot 2 \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{{\left(a + b\right)}^{3} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)}} \cdot 2 \]
    7. lower-+.f64N/A

      \[\leadsto \frac{\color{blue}{{\left(a + b\right)}^{3} + {\left(c + d\right)}^{3}}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    8. lower-pow.f64N/A

      \[\leadsto \frac{\color{blue}{{\left(a + b\right)}^{3}} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    9. lower-+.f64N/A

      \[\leadsto \frac{{\color{blue}{\left(a + b\right)}}^{3} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    10. lower-pow.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + \color{blue}{{\left(c + d\right)}^{3}}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    11. +-commutativeN/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\color{blue}{\left(d + c\right)}}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    12. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\color{blue}{\left(d + c\right)}}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    13. lower-fma.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\color{blue}{\mathsf{fma}\left(a + b, a + b, \left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)}} \cdot 2 \]
    14. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(\color{blue}{a + b}, a + b, \left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    15. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, \color{blue}{a + b}, \left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    16. lower--.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, \color{blue}{\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)}\right)} \cdot 2 \]
    17. pow2N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, \color{blue}{{\left(c + d\right)}^{2}} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    18. lower-pow.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, \color{blue}{{\left(c + d\right)}^{2}} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    19. +-commutativeN/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\color{blue}{\left(d + c\right)}}^{2} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    20. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\color{blue}{\left(d + c\right)}}^{2} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    21. lower-*.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\left(d + c\right)}^{2} - \color{blue}{\left(a + b\right) \cdot \left(c + d\right)}\right)} \cdot 2 \]
  4. Applied rewrites93.6%

    \[\leadsto \color{blue}{\frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\left(d + c\right)}^{2} - \left(a + b\right) \cdot \left(d + c\right)\right)}} \cdot 2 \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{2 \cdot \left(c \cdot \left(\left(2 \cdot \frac{{d}^{2}}{\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)} + \frac{{d}^{2}}{\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right)\right) + 2 \cdot \frac{{d}^{3} + {\left(a + b\right)}^{3}}{\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}} \]
  6. Applied rewrites94.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), 2 \cdot \frac{{d}^{3} + {\left(a + b\right)}^{3}}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right)} \]
  7. Taylor expanded in b around inf

    \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
  8. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
    2. lower-+.f64N/A

      \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
    3. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
    4. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
    5. lift-+.f6497.1

      \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
  9. Applied rewrites97.1%

    \[\leadsto \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), b \cdot \left(2 + 2 \cdot \frac{a + d}{b}\right)\right) \]
  10. Add Preprocessing

Alternative 3: 96.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(2, a \cdot a, a \cdot a\right)\\ t_1 := {a}^{3} + {d}^{3}\\ t_2 := 2 \cdot a - d\\ t_3 := 2 \cdot d - a\\ t_4 := \mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\\ t_5 := {t\_4}^{2}\\ t_6 := \frac{d \cdot d}{t\_4}\\ t_7 := {t\_4}^{3}\\ t_8 := \frac{t\_1}{t\_5}\\ t_9 := \frac{t\_0 \cdot t\_3}{t\_5}\\ t_10 := \frac{{\left(d \cdot t\_2\right)}^{2}}{t\_7}\\ t_11 := \frac{\left(d \cdot d\right) \cdot t\_2}{t\_5}\\ t_12 := \frac{d \cdot d}{t\_5}\\ t_13 := 2 \cdot \frac{t\_1 \cdot \left(t\_2 \cdot t\_3\right)}{t\_7}\\ t_14 := \frac{a \cdot a}{t\_4}\\ t_15 := \mathsf{fma}\left(2, t\_14, t\_14\right) - \frac{t\_1 \cdot t\_2}{t\_5}\\ t_16 := \frac{a}{t\_4}\\ \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, t\_6, t\_6\right) - \frac{t\_1 \cdot t\_3}{t\_5}\right), \mathsf{fma}\left(2, \frac{t\_1}{t\_4}, b \cdot \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(-2, t\_11, t\_13\right) - \mathsf{fma}\left(-1, t\_8, t\_9 + t\_11\right)\right), \mathsf{fma}\left(2, t\_15, b \cdot \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(-2, \mathsf{fma}\left(-1, t\_10, t\_12\right), \mathsf{fma}\left(2, \frac{t\_2 \cdot \left(\mathsf{fma}\left(-1, t\_8, t\_9\right) - t\_13\right)}{t\_4}, \frac{t\_1 \cdot \left(t\_3 \cdot \left(\mathsf{fma}\left(2, a \cdot a, \mathsf{fma}\left(2, d \cdot d, {t\_2}^{2}\right)\right) - 2 \cdot \left(a \cdot d\right)\right)\right)}{{t\_4}^{4}}\right)\right) - \mathsf{fma}\left(-1, t\_10, \mathsf{fma}\left(-1, \frac{t\_0}{t\_5}, \frac{\left(a + 2 \cdot a\right) \cdot t\_3}{t\_5} + t\_12\right)\right)\right), 2 \cdot \left(\mathsf{fma}\left(2, t\_16, t\_16\right) - \left(\frac{t\_2 \cdot t\_15}{t\_4} + \left(\frac{{a}^{3}}{t\_5} + \frac{{d}^{3}}{t\_5}\right)\right)\right)\right)\right)\right)\right)\right) \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma 2.0 (* a a) (* a a)))
        (t_1 (+ (pow a 3.0) (pow d 3.0)))
        (t_2 (- (* 2.0 a) d))
        (t_3 (- (* 2.0 d) a))
        (t_4 (- (fma a a (* d d)) (* a d)))
        (t_5 (pow t_4 2.0))
        (t_6 (/ (* d d) t_4))
        (t_7 (pow t_4 3.0))
        (t_8 (/ t_1 t_5))
        (t_9 (/ (* t_0 t_3) t_5))
        (t_10 (/ (pow (* d t_2) 2.0) t_7))
        (t_11 (/ (* (* d d) t_2) t_5))
        (t_12 (/ (* d d) t_5))
        (t_13 (* 2.0 (/ (* t_1 (* t_2 t_3)) t_7)))
        (t_14 (/ (* a a) t_4))
        (t_15 (- (fma 2.0 t_14 t_14) (/ (* t_1 t_2) t_5)))
        (t_16 (/ a t_4)))
   (fma
    2.0
    (* c (- (fma 2.0 t_6 t_6) (/ (* t_1 t_3) t_5)))
    (fma
     2.0
     (/ t_1 t_4)
     (*
      b
      (fma
       2.0
       (* c (- (fma -2.0 t_11 t_13) (fma -1.0 t_8 (+ t_9 t_11))))
       (fma
        2.0
        t_15
        (*
         b
         (fma
          2.0
          (*
           c
           (-
            (fma
             -2.0
             (fma -1.0 t_10 t_12)
             (fma
              2.0
              (/ (* t_2 (- (fma -1.0 t_8 t_9) t_13)) t_4)
              (/
               (*
                t_1
                (*
                 t_3
                 (-
                  (fma 2.0 (* a a) (fma 2.0 (* d d) (pow t_2 2.0)))
                  (* 2.0 (* a d)))))
               (pow t_4 4.0))))
            (fma
             -1.0
             t_10
             (fma -1.0 (/ t_0 t_5) (+ (/ (* (+ a (* 2.0 a)) t_3) t_5) t_12)))))
          (*
           2.0
           (-
            (fma 2.0 t_16 t_16)
            (+
             (/ (* t_2 t_15) t_4)
             (+ (/ (pow a 3.0) t_5) (/ (pow d 3.0) t_5))))))))))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(2.0, (a * a), (a * a));
	double t_1 = pow(a, 3.0) + pow(d, 3.0);
	double t_2 = (2.0 * a) - d;
	double t_3 = (2.0 * d) - a;
	double t_4 = fma(a, a, (d * d)) - (a * d);
	double t_5 = pow(t_4, 2.0);
	double t_6 = (d * d) / t_4;
	double t_7 = pow(t_4, 3.0);
	double t_8 = t_1 / t_5;
	double t_9 = (t_0 * t_3) / t_5;
	double t_10 = pow((d * t_2), 2.0) / t_7;
	double t_11 = ((d * d) * t_2) / t_5;
	double t_12 = (d * d) / t_5;
	double t_13 = 2.0 * ((t_1 * (t_2 * t_3)) / t_7);
	double t_14 = (a * a) / t_4;
	double t_15 = fma(2.0, t_14, t_14) - ((t_1 * t_2) / t_5);
	double t_16 = a / t_4;
	return fma(2.0, (c * (fma(2.0, t_6, t_6) - ((t_1 * t_3) / t_5))), fma(2.0, (t_1 / t_4), (b * fma(2.0, (c * (fma(-2.0, t_11, t_13) - fma(-1.0, t_8, (t_9 + t_11)))), fma(2.0, t_15, (b * fma(2.0, (c * (fma(-2.0, fma(-1.0, t_10, t_12), fma(2.0, ((t_2 * (fma(-1.0, t_8, t_9) - t_13)) / t_4), ((t_1 * (t_3 * (fma(2.0, (a * a), fma(2.0, (d * d), pow(t_2, 2.0))) - (2.0 * (a * d))))) / pow(t_4, 4.0)))) - fma(-1.0, t_10, fma(-1.0, (t_0 / t_5), ((((a + (2.0 * a)) * t_3) / t_5) + t_12))))), (2.0 * (fma(2.0, t_16, t_16) - (((t_2 * t_15) / t_4) + ((pow(a, 3.0) / t_5) + (pow(d, 3.0) / t_5))))))))))));
}
function code(a, b, c, d)
	t_0 = fma(2.0, Float64(a * a), Float64(a * a))
	t_1 = Float64((a ^ 3.0) + (d ^ 3.0))
	t_2 = Float64(Float64(2.0 * a) - d)
	t_3 = Float64(Float64(2.0 * d) - a)
	t_4 = Float64(fma(a, a, Float64(d * d)) - Float64(a * d))
	t_5 = t_4 ^ 2.0
	t_6 = Float64(Float64(d * d) / t_4)
	t_7 = t_4 ^ 3.0
	t_8 = Float64(t_1 / t_5)
	t_9 = Float64(Float64(t_0 * t_3) / t_5)
	t_10 = Float64((Float64(d * t_2) ^ 2.0) / t_7)
	t_11 = Float64(Float64(Float64(d * d) * t_2) / t_5)
	t_12 = Float64(Float64(d * d) / t_5)
	t_13 = Float64(2.0 * Float64(Float64(t_1 * Float64(t_2 * t_3)) / t_7))
	t_14 = Float64(Float64(a * a) / t_4)
	t_15 = Float64(fma(2.0, t_14, t_14) - Float64(Float64(t_1 * t_2) / t_5))
	t_16 = Float64(a / t_4)
	return fma(2.0, Float64(c * Float64(fma(2.0, t_6, t_6) - Float64(Float64(t_1 * t_3) / t_5))), fma(2.0, Float64(t_1 / t_4), Float64(b * fma(2.0, Float64(c * Float64(fma(-2.0, t_11, t_13) - fma(-1.0, t_8, Float64(t_9 + t_11)))), fma(2.0, t_15, Float64(b * fma(2.0, Float64(c * Float64(fma(-2.0, fma(-1.0, t_10, t_12), fma(2.0, Float64(Float64(t_2 * Float64(fma(-1.0, t_8, t_9) - t_13)) / t_4), Float64(Float64(t_1 * Float64(t_3 * Float64(fma(2.0, Float64(a * a), fma(2.0, Float64(d * d), (t_2 ^ 2.0))) - Float64(2.0 * Float64(a * d))))) / (t_4 ^ 4.0)))) - fma(-1.0, t_10, fma(-1.0, Float64(t_0 / t_5), Float64(Float64(Float64(Float64(a + Float64(2.0 * a)) * t_3) / t_5) + t_12))))), Float64(2.0 * Float64(fma(2.0, t_16, t_16) - Float64(Float64(Float64(t_2 * t_15) / t_4) + Float64(Float64((a ^ 3.0) / t_5) + Float64((d ^ 3.0) / t_5))))))))))))
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(2.0 * N[(a * a), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[a, 3.0], $MachinePrecision] + N[Power[d, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 * a), $MachinePrecision] - d), $MachinePrecision]}, Block[{t$95$3 = N[(N[(2.0 * d), $MachinePrecision] - a), $MachinePrecision]}, Block[{t$95$4 = N[(N[(a * a + N[(d * d), $MachinePrecision]), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[t$95$4, 2.0], $MachinePrecision]}, Block[{t$95$6 = N[(N[(d * d), $MachinePrecision] / t$95$4), $MachinePrecision]}, Block[{t$95$7 = N[Power[t$95$4, 3.0], $MachinePrecision]}, Block[{t$95$8 = N[(t$95$1 / t$95$5), $MachinePrecision]}, Block[{t$95$9 = N[(N[(t$95$0 * t$95$3), $MachinePrecision] / t$95$5), $MachinePrecision]}, Block[{t$95$10 = N[(N[Power[N[(d * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] / t$95$7), $MachinePrecision]}, Block[{t$95$11 = N[(N[(N[(d * d), $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$5), $MachinePrecision]}, Block[{t$95$12 = N[(N[(d * d), $MachinePrecision] / t$95$5), $MachinePrecision]}, Block[{t$95$13 = N[(2.0 * N[(N[(t$95$1 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision] / t$95$7), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$14 = N[(N[(a * a), $MachinePrecision] / t$95$4), $MachinePrecision]}, Block[{t$95$15 = N[(N[(2.0 * t$95$14 + t$95$14), $MachinePrecision] - N[(N[(t$95$1 * t$95$2), $MachinePrecision] / t$95$5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$16 = N[(a / t$95$4), $MachinePrecision]}, N[(2.0 * N[(c * N[(N[(2.0 * t$95$6 + t$95$6), $MachinePrecision] - N[(N[(t$95$1 * t$95$3), $MachinePrecision] / t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(t$95$1 / t$95$4), $MachinePrecision] + N[(b * N[(2.0 * N[(c * N[(N[(-2.0 * t$95$11 + t$95$13), $MachinePrecision] - N[(-1.0 * t$95$8 + N[(t$95$9 + t$95$11), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * t$95$15 + N[(b * N[(2.0 * N[(c * N[(N[(-2.0 * N[(-1.0 * t$95$10 + t$95$12), $MachinePrecision] + N[(2.0 * N[(N[(t$95$2 * N[(N[(-1.0 * t$95$8 + t$95$9), $MachinePrecision] - t$95$13), $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision] + N[(N[(t$95$1 * N[(t$95$3 * N[(N[(2.0 * N[(a * a), $MachinePrecision] + N[(2.0 * N[(d * d), $MachinePrecision] + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 * N[(a * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[t$95$4, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * t$95$10 + N[(-1.0 * N[(t$95$0 / t$95$5), $MachinePrecision] + N[(N[(N[(N[(a + N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision] / t$95$5), $MachinePrecision] + t$95$12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(N[(2.0 * t$95$16 + t$95$16), $MachinePrecision] - N[(N[(N[(t$95$2 * t$95$15), $MachinePrecision] / t$95$4), $MachinePrecision] + N[(N[(N[Power[a, 3.0], $MachinePrecision] / t$95$5), $MachinePrecision] + N[(N[Power[d, 3.0], $MachinePrecision] / t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(2, a \cdot a, a \cdot a\right)\\
t_1 := {a}^{3} + {d}^{3}\\
t_2 := 2 \cdot a - d\\
t_3 := 2 \cdot d - a\\
t_4 := \mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\\
t_5 := {t\_4}^{2}\\
t_6 := \frac{d \cdot d}{t\_4}\\
t_7 := {t\_4}^{3}\\
t_8 := \frac{t\_1}{t\_5}\\
t_9 := \frac{t\_0 \cdot t\_3}{t\_5}\\
t_10 := \frac{{\left(d \cdot t\_2\right)}^{2}}{t\_7}\\
t_11 := \frac{\left(d \cdot d\right) \cdot t\_2}{t\_5}\\
t_12 := \frac{d \cdot d}{t\_5}\\
t_13 := 2 \cdot \frac{t\_1 \cdot \left(t\_2 \cdot t\_3\right)}{t\_7}\\
t_14 := \frac{a \cdot a}{t\_4}\\
t_15 := \mathsf{fma}\left(2, t\_14, t\_14\right) - \frac{t\_1 \cdot t\_2}{t\_5}\\
t_16 := \frac{a}{t\_4}\\
\mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, t\_6, t\_6\right) - \frac{t\_1 \cdot t\_3}{t\_5}\right), \mathsf{fma}\left(2, \frac{t\_1}{t\_4}, b \cdot \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(-2, t\_11, t\_13\right) - \mathsf{fma}\left(-1, t\_8, t\_9 + t\_11\right)\right), \mathsf{fma}\left(2, t\_15, b \cdot \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(-2, \mathsf{fma}\left(-1, t\_10, t\_12\right), \mathsf{fma}\left(2, \frac{t\_2 \cdot \left(\mathsf{fma}\left(-1, t\_8, t\_9\right) - t\_13\right)}{t\_4}, \frac{t\_1 \cdot \left(t\_3 \cdot \left(\mathsf{fma}\left(2, a \cdot a, \mathsf{fma}\left(2, d \cdot d, {t\_2}^{2}\right)\right) - 2 \cdot \left(a \cdot d\right)\right)\right)}{{t\_4}^{4}}\right)\right) - \mathsf{fma}\left(-1, t\_10, \mathsf{fma}\left(-1, \frac{t\_0}{t\_5}, \frac{\left(a + 2 \cdot a\right) \cdot t\_3}{t\_5} + t\_12\right)\right)\right), 2 \cdot \left(\mathsf{fma}\left(2, t\_16, t\_16\right) - \left(\frac{t\_2 \cdot t\_15}{t\_4} + \left(\frac{{a}^{3}}{t\_5} + \frac{{d}^{3}}{t\_5}\right)\right)\right)\right)\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 94.3%

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(a + \left(b + \left(c + d\right)\right)\right)} \cdot 2 \]
    2. lift-+.f64N/A

      \[\leadsto \left(a + \left(b + \color{blue}{\left(c + d\right)}\right)\right) \cdot 2 \]
    3. lift-+.f64N/A

      \[\leadsto \left(a + \color{blue}{\left(b + \left(c + d\right)\right)}\right) \cdot 2 \]
    4. associate-+r+N/A

      \[\leadsto \color{blue}{\left(\left(a + b\right) + \left(c + d\right)\right)} \cdot 2 \]
    5. flip3-+N/A

      \[\leadsto \color{blue}{\frac{{\left(a + b\right)}^{3} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)}} \cdot 2 \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{{\left(a + b\right)}^{3} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)}} \cdot 2 \]
    7. lower-+.f64N/A

      \[\leadsto \frac{\color{blue}{{\left(a + b\right)}^{3} + {\left(c + d\right)}^{3}}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    8. lower-pow.f64N/A

      \[\leadsto \frac{\color{blue}{{\left(a + b\right)}^{3}} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    9. lower-+.f64N/A

      \[\leadsto \frac{{\color{blue}{\left(a + b\right)}}^{3} + {\left(c + d\right)}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    10. lower-pow.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + \color{blue}{{\left(c + d\right)}^{3}}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    11. +-commutativeN/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\color{blue}{\left(d + c\right)}}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    12. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\color{blue}{\left(d + c\right)}}^{3}}{\left(a + b\right) \cdot \left(a + b\right) + \left(\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    13. lower-fma.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\color{blue}{\mathsf{fma}\left(a + b, a + b, \left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)}} \cdot 2 \]
    14. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(\color{blue}{a + b}, a + b, \left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    15. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, \color{blue}{a + b}, \left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    16. lower--.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, \color{blue}{\left(c + d\right) \cdot \left(c + d\right) - \left(a + b\right) \cdot \left(c + d\right)}\right)} \cdot 2 \]
    17. pow2N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, \color{blue}{{\left(c + d\right)}^{2}} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    18. lower-pow.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, \color{blue}{{\left(c + d\right)}^{2}} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    19. +-commutativeN/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\color{blue}{\left(d + c\right)}}^{2} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    20. lower-+.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\color{blue}{\left(d + c\right)}}^{2} - \left(a + b\right) \cdot \left(c + d\right)\right)} \cdot 2 \]
    21. lower-*.f64N/A

      \[\leadsto \frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\left(d + c\right)}^{2} - \color{blue}{\left(a + b\right) \cdot \left(c + d\right)}\right)} \cdot 2 \]
  4. Applied rewrites93.6%

    \[\leadsto \color{blue}{\frac{{\left(a + b\right)}^{3} + {\left(d + c\right)}^{3}}{\mathsf{fma}\left(a + b, a + b, {\left(d + c\right)}^{2} - \left(a + b\right) \cdot \left(d + c\right)\right)}} \cdot 2 \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{2 \cdot \left(c \cdot \left(\left(2 \cdot \frac{{d}^{2}}{\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)} + \frac{{d}^{2}}{\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right)\right) + 2 \cdot \frac{{d}^{3} + {\left(a + b\right)}^{3}}{\left({d}^{2} + {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}} \]
  6. Applied rewrites94.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}, \frac{d \cdot d}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right) - \frac{\left({d}^{3} + {\left(a + b\right)}^{3}\right) \cdot \left(2 \cdot d - \left(a + b\right)\right)}{{\left(\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)\right)}^{2}}\right), 2 \cdot \frac{{d}^{3} + {\left(a + b\right)}^{3}}{\mathsf{fma}\left(d, d, {\left(a + b\right)}^{2}\right) - d \cdot \left(a + b\right)}\right)} \]
  7. Taylor expanded in b around 0

    \[\leadsto 2 \cdot \left(c \cdot \left(\left(2 \cdot \frac{{d}^{2}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + \frac{{d}^{2}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d}\right) - \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(2 \cdot d - a\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right)\right) + \color{blue}{\left(2 \cdot \frac{{a}^{3} + {d}^{3}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + b \cdot \left(2 \cdot \left(c \cdot \left(\left(-2 \cdot \frac{{d}^{2} \cdot \left(2 \cdot a - d\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + 2 \cdot \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(\left(2 \cdot a - d\right) \cdot \left(2 \cdot d - a\right)\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{3}}\right) - \left(-1 \cdot \frac{{a}^{3} + {d}^{3}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + \left(\frac{\left(2 \cdot {a}^{2} + {a}^{2}\right) \cdot \left(2 \cdot d - a\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + \frac{{d}^{2} \cdot \left(2 \cdot a - d\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right)\right)\right)\right) + \left(2 \cdot \left(\left(2 \cdot \frac{{a}^{2}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + \frac{{a}^{2}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d}\right) - \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(2 \cdot a - d\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right) + b \cdot \left(2 \cdot \left(c \cdot \left(\left(-2 \cdot \left(-1 \cdot \frac{{d}^{2} \cdot {\left(2 \cdot a - d\right)}^{2}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{3}} + \frac{{d}^{2}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right) + \left(2 \cdot \frac{\left(2 \cdot a - d\right) \cdot \left(\left(-1 \cdot \frac{{a}^{3} + {d}^{3}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + \frac{\left(2 \cdot {a}^{2} + {a}^{2}\right) \cdot \left(2 \cdot d - a\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right) - 2 \cdot \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(\left(2 \cdot a - d\right) \cdot \left(2 \cdot d - a\right)\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{3}}\right)}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(\left(2 \cdot d - a\right) \cdot \left(\left(2 \cdot {a}^{2} + \left(2 \cdot {d}^{2} + {\left(2 \cdot a - d\right)}^{2}\right)\right) - 2 \cdot \left(a \cdot d\right)\right)\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{4}}\right)\right) - \left(-1 \cdot \frac{{d}^{2} \cdot {\left(2 \cdot a - d\right)}^{2}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{3}} + \left(-1 \cdot \frac{2 \cdot {a}^{2} + {a}^{2}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + \left(\frac{\left(a + 2 \cdot a\right) \cdot \left(2 \cdot d - a\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + \frac{{d}^{2}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right)\right)\right)\right)\right) + 2 \cdot \left(\left(2 \cdot \frac{a}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + \frac{a}{\left({a}^{2} + {d}^{2}\right) - a \cdot d}\right) - \left(\frac{\left(2 \cdot a - d\right) \cdot \left(\left(2 \cdot \frac{{a}^{2}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + \frac{{a}^{2}}{\left({a}^{2} + {d}^{2}\right) - a \cdot d}\right) - \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(2 \cdot a - d\right)}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right)}{\left({a}^{2} + {d}^{2}\right) - a \cdot d} + \left(\frac{{a}^{3}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}} + \frac{{d}^{3}}{{\left(\left({a}^{2} + {d}^{2}\right) - a \cdot d\right)}^{2}}\right)\right)\right)\right)\right)\right)\right)} \]
  8. Applied rewrites96.4%

    \[\leadsto \mathsf{fma}\left(2, \color{blue}{c \cdot \left(\mathsf{fma}\left(2, \frac{d \cdot d}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}, \frac{d \cdot d}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}\right) - \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(2 \cdot d - a\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right)}, \mathsf{fma}\left(2, \frac{{a}^{3} + {d}^{3}}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}, b \cdot \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(-2, \frac{\left(d \cdot d\right) \cdot \left(2 \cdot a - d\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}, 2 \cdot \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(\left(2 \cdot a - d\right) \cdot \left(2 \cdot d - a\right)\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{3}}\right) - \mathsf{fma}\left(-1, \frac{{a}^{3} + {d}^{3}}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}, \frac{\mathsf{fma}\left(2, a \cdot a, a \cdot a\right) \cdot \left(2 \cdot d - a\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}} + \frac{\left(d \cdot d\right) \cdot \left(2 \cdot a - d\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right)\right), \mathsf{fma}\left(2, \mathsf{fma}\left(2, \frac{a \cdot a}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}, \frac{a \cdot a}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}\right) - \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(2 \cdot a - d\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}, b \cdot \mathsf{fma}\left(2, c \cdot \left(\mathsf{fma}\left(-2, \mathsf{fma}\left(-1, \frac{{\left(d \cdot \left(2 \cdot a - d\right)\right)}^{2}}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{3}}, \frac{d \cdot d}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right), \mathsf{fma}\left(2, \frac{\left(2 \cdot a - d\right) \cdot \left(\mathsf{fma}\left(-1, \frac{{a}^{3} + {d}^{3}}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}, \frac{\mathsf{fma}\left(2, a \cdot a, a \cdot a\right) \cdot \left(2 \cdot d - a\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right) - 2 \cdot \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(\left(2 \cdot a - d\right) \cdot \left(2 \cdot d - a\right)\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{3}}\right)}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}, \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(\left(2 \cdot d - a\right) \cdot \left(\mathsf{fma}\left(2, a \cdot a, \mathsf{fma}\left(2, d \cdot d, {\left(2 \cdot a - d\right)}^{2}\right)\right) - 2 \cdot \left(a \cdot d\right)\right)\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{4}}\right)\right) - \mathsf{fma}\left(-1, \frac{{\left(d \cdot \left(2 \cdot a - d\right)\right)}^{2}}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{3}}, \mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(2, a \cdot a, a \cdot a\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}, \frac{\left(a + 2 \cdot a\right) \cdot \left(2 \cdot d - a\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}} + \frac{d \cdot d}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right)\right)\right), 2 \cdot \left(\mathsf{fma}\left(2, \frac{a}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}, \frac{a}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}\right) - \left(\frac{\left(2 \cdot a - d\right) \cdot \left(\mathsf{fma}\left(2, \frac{a \cdot a}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}, \frac{a \cdot a}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d}\right) - \frac{\left({a}^{3} + {d}^{3}\right) \cdot \left(2 \cdot a - d\right)}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right)}{\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d} + \left(\frac{{a}^{3}}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}} + \frac{{d}^{3}}{{\left(\mathsf{fma}\left(a, a, d \cdot d\right) - a \cdot d\right)}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
  9. Add Preprocessing

Alternative 4: 95.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ 2 \cdot \left(c + \left(\left(d + b\right) + a\right)\right) \end{array} \]
(FPCore (a b c d) :precision binary64 (* 2.0 (+ c (+ (+ d b) a))))
double code(double a, double b, double c, double d) {
	return 2.0 * (c + ((d + b) + a));
}
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, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = 2.0d0 * (c + ((d + b) + a))
end function
public static double code(double a, double b, double c, double d) {
	return 2.0 * (c + ((d + b) + a));
}
def code(a, b, c, d):
	return 2.0 * (c + ((d + b) + a))
function code(a, b, c, d)
	return Float64(2.0 * Float64(c + Float64(Float64(d + b) + a)))
end
function tmp = code(a, b, c, d)
	tmp = 2.0 * (c + ((d + b) + a));
end
code[a_, b_, c_, d_] := N[(2.0 * N[(c + N[(N[(d + b), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \left(c + \left(\left(d + b\right) + a\right)\right)
\end{array}
Derivation
  1. Initial program 94.3%

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Add Preprocessing
  3. Taylor expanded in c around 0

    \[\leadsto \color{blue}{2 \cdot c + 2 \cdot \left(a + \left(b + d\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-lft-outN/A

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

      \[\leadsto 2 \cdot \color{blue}{\left(c + \left(a + \left(b + d\right)\right)\right)} \]
    3. lower-+.f64N/A

      \[\leadsto 2 \cdot \left(c + \color{blue}{\left(a + \left(b + d\right)\right)}\right) \]
    4. +-commutativeN/A

      \[\leadsto 2 \cdot \left(c + \left(\left(b + d\right) + \color{blue}{a}\right)\right) \]
    5. lower-+.f64N/A

      \[\leadsto 2 \cdot \left(c + \left(\left(b + d\right) + \color{blue}{a}\right)\right) \]
    6. +-commutativeN/A

      \[\leadsto 2 \cdot \left(c + \left(\left(d + b\right) + a\right)\right) \]
    7. lower-+.f6495.7

      \[\leadsto 2 \cdot \left(c + \left(\left(d + b\right) + a\right)\right) \]
  5. Applied rewrites95.7%

    \[\leadsto \color{blue}{2 \cdot \left(c + \left(\left(d + b\right) + a\right)\right)} \]
  6. Add Preprocessing

Alternative 5: 95.4% accurate, N/A× speedup?

\[\begin{array}{l} \\ 2 \cdot \left(b + d \cdot \left(1 + \frac{a + c}{d}\right)\right) \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (* 2.0 (+ b (* d (+ 1.0 (/ (+ a c) d))))))
double code(double a, double b, double c, double d) {
	return 2.0 * (b + (d * (1.0 + ((a + c) / d))));
}
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, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = 2.0d0 * (b + (d * (1.0d0 + ((a + c) / d))))
end function
public static double code(double a, double b, double c, double d) {
	return 2.0 * (b + (d * (1.0 + ((a + c) / d))));
}
def code(a, b, c, d):
	return 2.0 * (b + (d * (1.0 + ((a + c) / d))))
function code(a, b, c, d)
	return Float64(2.0 * Float64(b + Float64(d * Float64(1.0 + Float64(Float64(a + c) / d)))))
end
function tmp = code(a, b, c, d)
	tmp = 2.0 * (b + (d * (1.0 + ((a + c) / d))));
end
code[a_, b_, c_, d_] := N[(2.0 * N[(b + N[(d * N[(1.0 + N[(N[(a + c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \left(b + d \cdot \left(1 + \frac{a + c}{d}\right)\right)
\end{array}
Derivation
  1. Initial program 94.3%

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Add Preprocessing
  3. Taylor expanded in b around 0

    \[\leadsto \color{blue}{2 \cdot b + 2 \cdot \left(a + \left(c + d\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-lft-outN/A

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

      \[\leadsto 2 \cdot \color{blue}{\left(b + \left(a + \left(c + d\right)\right)\right)} \]
    3. lower-+.f64N/A

      \[\leadsto 2 \cdot \left(b + \color{blue}{\left(a + \left(c + d\right)\right)}\right) \]
    4. +-commutativeN/A

      \[\leadsto 2 \cdot \left(b + \left(\left(c + d\right) + \color{blue}{a}\right)\right) \]
    5. lower-+.f64N/A

      \[\leadsto 2 \cdot \left(b + \left(\left(c + d\right) + \color{blue}{a}\right)\right) \]
    6. +-commutativeN/A

      \[\leadsto 2 \cdot \left(b + \left(\left(d + c\right) + a\right)\right) \]
    7. lower-+.f6494.5

      \[\leadsto 2 \cdot \left(b + \left(\left(d + c\right) + a\right)\right) \]
  5. Applied rewrites94.5%

    \[\leadsto \color{blue}{2 \cdot \left(b + \left(\left(d + c\right) + a\right)\right)} \]
  6. Taylor expanded in d around inf

    \[\leadsto 2 \cdot \left(b + d \cdot \color{blue}{\left(1 + \left(\frac{a}{d} + \frac{c}{d}\right)\right)}\right) \]
  7. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto 2 \cdot \left(b + d \cdot \left(1 + \color{blue}{\left(\frac{a}{d} + \frac{c}{d}\right)}\right)\right) \]
    2. lower-+.f64N/A

      \[\leadsto 2 \cdot \left(b + d \cdot \left(1 + \left(\frac{a}{d} + \color{blue}{\frac{c}{d}}\right)\right)\right) \]
    3. div-add-revN/A

      \[\leadsto 2 \cdot \left(b + d \cdot \left(1 + \frac{a + c}{d}\right)\right) \]
    4. lower-/.f64N/A

      \[\leadsto 2 \cdot \left(b + d \cdot \left(1 + \frac{a + c}{d}\right)\right) \]
    5. lower-+.f6495.2

      \[\leadsto 2 \cdot \left(b + d \cdot \left(1 + \frac{a + c}{d}\right)\right) \]
  8. Applied rewrites95.2%

    \[\leadsto 2 \cdot \left(b + d \cdot \color{blue}{\left(1 + \frac{a + c}{d}\right)}\right) \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2025057 
(FPCore (a b c d)
  :name "Expression, p6"
  :precision binary64
  :pre (and (and (and (and (<= -14.0 a) (<= a -13.0)) (and (<= -3.0 b) (<= b -2.0))) (and (<= 3.0 c) (<= c 3.5))) (and (<= 12.5 d) (<= d 13.5)))

  :alt
  (! :herbie-platform default (let ((e 2)) (+ (* (+ a b) e) (* (+ c d) e))))

  (* (+ a (+ b (+ c d))) 2.0))