?

Average Accuracy: 8.7% → 100.0%
Time: 6.0s
Precision: binary64
Cost: 13184

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 8.7%

    \[\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  2. Simplified100.0%

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

    [Start]8.7

    \[ \frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]

    *-rgt-identity [<=]8.7

    \[ \color{blue}{\left(\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)\right) \cdot 1} \]

    associate-*r* [<=]8.7

    \[ \color{blue}{\frac{1}{2} \cdot \left(\log \left(\frac{1 + x}{1 - x}\right) \cdot 1\right)} \]

    *-commutative [<=]8.7

    \[ \frac{1}{2} \cdot \color{blue}{\left(1 \cdot \log \left(\frac{1 + x}{1 - x}\right)\right)} \]

    metadata-eval [=>]8.7

    \[ \color{blue}{0.5} \cdot \left(1 \cdot \log \left(\frac{1 + x}{1 - x}\right)\right) \]

    *-lft-identity [=>]8.7

    \[ 0.5 \cdot \color{blue}{\log \left(\frac{1 + x}{1 - x}\right)} \]

    log-div [=>]8.7

    \[ 0.5 \cdot \color{blue}{\left(\log \left(1 + x\right) - \log \left(1 - x\right)\right)} \]

    log1p-def [=>]21.3

    \[ 0.5 \cdot \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log \left(1 - x\right)\right) \]

    sub-neg [=>]21.3

    \[ 0.5 \cdot \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(1 + \left(-x\right)\right)}\right) \]

    log1p-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy99.5%
Cost7040
\[0.5 \cdot \left(x \cdot 2 + 0.6666666666666666 \cdot {x}^{3}\right) \]
Alternative 2
Accuracy99.0%
Cost320
\[0.5 \cdot \left(x \cdot 2\right) \]

Error

Reproduce?

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