Average Error: 16.1 → 0.4
Time: 6.9s
Precision: binary32
Cost: 7040
\[x \geq 1\]
\[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
\[\log \left(x \cdot 2 - \left(\frac{0.5}{x} + \left(\frac{\frac{\frac{0.125}{x}}{x}}{x} + \frac{0.0625}{{x}^{5}}\right)\right)\right) \]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x)
 :precision binary32
 (log
  (-
   (* x 2.0)
   (+ (/ 0.5 x) (+ (/ (/ (/ 0.125 x) x) x) (/ 0.0625 (pow x 5.0)))))))
float code(float x) {
	return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
	return logf(((x * 2.0f) - ((0.5f / x) + ((((0.125f / x) / x) / x) + (0.0625f / powf(x, 5.0f))))));
}
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 * 2.0e0) - ((0.5e0 / x) + ((((0.125e0 / x) / x) / x) + (0.0625e0 / (x ** 5.0e0))))))
end function
function code(x)
	return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0)))))
end
function code(x)
	return log(Float32(Float32(x * Float32(2.0)) - Float32(Float32(Float32(0.5) / x) + Float32(Float32(Float32(Float32(Float32(0.125) / x) / x) / x) + Float32(Float32(0.0625) / (x ^ Float32(5.0)))))))
end
function tmp = code(x)
	tmp = log((x + sqrt(((x * x) - single(1.0)))));
end
function tmp = code(x)
	tmp = log(((x * single(2.0)) - ((single(0.5) / x) + ((((single(0.125) / x) / x) / x) + (single(0.0625) / (x ^ single(5.0)))))));
end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x \cdot 2 - \left(\frac{0.5}{x} + \left(\frac{\frac{\frac{0.125}{x}}{x}}{x} + \frac{0.0625}{{x}^{5}}\right)\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.1
Target0.2
Herbie0.4
\[\log \left(x + \sqrt{x - 1} \cdot \sqrt{x + 1}\right) \]

Derivation

  1. Initial program 16.1

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

    \[\leadsto \log \color{blue}{\left(2 \cdot x - \left(0.5 \cdot \frac{1}{x} + \left(0.0625 \cdot \frac{1}{{x}^{5}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)} \]
  3. Simplified0.4

    \[\leadsto \log \color{blue}{\left(x \cdot 2 - \left(\frac{0.5}{x} + \left(\frac{0.125}{{x}^{3}} + \frac{0.0625}{{x}^{5}}\right)\right)\right)} \]
    Proof
    (-.f32 (*.f32 x 2) (+.f32 (/.f32 1/2 x) (+.f32 (/.f32 1/8 (pow.f32 x 3)) (/.f32 1/16 (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (Rewrite<= *-commutative_binary32 (*.f32 2 x)) (+.f32 (/.f32 1/2 x) (+.f32 (/.f32 1/8 (pow.f32 x 3)) (/.f32 1/16 (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (/.f32 (Rewrite<= metadata-eval (*.f32 1/2 1)) x) (+.f32 (/.f32 1/8 (pow.f32 x 3)) (/.f32 1/16 (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (Rewrite<= associate-*r/_binary32 (*.f32 1/2 (/.f32 1 x))) (+.f32 (/.f32 1/8 (pow.f32 x 3)) (/.f32 1/16 (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (*.f32 1/2 (/.f32 1 x)) (+.f32 (/.f32 (Rewrite<= metadata-eval (*.f32 1/8 1)) (pow.f32 x 3)) (/.f32 1/16 (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (*.f32 1/2 (/.f32 1 x)) (+.f32 (Rewrite<= associate-*r/_binary32 (*.f32 1/8 (/.f32 1 (pow.f32 x 3)))) (/.f32 1/16 (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (*.f32 1/2 (/.f32 1 x)) (+.f32 (*.f32 1/8 (/.f32 1 (pow.f32 x 3))) (/.f32 (Rewrite<= metadata-eval (*.f32 1/16 1)) (pow.f32 x 5))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (*.f32 1/2 (/.f32 1 x)) (+.f32 (*.f32 1/8 (/.f32 1 (pow.f32 x 3))) (Rewrite<= associate-*r/_binary32 (*.f32 1/16 (/.f32 1 (pow.f32 x 5))))))): 0 points increase in error, 0 points decrease in error
    (-.f32 (*.f32 2 x) (+.f32 (*.f32 1/2 (/.f32 1 x)) (Rewrite<= +-commutative_binary32 (+.f32 (*.f32 1/16 (/.f32 1 (pow.f32 x 5))) (*.f32 1/8 (/.f32 1 (pow.f32 x 3))))))): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr0.4

    \[\leadsto \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \left(\color{blue}{\frac{0.5}{x} \cdot \frac{0.25}{x \cdot x}} + \frac{0.0625}{{x}^{5}}\right)\right)\right) \]
  5. Applied egg-rr0.4

    \[\leadsto \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \left(\color{blue}{\frac{\frac{\frac{0.125}{x}}{x}}{x}} + \frac{0.0625}{{x}^{5}}\right)\right)\right) \]
  6. Final simplification0.4

    \[\leadsto \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \left(\frac{\frac{\frac{0.125}{x}}{x}}{x} + \frac{0.0625}{{x}^{5}}\right)\right)\right) \]

Alternatives

Alternative 1
Error0.4
Cost3680
\[\log \left(x \cdot 2 + \frac{\frac{-0.25}{x} - x}{x \cdot \left(x + x\right)}\right) \]
Alternative 2
Error0.6
Cost3424
\[\log \left(x + \left(x + \frac{-0.5}{x}\right)\right) \]
Alternative 3
Error0.6
Cost3424
\[\log \left(x \cdot 2 + \frac{-0.5}{x}\right) \]
Alternative 4
Error0.7
Cost3328
\[-\log \left(\frac{0.5}{x}\right) \]
Alternative 5
Error1.0
Cost3296
\[\log \left(x + x\right) \]
Alternative 6
Error30.0
Cost32
\[0 \]

Error

Reproduce

herbie shell --seed 2022329 
(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)))))