Hyperbolic arc-(co)tangent

Percentage Accurate: 8.3% → 100.0%
Time: 5.2s
Alternatives: 5
Speedup: 134.0×

Specification

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

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

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

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

Alternative 1: 100.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \end{array} \]
(FPCore (x) :precision binary64 (* (- (log1p x) (log1p (- x))) 0.5))
double code(double x) {
	return (log1p(x) - log1p(-x)) * 0.5;
}
public static double code(double x) {
	return (Math.log1p(x) - Math.log1p(-x)) * 0.5;
}
def code(x):
	return (math.log1p(x) - math.log1p(-x)) * 0.5
function code(x)
	return Float64(Float64(log1p(x) - log1p(Float64(-x))) * 0.5)
end
code[x_] := N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5
\end{array}
Derivation
  1. Initial program 8.3%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    3. lower-*.f648.3

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    4. lift-log.f64N/A

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

      \[\leadsto \log \color{blue}{\left(\frac{1 + x}{1 - x}\right)} \cdot \frac{1}{2} \]
    6. log-divN/A

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

      \[\leadsto \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \cdot \frac{1}{2} \]
    8. lift-+.f64N/A

      \[\leadsto \left(\log \color{blue}{\left(1 + x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    9. lower-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    10. lift--.f64N/A

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{2} \]
    11. sub-negate1N/A

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(x\right)\right)}\right) \cdot \frac{1}{2} \]
    13. lower-neg.f64100.0

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{\frac{1}{2}} \]
    15. metadata-eval100.0

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{0.5} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5} \]
  4. Add Preprocessing

Alternative 2: 99.8% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.14285714285714285, x \cdot x, 0.2\right), x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (fma
   (fma (fma 0.14285714285714285 (* x x) 0.2) (* x x) 0.3333333333333333)
   (* x x)
   1.0)
  x))
double code(double x) {
	return fma(fma(fma(0.14285714285714285, (x * x), 0.2), (x * x), 0.3333333333333333), (x * x), 1.0) * x;
}
function code(x)
	return Float64(fma(fma(fma(0.14285714285714285, Float64(x * x), 0.2), Float64(x * x), 0.3333333333333333), Float64(x * x), 1.0) * x)
end
code[x_] := N[(N[(N[(N[(0.14285714285714285 * N[(x * x), $MachinePrecision] + 0.2), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.14285714285714285, x \cdot x, 0.2\right), x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x
\end{array}
Derivation
  1. Initial program 8.3%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    3. lower-*.f648.3

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    4. lift-log.f64N/A

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

      \[\leadsto \log \color{blue}{\left(\frac{1 + x}{1 - x}\right)} \cdot \frac{1}{2} \]
    6. log-divN/A

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

      \[\leadsto \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \cdot \frac{1}{2} \]
    8. lift-+.f64N/A

      \[\leadsto \left(\log \color{blue}{\left(1 + x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    9. lower-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    10. lift--.f64N/A

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{2} \]
    11. sub-negate1N/A

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(x\right)\right)}\right) \cdot \frac{1}{2} \]
    13. lower-neg.f64100.0

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{\frac{1}{2}} \]
    15. metadata-eval100.0

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{0.5} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5} \]
  4. Step-by-step derivation
    1. lift-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\log \left(1 + x\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    2. flip3-+N/A

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

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

      \[\leadsto \left(\color{blue}{\left(\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    5. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{{x}^{3}}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    8. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\color{blue}{x \cdot x} - 1 \cdot x\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    19. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + \left(\mathsf{neg}\left(\color{blue}{1 \cdot x}\right)\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    21. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + 1 \cdot \color{blue}{\left(-x\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
  5. Applied rewrites100.0%

    \[\leadsto \left(\color{blue}{\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    4. lower-*.f64100.0

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  7. Applied rewrites100.0%

    \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  8. Taylor expanded in x around 0

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

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

      \[\leadsto \left(1 + {x}^{2} \cdot \left(\frac{1}{3} + {x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{7} \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
  10. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.14285714285714285, x \cdot x, 0.2\right), x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x} \]
  11. Add Preprocessing

Alternative 3: 99.7% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x \end{array} \]
(FPCore (x)
 :precision binary64
 (* (fma (fma 0.2 (* x x) 0.3333333333333333) (* x x) 1.0) x))
double code(double x) {
	return fma(fma(0.2, (x * x), 0.3333333333333333), (x * x), 1.0) * x;
}
function code(x)
	return Float64(fma(fma(0.2, Float64(x * x), 0.3333333333333333), Float64(x * x), 1.0) * x)
end
code[x_] := N[(N[(N[(0.2 * N[(x * x), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x
\end{array}
Derivation
  1. Initial program 8.3%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    3. lower-*.f648.3

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    4. lift-log.f64N/A

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

      \[\leadsto \log \color{blue}{\left(\frac{1 + x}{1 - x}\right)} \cdot \frac{1}{2} \]
    6. log-divN/A

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

      \[\leadsto \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \cdot \frac{1}{2} \]
    8. lift-+.f64N/A

      \[\leadsto \left(\log \color{blue}{\left(1 + x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    9. lower-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    10. lift--.f64N/A

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{2} \]
    11. sub-negate1N/A

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(x\right)\right)}\right) \cdot \frac{1}{2} \]
    13. lower-neg.f64100.0

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{\frac{1}{2}} \]
    15. metadata-eval100.0

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{0.5} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5} \]
  4. Step-by-step derivation
    1. lift-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\log \left(1 + x\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    2. flip3-+N/A

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

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

      \[\leadsto \left(\color{blue}{\left(\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    5. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{{x}^{3}}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    8. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\color{blue}{x \cdot x} - 1 \cdot x\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    19. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + \left(\mathsf{neg}\left(\color{blue}{1 \cdot x}\right)\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    21. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + 1 \cdot \color{blue}{\left(-x\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
  5. Applied rewrites100.0%

    \[\leadsto \left(\color{blue}{\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    4. lower-*.f64100.0

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  7. Applied rewrites100.0%

    \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  8. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{5}, x \cdot x, \frac{1}{3}\right), x \cdot x, 1\right) \cdot x \]
    11. lift-*.f6499.7

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x \]
  10. Applied rewrites99.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.3333333333333333\right), x \cdot x, 1\right) \cdot x} \]
  11. Add Preprocessing

Alternative 4: 99.6% accurate, 7.9× speedup?

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

\\
\mathsf{fma}\left(x \cdot x, 0.3333333333333333, 1\right) \cdot x
\end{array}
Derivation
  1. Initial program 8.3%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    3. lower-*.f648.3

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    4. lift-log.f64N/A

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

      \[\leadsto \log \color{blue}{\left(\frac{1 + x}{1 - x}\right)} \cdot \frac{1}{2} \]
    6. log-divN/A

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

      \[\leadsto \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \cdot \frac{1}{2} \]
    8. lift-+.f64N/A

      \[\leadsto \left(\log \color{blue}{\left(1 + x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    9. lower-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    10. lift--.f64N/A

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{2} \]
    11. sub-negate1N/A

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(x\right)\right)}\right) \cdot \frac{1}{2} \]
    13. lower-neg.f64100.0

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{\frac{1}{2}} \]
    15. metadata-eval100.0

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{0.5} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5} \]
  4. Step-by-step derivation
    1. lift-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\log \left(1 + x\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    2. flip3-+N/A

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

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

      \[\leadsto \left(\color{blue}{\left(\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    5. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{{x}^{3}}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    8. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\color{blue}{x \cdot x} - 1 \cdot x\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    19. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + \left(\mathsf{neg}\left(\color{blue}{1 \cdot x}\right)\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    21. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + 1 \cdot \color{blue}{\left(-x\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
  5. Applied rewrites100.0%

    \[\leadsto \left(\color{blue}{\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    4. lower-*.f64100.0

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  7. Applied rewrites100.0%

    \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  8. Taylor expanded in x around 0

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x \cdot x, \frac{1}{3}, 1\right) \cdot x \]
    7. lift-*.f6499.6

      \[\leadsto \mathsf{fma}\left(x \cdot x, 0.3333333333333333, 1\right) \cdot x \]
  10. Applied rewrites99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, 0.3333333333333333, 1\right) \cdot x} \]
  11. Add Preprocessing

Alternative 5: 99.1% accurate, 134.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x) :precision binary64 x)
double code(double x) {
	return x;
}
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 = x
end function
public static double code(double x) {
	return x;
}
def code(x):
	return x
function code(x)
	return x
end
function tmp = code(x)
	tmp = x;
end
code[x_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 8.3%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    3. lower-*.f648.3

      \[\leadsto \color{blue}{\log \left(\frac{1 + x}{1 - x}\right) \cdot \frac{1}{2}} \]
    4. lift-log.f64N/A

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

      \[\leadsto \log \color{blue}{\left(\frac{1 + x}{1 - x}\right)} \cdot \frac{1}{2} \]
    6. log-divN/A

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

      \[\leadsto \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \cdot \frac{1}{2} \]
    8. lift-+.f64N/A

      \[\leadsto \left(\log \color{blue}{\left(1 + x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    9. lower-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \cdot \frac{1}{2} \]
    10. lift--.f64N/A

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{2} \]
    11. sub-negate1N/A

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(x\right)\right)}\right) \cdot \frac{1}{2} \]
    13. lower-neg.f64100.0

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

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{\frac{1}{2}} \]
    15. metadata-eval100.0

      \[\leadsto \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \color{blue}{0.5} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5} \]
  4. Step-by-step derivation
    1. lift-log1p.f64N/A

      \[\leadsto \left(\color{blue}{\log \left(1 + x\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    2. flip3-+N/A

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

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

      \[\leadsto \left(\color{blue}{\left(\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    5. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{{x}^{3}}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    8. metadata-evalN/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\color{blue}{x \cdot x} - 1 \cdot x\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    19. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + \left(\mathsf{neg}\left(\color{blue}{1 \cdot x}\right)\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    21. distribute-rgt-neg-outN/A

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

      \[\leadsto \left(\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\left(-x\right) \cdot \left(-x\right) + 1 \cdot \color{blue}{\left(-x\right)}\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
  5. Applied rewrites100.0%

    \[\leadsto \left(\color{blue}{\left(\mathsf{log1p}\left({x}^{3}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right)} - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

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

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

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot \frac{1}{2} \]
    4. lower-*.f64100.0

      \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  7. Applied rewrites100.0%

    \[\leadsto \left(\left(\mathsf{log1p}\left(\color{blue}{\left(x \cdot x\right) \cdot x}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(x, x, -x\right)\right)\right) - \mathsf{log1p}\left(-x\right)\right) \cdot 0.5 \]
  8. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x} \]
  9. Step-by-step derivation
    1. Applied rewrites99.1%

      \[\leadsto \color{blue}{x} \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025107 
    (FPCore (x)
      :name "Hyperbolic arc-(co)tangent"
      :precision binary64
      (* (/ 1.0 2.0) (log (/ (+ 1.0 x) (- 1.0 x)))))