?

Average Accuracy: 8.6% → 100.0%
Time: 9.3s
Precision: binary64
Cost: 13440

?

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

Error?

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 7.3%

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

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

    [Start]7.3

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

    metadata-eval [=>]7.3

    \[ \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right) \]
  3. Applied egg-rr7.3%

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

    [Start]7.3

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

    clear-num [=>]7.3

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

    clear-num [=>]7.3

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

    log-rec [=>]7.3

    \[ 0.5 \cdot \color{blue}{\left(-\log \left(\frac{\frac{1 - x}{1 + x}}{1}\right)\right)} \]
  4. Applied egg-rr100.0%

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

    [Start]7.3

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

    /-rgt-identity [=>]7.3

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

    flip-- [=>]7.3

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

    associate-/l/ [=>]7.3

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

    log-div [=>]7.3

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

    metadata-eval [=>]7.3

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

    sub-neg [=>]7.3

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

    log1p-def [=>]7.6

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

    pow2 [=>]7.6

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

    metadata-eval [<=]7.6

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

    log-pow [=>]7.6

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

    metadata-eval [=>]7.6

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

    log1p-udef [<=]100.0

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

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

Alternatives

Alternative 1
Accuracy100.0%
Cost13184
\[0.5 \cdot \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right) \]
Alternative 2
Accuracy99.5%
Cost7040
\[0.5 \cdot \left(x \cdot 2 + 0.6666666666666666 \cdot {x}^{3}\right) \]
Alternative 3
Accuracy98.9%
Cost320
\[0.5 \cdot \left(x \cdot 2\right) \]

Error

Reproduce?

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