Hyperbolic arc-(co)tangent

Percentage Accurate: 8.8% → 100.0%
Time: 8.2s
Alternatives: 4
Speedup: 22.2×

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)));
}
real(8) function code(x)
    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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 4 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.8% 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)));
}
real(8) function code(x)
    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.5× speedup?

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

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

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. metadata-eval8.9%

      \[\leadsto \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
    2. log-div9.0%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \]
    3. log1p-def21.3%

      \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \]
    4. sub-neg21.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 + \left(-x\right)\right)}\right) \]
    5. log1p-def100.0%

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

    \[\leadsto \color{blue}{0.5 \cdot \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right)} \]
  4. Final simplification100.0%

    \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \]

Alternative 2: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot 2 + 0.6666666666666666 \cdot {x}^{3}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (* 0.5 (+ (* x 2.0) (* 0.6666666666666666 (pow x 3.0)))))
double code(double x) {
	return 0.5 * ((x * 2.0) + (0.6666666666666666 * pow(x, 3.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.5d0 * ((x * 2.0d0) + (0.6666666666666666d0 * (x ** 3.0d0)))
end function
public static double code(double x) {
	return 0.5 * ((x * 2.0) + (0.6666666666666666 * Math.pow(x, 3.0)));
}
def code(x):
	return 0.5 * ((x * 2.0) + (0.6666666666666666 * math.pow(x, 3.0)))
function code(x)
	return Float64(0.5 * Float64(Float64(x * 2.0) + Float64(0.6666666666666666 * (x ^ 3.0))))
end
function tmp = code(x)
	tmp = 0.5 * ((x * 2.0) + (0.6666666666666666 * (x ^ 3.0)));
end
code[x_] := N[(0.5 * N[(N[(x * 2.0), $MachinePrecision] + N[(0.6666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot 2 + 0.6666666666666666 \cdot {x}^{3}\right)
\end{array}
Derivation
  1. Initial program 8.9%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. metadata-eval8.9%

      \[\leadsto \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  3. Simplified8.9%

    \[\leadsto \color{blue}{0.5 \cdot \log \left(\frac{1 + x}{1 - x}\right)} \]
  4. Taylor expanded in x around 0 99.4%

    \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot x + 0.6666666666666666 \cdot {x}^{3}\right)} \]
  5. Final simplification99.4%

    \[\leadsto 0.5 \cdot \left(x \cdot 2 + 0.6666666666666666 \cdot {x}^{3}\right) \]

Alternative 3: 98.8% accurate, 22.2× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot 2\right) \end{array} \]
(FPCore (x) :precision binary64 (* 0.5 (* x 2.0)))
double code(double x) {
	return 0.5 * (x * 2.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.5d0 * (x * 2.0d0)
end function
public static double code(double x) {
	return 0.5 * (x * 2.0);
}
def code(x):
	return 0.5 * (x * 2.0)
function code(x)
	return Float64(0.5 * Float64(x * 2.0))
end
function tmp = code(x)
	tmp = 0.5 * (x * 2.0);
end
code[x_] := N[(0.5 * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot 2\right)
\end{array}
Derivation
  1. Initial program 8.9%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. metadata-eval8.9%

      \[\leadsto \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  3. Simplified8.9%

    \[\leadsto \color{blue}{0.5 \cdot \log \left(\frac{1 + x}{1 - x}\right)} \]
  4. Taylor expanded in x around 0 99.1%

    \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot x\right)} \]
  5. Final simplification99.1%

    \[\leadsto 0.5 \cdot \left(x \cdot 2\right) \]

Alternative 4: 5.4% accurate, 111.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x) :precision binary64 0.0)
double code(double x) {
	return 0.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.0d0
end function
public static double code(double x) {
	return 0.0;
}
def code(x):
	return 0.0
function code(x)
	return 0.0
end
function tmp = code(x)
	tmp = 0.0;
end
code[x_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 8.9%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. metadata-eval8.9%

      \[\leadsto \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  3. Simplified8.9%

    \[\leadsto \color{blue}{0.5 \cdot \log \left(\frac{1 + x}{1 - x}\right)} \]
  4. Step-by-step derivation
    1. div-inv9.0%

      \[\leadsto 0.5 \cdot \log \color{blue}{\left(\left(1 + x\right) \cdot \frac{1}{1 - x}\right)} \]
    2. add-cube-cbrt8.8%

      \[\leadsto 0.5 \cdot \log \left(\color{blue}{\left(\left(\sqrt[3]{1 + x} \cdot \sqrt[3]{1 + x}\right) \cdot \sqrt[3]{1 + x}\right)} \cdot \frac{1}{1 - x}\right) \]
    3. associate-*l*8.8%

      \[\leadsto 0.5 \cdot \log \color{blue}{\left(\left(\sqrt[3]{1 + x} \cdot \sqrt[3]{1 + x}\right) \cdot \left(\sqrt[3]{1 + x} \cdot \frac{1}{1 - x}\right)\right)} \]
    4. pow28.8%

      \[\leadsto 0.5 \cdot \log \left(\color{blue}{{\left(\sqrt[3]{1 + x}\right)}^{2}} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{1}{1 - x}\right)\right) \]
    5. frac-2neg8.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \color{blue}{\frac{-1}{-\left(1 - x\right)}}\right)\right) \]
    6. metadata-eval8.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{\color{blue}{-1}}{-\left(1 - x\right)}\right)\right) \]
    7. sub-neg8.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\color{blue}{\left(1 + \left(-x\right)\right)}}\right)\right) \]
    8. add-sqr-sqrt4.9%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\left(1 + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)}\right)\right) \]
    9. sqrt-unprod7.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\left(1 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right)}\right)\right) \]
    10. sqr-neg7.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\left(1 + \sqrt{\color{blue}{x \cdot x}}\right)}\right)\right) \]
    11. sqrt-unprod2.9%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)}\right)\right) \]
    12. add-sqr-sqrt5.6%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\left(1 + \color{blue}{x}\right)}\right)\right) \]
    13. *-un-lft-identity5.6%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\color{blue}{1 \cdot \left(1 + x\right)}}\right)\right) \]
    14. *-un-lft-identity5.6%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\color{blue}{\left(1 + x\right)}}\right)\right) \]
    15. +-commutative5.6%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{-\color{blue}{\left(x + 1\right)}}\right)\right) \]
    16. distribute-neg-in5.6%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{\color{blue}{\left(-x\right) + \left(-1\right)}}\right)\right) \]
    17. add-sqr-sqrt2.6%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}} + \left(-1\right)}\right)\right) \]
    18. sqrt-unprod6.5%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} + \left(-1\right)}\right)\right) \]
    19. sqr-neg6.5%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{\sqrt{\color{blue}{x \cdot x}} + \left(-1\right)}\right)\right) \]
    20. sqrt-unprod3.9%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \left(-1\right)}\right)\right) \]
    21. add-sqr-sqrt8.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{\color{blue}{x} + \left(-1\right)}\right)\right) \]
    22. metadata-eval8.8%

      \[\leadsto 0.5 \cdot \log \left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{x + \color{blue}{-1}}\right)\right) \]
  5. Applied egg-rr8.8%

    \[\leadsto 0.5 \cdot \log \color{blue}{\left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \left(\sqrt[3]{1 + x} \cdot \frac{-1}{x + -1}\right)\right)} \]
  6. Step-by-step derivation
    1. associate-*r*8.8%

      \[\leadsto 0.5 \cdot \log \color{blue}{\left(\left({\left(\sqrt[3]{1 + x}\right)}^{2} \cdot \sqrt[3]{1 + x}\right) \cdot \frac{-1}{x + -1}\right)} \]
    2. unpow28.8%

      \[\leadsto 0.5 \cdot \log \left(\left(\color{blue}{\left(\sqrt[3]{1 + x} \cdot \sqrt[3]{1 + x}\right)} \cdot \sqrt[3]{1 + x}\right) \cdot \frac{-1}{x + -1}\right) \]
    3. add-cube-cbrt9.0%

      \[\leadsto 0.5 \cdot \log \left(\color{blue}{\left(1 + x\right)} \cdot \frac{-1}{x + -1}\right) \]
    4. add-sqr-sqrt8.9%

      \[\leadsto 0.5 \cdot \log \left(\left(1 + x\right) \cdot \color{blue}{\left(\sqrt{\frac{-1}{x + -1}} \cdot \sqrt{\frac{-1}{x + -1}}\right)}\right) \]
    5. associate-*r*8.9%

      \[\leadsto 0.5 \cdot \log \color{blue}{\left(\left(\left(1 + x\right) \cdot \sqrt{\frac{-1}{x + -1}}\right) \cdot \sqrt{\frac{-1}{x + -1}}\right)} \]
    6. log-prod8.9%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\log \left(\left(1 + x\right) \cdot \sqrt{\frac{-1}{x + -1}}\right) + \log \left(\sqrt{\frac{-1}{x + -1}}\right)\right)} \]
  7. Applied egg-rr8.8%

    \[\leadsto 0.5 \cdot \color{blue}{\left(\log \left(\left(1 + x\right) \cdot \frac{1}{\sqrt{1 - x}}\right) + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right)} \]
  8. Step-by-step derivation
    1. log-prod8.8%

      \[\leadsto 0.5 \cdot \left(\color{blue}{\left(\log \left(1 + x\right) + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right)} + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right) \]
    2. log1p-def21.1%

      \[\leadsto 0.5 \cdot \left(\left(\color{blue}{\mathsf{log1p}\left(x\right)} + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right) + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right) \]
    3. associate-+l+21.1%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{log1p}\left(x\right) + \left(\log \left(\frac{1}{\sqrt{1 - x}}\right) + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right)\right)} \]
    4. log-rec21.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(\color{blue}{\left(-\log \left(\sqrt{1 - x}\right)\right)} + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right)\right) \]
    5. neg-mul-121.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(\color{blue}{-1 \cdot \log \left(\sqrt{1 - x}\right)} + \log \left(\frac{1}{\sqrt{1 - x}}\right)\right)\right) \]
    6. log-rec21.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(-1 \cdot \log \left(\sqrt{1 - x}\right) + \color{blue}{\left(-\log \left(\sqrt{1 - x}\right)\right)}\right)\right) \]
    7. neg-mul-121.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(-1 \cdot \log \left(\sqrt{1 - x}\right) + \color{blue}{-1 \cdot \log \left(\sqrt{1 - x}\right)}\right)\right) \]
    8. distribute-rgt-out21.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \color{blue}{\log \left(\sqrt{1 - x}\right) \cdot \left(-1 + -1\right)}\right) \]
    9. metadata-eval21.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \log \left(\sqrt{1 - x}\right) \cdot \color{blue}{-2}\right) \]
  9. Simplified21.1%

    \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{log1p}\left(x\right) + \log \left(\sqrt{1 - x}\right) \cdot -2\right)} \]
  10. Step-by-step derivation
    1. add-cbrt-cube21.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \log \color{blue}{\left(\sqrt[3]{\left(\sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \sqrt{1 - x}}\right)} \cdot -2\right) \]
    2. pow1/321.1%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \log \color{blue}{\left({\left(\left(\sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \sqrt{1 - x}\right)}^{0.3333333333333333}\right)} \cdot -2\right) \]
    3. log-pow21.2%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \color{blue}{\left(0.3333333333333333 \cdot \log \left(\left(\sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \sqrt{1 - x}\right)\right)} \cdot -2\right) \]
    4. add-sqr-sqrt21.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \log \left(\color{blue}{\left(1 - x\right)} \cdot \sqrt{1 - x}\right)\right) \cdot -2\right) \]
    5. pow121.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \log \left(\color{blue}{{\left(1 - x\right)}^{1}} \cdot \sqrt{1 - x}\right)\right) \cdot -2\right) \]
    6. pow1/221.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \log \left({\left(1 - x\right)}^{1} \cdot \color{blue}{{\left(1 - x\right)}^{0.5}}\right)\right) \cdot -2\right) \]
    7. pow-prod-up21.2%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(1 - x\right)}^{\left(1 + 0.5\right)}\right)}\right) \cdot -2\right) \]
    8. log-pow21.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(1 + 0.5\right) \cdot \log \left(1 - x\right)\right)}\right) \cdot -2\right) \]
    9. metadata-eval21.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \left(\color{blue}{1.5} \cdot \log \left(1 - x\right)\right)\right) \cdot -2\right) \]
    10. sub-neg21.3%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \left(1.5 \cdot \log \color{blue}{\left(1 + \left(-x\right)\right)}\right)\right) \cdot -2\right) \]
    11. log1p-def99.6%

      \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \left(1.5 \cdot \color{blue}{\mathsf{log1p}\left(-x\right)}\right)\right) \cdot -2\right) \]
  11. Applied egg-rr99.6%

    \[\leadsto 0.5 \cdot \left(\mathsf{log1p}\left(x\right) + \color{blue}{\left(0.3333333333333333 \cdot \left(1.5 \cdot \mathsf{log1p}\left(-x\right)\right)\right)} \cdot -2\right) \]
  12. Step-by-step derivation
    1. expm1-log1p-u99.2%

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \left(1.5 \cdot \mathsf{log1p}\left(-x\right)\right)\right) \cdot -2\right)\right)} \]
    2. expm1-udef8.7%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\mathsf{log1p}\left(x\right) + \left(0.3333333333333333 \cdot \left(1.5 \cdot \mathsf{log1p}\left(-x\right)\right)\right) \cdot -2\right)} - 1\right)} \]
  13. Applied egg-rr5.2%

    \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \mathsf{log1p}\left(x\right)\right)\right)} - 1\right)} \]
  14. Step-by-step derivation
    1. expm1-def5.2%

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \mathsf{log1p}\left(x\right)\right)\right)\right)} \]
    2. expm1-log1p5.2%

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \mathsf{log1p}\left(x\right)\right)} \]
    3. fma-udef5.2%

      \[\leadsto 0.5 \cdot \color{blue}{\left(-1 \cdot \mathsf{log1p}\left(x\right) + \mathsf{log1p}\left(x\right)\right)} \]
    4. distribute-lft1-in5.2%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \mathsf{log1p}\left(x\right)\right)} \]
    5. metadata-eval5.2%

      \[\leadsto 0.5 \cdot \left(\color{blue}{0} \cdot \mathsf{log1p}\left(x\right)\right) \]
    6. mul0-lft5.2%

      \[\leadsto 0.5 \cdot \color{blue}{0} \]
  15. Simplified5.2%

    \[\leadsto 0.5 \cdot \color{blue}{0} \]
  16. Final simplification5.2%

    \[\leadsto 0 \]

Reproduce

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