| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 3552 |
\[\log \left(\left(\left(-1 - \frac{0.5}{x}\right) + \left(x - -1\right)\right) + x\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x)
:precision binary32
(-
(+ (log x) (log 2.0))
(+
(* 0.25 (/ 1.0 (pow x 2.0)))
(+
(* 0.09375 (/ 1.0 (pow x 4.0)))
(* 0.052083333333333336 (/ 1.0 (pow x 6.0)))))))float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return (logf(x) + logf(2.0f)) - ((0.25f * (1.0f / powf(x, 2.0f))) + ((0.09375f * (1.0f / powf(x, 4.0f))) + (0.052083333333333336f * (1.0f / powf(x, 6.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) + log(2.0e0)) - ((0.25e0 * (1.0e0 / (x ** 2.0e0))) + ((0.09375e0 * (1.0e0 / (x ** 4.0e0))) + (0.052083333333333336e0 * (1.0e0 / (x ** 6.0e0)))))
end function
function code(x) return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0))))) end
function code(x) return Float32(Float32(log(x) + log(Float32(2.0))) - Float32(Float32(Float32(0.25) * Float32(Float32(1.0) / (x ^ Float32(2.0)))) + Float32(Float32(Float32(0.09375) * Float32(Float32(1.0) / (x ^ Float32(4.0)))) + Float32(Float32(0.052083333333333336) * Float32(Float32(1.0) / (x ^ Float32(6.0))))))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) tmp = (log(x) + log(single(2.0))) - ((single(0.25) * (single(1.0) / (x ^ single(2.0)))) + ((single(0.09375) * (single(1.0) / (x ^ single(4.0)))) + (single(0.052083333333333336) * (single(1.0) / (x ^ single(6.0)))))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\left(\log x + \log 2\right) - \left(0.25 \cdot \frac{1}{{x}^{2}} + \left(0.09375 \cdot \frac{1}{{x}^{4}} + 0.052083333333333336 \cdot \frac{1}{{x}^{6}}\right)\right)
Results
| Original | 16.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.5 |
Initial program 16.0
Taylor expanded in x around inf 0.5
Simplified0.5
[Start]0.5 | \[ \left(-1 \cdot \log \left(\frac{1}{x}\right) + \log 2\right) - \left(0.09375 \cdot \frac{1}{{x}^{4}} + \left(0.052083333333333336 \cdot \frac{1}{{x}^{6}} + 0.25 \cdot \frac{1}{{x}^{2}}\right)\right)
\] |
|---|---|
rational.json-simplify-1 [<=]0.5 | \[ \color{blue}{\left(\log 2 + -1 \cdot \log \left(\frac{1}{x}\right)\right)} - \left(0.09375 \cdot \frac{1}{{x}^{4}} + \left(0.052083333333333336 \cdot \frac{1}{{x}^{6}} + 0.25 \cdot \frac{1}{{x}^{2}}\right)\right)
\] |
rational.json-simplify-2 [=>]0.5 | \[ \left(\log 2 + \color{blue}{\log \left(\frac{1}{x}\right) \cdot -1}\right) - \left(0.09375 \cdot \frac{1}{{x}^{4}} + \left(0.052083333333333336 \cdot \frac{1}{{x}^{6}} + 0.25 \cdot \frac{1}{{x}^{2}}\right)\right)
\] |
rational.json-simplify-9 [=>]0.5 | \[ \left(\log 2 + \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)}\right) - \left(0.09375 \cdot \frac{1}{{x}^{4}} + \left(0.052083333333333336 \cdot \frac{1}{{x}^{6}} + 0.25 \cdot \frac{1}{{x}^{2}}\right)\right)
\] |
rational.json-simplify-41 [<=]0.5 | \[ \left(\log 2 + \left(-\log \left(\frac{1}{x}\right)\right)\right) - \color{blue}{\left(0.25 \cdot \frac{1}{{x}^{2}} + \left(0.09375 \cdot \frac{1}{{x}^{4}} + 0.052083333333333336 \cdot \frac{1}{{x}^{6}}\right)\right)}
\] |
Taylor expanded in x around 0 0.5
Simplified0.5
[Start]0.5 | \[ \left(\log 2 - -1 \cdot \log x\right) - \left(0.25 \cdot \frac{1}{{x}^{2}} + \left(0.09375 \cdot \frac{1}{{x}^{4}} + 0.052083333333333336 \cdot \frac{1}{{x}^{6}}\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]0.5 | \[ \left(\log 2 - \color{blue}{\log x \cdot -1}\right) - \left(0.25 \cdot \frac{1}{{x}^{2}} + \left(0.09375 \cdot \frac{1}{{x}^{4}} + 0.052083333333333336 \cdot \frac{1}{{x}^{6}}\right)\right)
\] |
rational.json-simplify-9 [=>]0.5 | \[ \left(\log 2 - \color{blue}{\left(-\log x\right)}\right) - \left(0.25 \cdot \frac{1}{{x}^{2}} + \left(0.09375 \cdot \frac{1}{{x}^{4}} + 0.052083333333333336 \cdot \frac{1}{{x}^{6}}\right)\right)
\] |
Applied egg-rr0.5
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 3552 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 3424 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
herbie shell --seed 2023064
(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)))))