Average Error: 20.0 → 0.0
Time: 19.5s
Precision: 64
Internal Precision: 128
\[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
\[\log \left(e^{\frac{x + y}{\sqrt{x^2 + y^2}^*}}\right) \cdot \frac{1}{\frac{\sqrt{x^2 + y^2}^*}{x - y}}\]

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.0
Target0.1
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;0.5 \lt \left|\frac{x}{y}\right| \lt 2:\\ \;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{2}{1 + \frac{x}{y} \cdot \frac{x}{y}}\\ \end{array}\]

Derivation

  1. Initial program 20.0

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Simplified20.0

    \[\leadsto \color{blue}{\frac{\left(x - y\right) \cdot \left(y + x\right)}{(x \cdot x + \left(y \cdot y\right))_*}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt20.0

    \[\leadsto \frac{\left(x - y\right) \cdot \left(y + x\right)}{\color{blue}{\sqrt{(x \cdot x + \left(y \cdot y\right))_*} \cdot \sqrt{(x \cdot x + \left(y \cdot y\right))_*}}}\]
  5. Applied times-frac20.0

    \[\leadsto \color{blue}{\frac{x - y}{\sqrt{(x \cdot x + \left(y \cdot y\right))_*}} \cdot \frac{y + x}{\sqrt{(x \cdot x + \left(y \cdot y\right))_*}}}\]
  6. Simplified20.0

    \[\leadsto \color{blue}{\frac{x - y}{\sqrt{x^2 + y^2}^*}} \cdot \frac{y + x}{\sqrt{(x \cdot x + \left(y \cdot y\right))_*}}\]
  7. Simplified0.0

    \[\leadsto \frac{x - y}{\sqrt{x^2 + y^2}^*} \cdot \color{blue}{\frac{x + y}{\sqrt{x^2 + y^2}^*}}\]
  8. Using strategy rm
  9. Applied clear-num0.0

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x^2 + y^2}^*}{x - y}}} \cdot \frac{x + y}{\sqrt{x^2 + y^2}^*}\]
  10. Using strategy rm
  11. Applied add-log-exp0.0

    \[\leadsto \frac{1}{\frac{\sqrt{x^2 + y^2}^*}{x - y}} \cdot \color{blue}{\log \left(e^{\frac{x + y}{\sqrt{x^2 + y^2}^*}}\right)}\]
  12. Final simplification0.0

    \[\leadsto \log \left(e^{\frac{x + y}{\sqrt{x^2 + y^2}^*}}\right) \cdot \frac{1}{\frac{\sqrt{x^2 + y^2}^*}{x - y}}\]

Reproduce

herbie shell --seed 2019004 +o rules:numerics
(FPCore (x y)
  :name "Kahan p9 Example"
  :pre (and (< 0 x 1) (< y 1))

  :herbie-target
  (if (< 0.5 (fabs (/ x y)) 2) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1 (/ 2 (+ 1 (* (/ x y) (/ x y))))))

  (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))

Details

Time bar (total: 18.9s)Debug log

sample54.0ms

Algorithm
intervals

simplify344.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

344.0ms
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y)))

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 23.5b

localize43.0ms

Local error

Found 1 expressions with local error:

23.5b
(/ (* (- x y) (+ y x)) (fma x x (* y y)))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
1 → 31
Calls

1 calls. Slowest were:

14.0ms
(/ (* (- x y) (+ y x)) (fma x x (* y y)))

series60.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

60.0ms
(/ (* (- x y) (+ y x)) (fma x x (* y y)))

simplify2.7s

Counts
25 → 34
Calls

25 calls. Slowest were:

317.0ms
(* (- (* x x) (* y y)) (+ y x))
308.0ms
(* (- (* x x) (* y y)) (- (* y y) (* x x)))
296.0ms
(* (- (pow x 3) (pow y 3)) (+ y x))

prune292.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 4 expressions with local error:

0.0b
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
0.0b
(/ (+ x y) (hypot x y))
0.0b
(/ (- x y) (hypot x y))
0.0b
(hypot x y)

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 121
Calls

4 calls. Slowest were:

7.0ms
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
3.0ms
(/ (+ x y) (hypot x y))
3.0ms
(/ (- x y) (hypot x y))

series203.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

56.0ms
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
54.0ms
(/ (+ x y) (hypot x y))
54.0ms
(/ (- x y) (hypot x y))
39.0ms
(hypot x y)

simplify3.0s

Counts
105 → 133
Calls

105 calls. Slowest were:

307.0ms
(/ (* (* (+ x y) (+ x y)) (+ x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))
303.0ms
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
297.0ms
(+ (- (log (- x y)) (log (hypot x y))) (- (log (+ x y)) (log (hypot x y))))

prune1.2s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0b

localize21.0ms

Local error

Found 4 expressions with local error:

0.0b
(* (/ 1 (/ (hypot x y) (- x y))) (/ (+ x y) (hypot x y)))
0.0b
(/ 1 (/ (hypot x y) (- x y)))
0.0b
(/ (+ x y) (hypot x y))
0.0b
(/ (hypot x y) (- x y))

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 134
Calls

4 calls. Slowest were:

13.0ms
(* (/ 1 (/ (hypot x y) (- x y))) (/ (+ x y) (hypot x y)))
7.0ms
(/ (hypot x y) (- x y))
7.0ms
(/ (+ x y) (hypot x y))

series232.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(/ (hypot x y) (- x y))
67.0ms
(/ 1 (/ (hypot x y) (- x y)))
52.0ms
(* (/ 1 (/ (hypot x y) (- x y))) (/ (+ x y) (hypot x y)))
41.0ms
(/ (+ x y) (hypot x y))

simplify3.0s

Counts
112 → 146
Calls

112 calls. Slowest were:

294.0ms
(+ (log (/ 1 (/ (hypot x y) (- x y)))) (- (log (+ x y)) (log (hypot x y))))
290.0ms
(/ (+ x y) (sqrt (hypot x y)))
230.0ms
(+ (log (/ 1 (/ (hypot x y) (- x y)))) (log (/ (+ x y) (hypot x y))))

prune1.5s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize9.0ms

Local error

Found 4 expressions with local error:

0.0b
(* (/ 1 (/ (hypot x y) (- x y))) (log (exp (/ (+ x y) (hypot x y)))))
0.0b
(/ 1 (/ (hypot x y) (- x y)))
0.0b
(log (exp (/ (+ x y) (hypot x y))))
0.0b
(exp (/ (+ x y) (hypot x y)))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 126
Calls

4 calls. Slowest were:

11.0ms
(* (/ 1 (/ (hypot x y) (- x y))) (log (exp (/ (+ x y) (hypot x y)))))
4.0ms
(log (exp (/ (+ x y) (hypot x y))))
3.0ms
(exp (/ (+ x y) (hypot x y)))

series260.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

84.0ms
(exp (/ (+ x y) (hypot x y)))
71.0ms
(* (/ 1 (/ (hypot x y) (- x y))) (log (exp (/ (+ x y) (hypot x y)))))
53.0ms
(log (exp (/ (+ x y) (hypot x y))))
53.0ms
(/ 1 (/ (hypot x y) (- x y)))

simplify2.8s

Counts
92 → 138
Calls

92 calls. Slowest were:

402.0ms
(* (log (sqrt (exp (/ (+ x y) (hypot x y))))) (/ 1 (/ (hypot x y) (- x y))))
371.0ms
(* (log (cbrt (exp (/ (+ x y) (hypot x y))))) (/ 1 (/ (hypot x y) (- x y))))
302.0ms
(+ (log (/ 1 (/ (hypot x y) (- x y)))) (log (log (exp (/ (+ x y) (hypot x y))))))

prune1.5s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

regimes116.0ms

Accuracy

0% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 0.0b

bsearch3.0ms

end0.0ms

sample1.5s

Algorithm
intervals