3frac (problem 3.3.3)

Percentage Accurate: 69.3% → 99.5%
Time: 6.5s
Alternatives: 7
Speedup: N/A×

Specification

?
\[\left|x\right| > 1\]
\[\begin{array}{l} \\ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \end{array} \]
(FPCore (x)
 :precision binary64
 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
double code(double x) {
	return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x - 1.0d0))
end function
public static double code(double x) {
	return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
def code(x):
	return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
function code(x)
	return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x - 1.0)))
end
function tmp = code(x)
	tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\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 7 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: 69.3% accurate, 1.0× speedup?

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

\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\end{array}

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

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

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

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Taylor expanded in x around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
  3. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
  4. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
  5. Applied rewrites99.2%

    \[\leadsto \mathsf{fma}\left(\frac{2}{x}, \color{blue}{{\left(\frac{-1}{x} \cdot -1\right)}^{2}}, \frac{\frac{-1}{x \cdot x} \cdot \frac{\mathsf{fma}\left({\left(\frac{-1}{x} \cdot -1\right)}^{2} \cdot 2, 1, 2\right)}{-1}}{\left(x \cdot x\right) \cdot x}\right) \]
  6. Applied rewrites99.4%

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

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{{\left(x \cdot x\right)}^{-1} \cdot 2}{x}\right) \]
    2. lift-pow.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{{\left(x \cdot x\right)}^{-1} \cdot 2}{x}\right) \]
    3. unpow-1N/A

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{\frac{1}{x \cdot x} \cdot 2}{x}\right) \]
    4. pow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{\frac{1}{{x}^{2}} \cdot 2}{x}\right) \]
    5. pow-flipN/A

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{{x}^{\left(\mathsf{neg}\left(2\right)\right)} \cdot 2}{x}\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{{x}^{-2} \cdot 2}{x}\right) \]
    7. lower-pow.f6499.5

      \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{{x}^{-2} \cdot 2}{x}\right) \]
  8. Applied rewrites99.5%

    \[\leadsto \mathsf{fma}\left(\frac{\frac{-1}{x \cdot x}}{x \cdot x}, \frac{\frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{1}}{x}, \frac{{x}^{-2} \cdot 2}{x}\right) \]
  9. Add Preprocessing

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

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

\\
\begin{array}{l}
t_0 := \frac{-1}{x \cdot x}\\
\mathsf{fma}\left(t\_0, \frac{-1}{x} \cdot 2, \frac{t\_0 \cdot \frac{\mathsf{fma}\left({\left(\frac{-1}{x} \cdot -1\right)}^{2} \cdot 2, 1, 2\right)}{-1}}{\left(x \cdot x\right) \cdot x}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 69.3%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Taylor expanded in x around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
  3. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
  4. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
  5. Applied rewrites99.4%

    \[\leadsto \mathsf{fma}\left(\frac{-1}{x \cdot x}, \color{blue}{\frac{-1}{x} \cdot 2}, \frac{\frac{-1}{x \cdot x} \cdot \frac{\mathsf{fma}\left({\left(\frac{-1}{x} \cdot -1\right)}^{2} \cdot 2, 1, 2\right)}{-1}}{\left(x \cdot x\right) \cdot x}\right) \]
  6. Add Preprocessing

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

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

\\
\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{3}}
\end{array}
Derivation
  1. Initial program 69.3%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Taylor expanded in x around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
  3. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
  4. Applied rewrites98.7%

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

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \color{blue}{-1}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1} \]
    4. pow3N/A

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{x}^{3} \cdot -1} \]
    5. metadata-evalN/A

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{x}^{3} \cdot {-1}^{\color{blue}{3}}} \]
    6. unpow-prod-downN/A

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

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

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{\color{blue}{3}}} \]
    9. lift-*.f6498.7

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{3}} \]
  6. Applied rewrites98.7%

    \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{\color{blue}{3}}} \]
  7. Add Preprocessing

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

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

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

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Taylor expanded in x around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
  3. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
  4. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
  5. Add Preprocessing

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(-1 \cdot x\right)}^{0.75}\\ t_1 := t\_0 \cdot t\_0\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{-1 \cdot x}, -2\right)}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (pow (* -1.0 x) 0.75)) (t_1 (* t_0 t_0)))
   (if (<= x -1.0)
     (/
      (/
       (fma
        (* (pow x -1.0) -1.0)
        (/ (* (fma (pow (* x x) -1.0) 2.0 2.0) -1.0) (* -1.0 x))
        -2.0)
       t_1)
      t_1)
     (/ (fma (fma (* (* x x) 2.0) 1.0 2.0) (* x x) 2.0) (pow (* x x) 3.5)))))
double code(double x) {
	double t_0 = pow((-1.0 * x), 0.75);
	double t_1 = t_0 * t_0;
	double tmp;
	if (x <= -1.0) {
		tmp = (fma((pow(x, -1.0) * -1.0), ((fma(pow((x * x), -1.0), 2.0, 2.0) * -1.0) / (-1.0 * x)), -2.0) / t_1) / t_1;
	} else {
		tmp = fma(fma(((x * x) * 2.0), 1.0, 2.0), (x * x), 2.0) / pow((x * x), 3.5);
	}
	return tmp;
}
function code(x)
	t_0 = Float64(-1.0 * x) ^ 0.75
	t_1 = Float64(t_0 * t_0)
	tmp = 0.0
	if (x <= -1.0)
		tmp = Float64(Float64(fma(Float64((x ^ -1.0) * -1.0), Float64(Float64(fma((Float64(x * x) ^ -1.0), 2.0, 2.0) * -1.0) / Float64(-1.0 * x)), -2.0) / t_1) / t_1);
	else
		tmp = Float64(fma(fma(Float64(Float64(x * x) * 2.0), 1.0, 2.0), Float64(x * x), 2.0) / (Float64(x * x) ^ 3.5));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Power[N[(-1.0 * x), $MachinePrecision], 0.75], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision] * 2.0 + 2.0), $MachinePrecision] * -1.0), $MachinePrecision] / N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 2.0), $MachinePrecision] * 1.0 + 2.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] / N[Power[N[(x * x), $MachinePrecision], 3.5], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(-1 \cdot x\right)}^{0.75}\\
t_1 := t\_0 \cdot t\_0\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{-1 \cdot x}, -2\right)}{t\_1}}{t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1

    1. Initial program 69.4%

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
      2. distribute-neg-frac2N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    4. Applied rewrites98.7%

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \color{blue}{-1}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1} \]
      4. pow3N/A

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{x}^{3} \cdot -1} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{x}^{3} \cdot {-1}^{\color{blue}{3}}} \]
      6. unpow-prod-downN/A

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{3}} \]
      8. sqr-powN/A

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

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{\left(\frac{3}{2}\right)} \cdot {\color{blue}{\left(-1 \cdot x\right)}}^{\left(\frac{3}{2}\right)}} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\color{blue}{-1} \cdot x\right)}^{\left(\frac{3}{2}\right)}} \]
      12. metadata-evalN/A

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{\frac{3}{2}} \cdot {\left(-1 \cdot x\right)}^{\color{blue}{\left(\frac{3}{2}\right)}}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{\frac{3}{2}} \cdot {\left(-1 \cdot x\right)}^{\left(\frac{\color{blue}{3}}{2}\right)}} \]
      15. metadata-eval98.6

        \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{1.5} \cdot {\left(-1 \cdot x\right)}^{1.5}} \]
    6. Applied rewrites98.6%

      \[\leadsto \frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{{\left(-1 \cdot x\right)}^{1.5} \cdot \color{blue}{{\left(-1 \cdot x\right)}^{1.5}}} \]
    7. Applied rewrites99.1%

      \[\leadsto \frac{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right) \cdot -1}{-1 \cdot x}, -2\right)}{{\left(-1 \cdot x\right)}^{0.75} \cdot {\left(-1 \cdot x\right)}^{0.75}}}{\color{blue}{{\left(-1 \cdot x\right)}^{0.75} \cdot {\left(-1 \cdot x\right)}^{0.75}}} \]

    if -1 < x

    1. Initial program 69.2%

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
      2. distribute-neg-frac2N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    4. Applied rewrites98.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
    5. Taylor expanded in x around 0

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

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

        \[\leadsto \frac{{x}^{2} \cdot \left(2 + 2 \cdot {x}^{2}\right) + 2}{{x}^{7}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\left(2 + 2 \cdot {x}^{2}\right) \cdot {x}^{2} + 2}{{x}^{7}} \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(2 + 2 \cdot {x}^{2}, {x}^{2}, 2\right)}{{x}^{7}} \]
      5. +-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{2} \cdot 2 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
      7. metadata-evalN/A

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\left(2 \cdot {x}^{2}\right) \cdot 1 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(2 \cdot {x}^{2}, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      13. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      15. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
      16. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
      17. sqr-powN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{\left(\frac{7}{2}\right)} \cdot {x}^{\color{blue}{\left(\frac{7}{2}\right)}}} \]
      18. pow-prod-downN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\left(\frac{7}{\color{blue}{2}}\right)}} \]
    7. Applied rewrites14.2%

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\color{blue}{{\left(x \cdot x\right)}^{3.5}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 14.1% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)\\ t_1 := {\left(x \cdot x\right)}^{3.5}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{t\_0}{t\_1 \cdot -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{t\_1}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (fma (fma (* (* x x) 2.0) 1.0 2.0) (* x x) 2.0))
        (t_1 (pow (* x x) 3.5)))
   (if (<= x -1.0) (/ t_0 (* t_1 -1.0)) (/ t_0 t_1))))
double code(double x) {
	double t_0 = fma(fma(((x * x) * 2.0), 1.0, 2.0), (x * x), 2.0);
	double t_1 = pow((x * x), 3.5);
	double tmp;
	if (x <= -1.0) {
		tmp = t_0 / (t_1 * -1.0);
	} else {
		tmp = t_0 / t_1;
	}
	return tmp;
}
function code(x)
	t_0 = fma(fma(Float64(Float64(x * x) * 2.0), 1.0, 2.0), Float64(x * x), 2.0)
	t_1 = Float64(x * x) ^ 3.5
	tmp = 0.0
	if (x <= -1.0)
		tmp = Float64(t_0 / Float64(t_1 * -1.0));
	else
		tmp = Float64(t_0 / t_1);
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] * 2.0), $MachinePrecision] * 1.0 + 2.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(x * x), $MachinePrecision], 3.5], $MachinePrecision]}, If[LessEqual[x, -1.0], N[(t$95$0 / N[(t$95$1 * -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / t$95$1), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)\\
t_1 := {\left(x \cdot x\right)}^{3.5}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{t\_0}{t\_1 \cdot -1}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{t\_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1

    1. Initial program 69.4%

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
      2. distribute-neg-frac2N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    4. Applied rewrites98.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
    5. Taylor expanded in x around 0

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

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

        \[\leadsto \frac{{x}^{2} \cdot \left(2 + 2 \cdot {x}^{2}\right) + 2}{{x}^{7}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\left(2 + 2 \cdot {x}^{2}\right) \cdot {x}^{2} + 2}{{x}^{7}} \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(2 + 2 \cdot {x}^{2}, {x}^{2}, 2\right)}{{x}^{7}} \]
      5. +-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{2} \cdot 2 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
      7. metadata-evalN/A

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\left(2 \cdot {x}^{2}\right) \cdot 1 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(2 \cdot {x}^{2}, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      13. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      15. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
      16. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
      17. sqr-powN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{\left(\frac{7}{2}\right)} \cdot {x}^{\color{blue}{\left(\frac{7}{2}\right)}}} \]
      18. pow-prod-downN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\left(\frac{7}{\color{blue}{2}}\right)}} \]
    7. Applied rewrites0.9%

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\color{blue}{{\left(x \cdot x\right)}^{3.5}}} \]
    8. Taylor expanded in x around -inf

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{-1 \cdot {x}^{\color{blue}{7}}} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7} \cdot -1} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7} \cdot -1} \]
      3. sqr-powN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\left({x}^{\left(\frac{7}{2}\right)} \cdot {x}^{\left(\frac{7}{2}\right)}\right) \cdot -1} \]
      4. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\left({x}^{\frac{7}{2}} \cdot {x}^{\left(\frac{7}{2}\right)}\right) \cdot -1} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\left({x}^{\frac{7}{2}} \cdot {x}^{\frac{7}{2}}\right) \cdot -1} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\frac{7}{2}} \cdot -1} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\frac{7}{2}} \cdot -1} \]
      8. lift-pow.f6413.9

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5} \cdot -1} \]
    10. Applied rewrites13.9%

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5} \cdot -1} \]

    if -1 < x

    1. Initial program 69.2%

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
      2. distribute-neg-frac2N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    4. Applied rewrites98.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
    5. Taylor expanded in x around 0

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

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

        \[\leadsto \frac{{x}^{2} \cdot \left(2 + 2 \cdot {x}^{2}\right) + 2}{{x}^{7}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\left(2 + 2 \cdot {x}^{2}\right) \cdot {x}^{2} + 2}{{x}^{7}} \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(2 + 2 \cdot {x}^{2}, {x}^{2}, 2\right)}{{x}^{7}} \]
      5. +-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left({x}^{2} \cdot 2 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
      7. metadata-evalN/A

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\left(2 \cdot {x}^{2}\right) \cdot 1 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(2 \cdot {x}^{2}, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      13. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
      15. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
      16. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
      17. sqr-powN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{\left(\frac{7}{2}\right)} \cdot {x}^{\color{blue}{\left(\frac{7}{2}\right)}}} \]
      18. pow-prod-downN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\left(\frac{7}{\color{blue}{2}}\right)}} \]
    7. Applied rewrites14.2%

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\color{blue}{{\left(x \cdot x\right)}^{3.5}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 7.4% accurate, N/A× speedup?

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

\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5} \cdot -1}
\end{array}
Derivation
  1. Initial program 69.3%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Taylor expanded in x around -inf

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}} \]
  3. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(\frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{{x}^{3}}\right) \]
    2. distribute-neg-frac2N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{-1 \cdot \frac{2 + 2 \cdot \frac{1}{{x}^{2}}}{{x}^{2}} - 2}{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}} \]
  4. Applied rewrites98.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{-1} \cdot -1, \frac{\mathsf{fma}\left({\left(x \cdot x\right)}^{-1}, 2, 2\right)}{x}, -2\right)}{\left(\left(x \cdot x\right) \cdot x\right) \cdot -1}} \]
  5. Taylor expanded in x around 0

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

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

      \[\leadsto \frac{{x}^{2} \cdot \left(2 + 2 \cdot {x}^{2}\right) + 2}{{x}^{7}} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\left(2 + 2 \cdot {x}^{2}\right) \cdot {x}^{2} + 2}{{x}^{7}} \]
    4. lower-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(2 + 2 \cdot {x}^{2}, {x}^{2}, 2\right)}{{x}^{7}} \]
    5. +-commutativeN/A

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

      \[\leadsto \frac{\mathsf{fma}\left({x}^{2} \cdot 2 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
    7. metadata-evalN/A

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\left(2 \cdot {x}^{2}\right) \cdot 1 + 2, {x}^{2}, 2\right)}{{x}^{7}} \]
    10. lower-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(2 \cdot {x}^{2}, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
    11. *-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
    12. lower-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2} \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
    13. pow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
    14. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), {x}^{2}, 2\right)}{{x}^{7}} \]
    15. pow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
    16. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7}} \]
    17. sqr-powN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{\left(\frac{7}{2}\right)} \cdot {x}^{\color{blue}{\left(\frac{7}{2}\right)}}} \]
    18. pow-prod-downN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\left(\frac{7}{\color{blue}{2}}\right)}} \]
  7. Applied rewrites7.5%

    \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\color{blue}{{\left(x \cdot x\right)}^{3.5}}} \]
  8. Taylor expanded in x around -inf

    \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{-1 \cdot {x}^{\color{blue}{7}}} \]
  9. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7} \cdot -1} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{x}^{7} \cdot -1} \]
    3. sqr-powN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\left({x}^{\left(\frac{7}{2}\right)} \cdot {x}^{\left(\frac{7}{2}\right)}\right) \cdot -1} \]
    4. metadata-evalN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\left({x}^{\frac{7}{2}} \cdot {x}^{\left(\frac{7}{2}\right)}\right) \cdot -1} \]
    5. metadata-evalN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{\left({x}^{\frac{7}{2}} \cdot {x}^{\frac{7}{2}}\right) \cdot -1} \]
    6. unpow-prod-downN/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\frac{7}{2}} \cdot -1} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{\frac{7}{2}} \cdot -1} \]
    8. lift-pow.f647.4

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5} \cdot -1} \]
  10. Applied rewrites7.4%

    \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 2, 1, 2\right), x \cdot x, 2\right)}{{\left(x \cdot x\right)}^{3.5} \cdot -1} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2025093 
(FPCore (x)
  :name "3frac (problem 3.3.3)"
  :precision binary64
  :pre (> (fabs x) 1.0)
  (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))