?

Average Error: 50.37% → 1.59%
Time: 6.9s
Precision: binary32
Cost: 3424

?

\[x \geq 1\]
\[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
\[\log \left(x + \left(x + \frac{-0.5}{x}\right)\right) \]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (+ x (+ x (/ -0.5 x)))))
float code(float x) {
	return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
	return logf((x + (x + (-0.5f / x))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = log((x + sqrt(((x * x) - 1.0e0))))
end function
real(4) function code(x)
    real(4), intent (in) :: x
    code = log((x + (x + ((-0.5e0) / x))))
end function
function code(x)
	return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0)))))
end
function code(x)
	return log(Float32(x + Float32(x + Float32(Float32(-0.5) / x))))
end
function tmp = code(x)
	tmp = log((x + sqrt(((x * x) - single(1.0)))));
end
function tmp = code(x)
	tmp = log((x + (x + (single(-0.5) / x))));
end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x + \left(x + \frac{-0.5}{x}\right)\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original50.37%
Target0.61%
Herbie1.59%
\[\log \left(x + \sqrt{x - 1} \cdot \sqrt{x + 1}\right) \]

Derivation?

  1. Initial program 50.37

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

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

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

    [Start]1.59

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

    associate-*r/ [=>]1.59

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

    metadata-eval [=>]1.59

    \[ \log \left(x + \left(x - \frac{\color{blue}{0.5}}{x}\right)\right) \]
  4. Final simplification1.59

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

Alternatives

Alternative 1
Error2.36%
Cost3328
\[-\log \left(\frac{0.5}{x}\right) \]
Alternative 2
Error2.91%
Cost3296
\[\log \left(x + x\right) \]
Alternative 3
Error55.81%
Cost3232
\[\log x \]
Alternative 4
Error93.89%
Cost32
\[0 \]

Error

Reproduce?

herbie shell --seed 2023121 
(FPCore (x)
  :name "Rust f32::acosh"
  :precision binary32
  :pre (>= x 1.0)

  :herbie-target
  (log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0)))))

  (log (+ x (sqrt (- (* x x) 1.0)))))