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

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.4
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.4

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

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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-cbrt-cube0.0

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

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

Reproduce

herbie shell --seed 2019008 +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: 21.2s)Debug log

sample29.0ms

Algorithm
intervals

simplify305.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune16.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.2b

localize41.0ms

Local error

Found 2 expressions with local error:

18.2b
(/ (* (- x y) (+ y x)) (fma x x (* y y)))
0.0b
(fma x x (* y y))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
2 → 41
Calls

2 calls. Slowest were:

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

series62.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

41.0ms
(/ (* (- x y) (+ y x)) (fma x x (* y y)))
21.0ms
(fma x x (* y y))

simplify2.8s

Counts
28 → 47
Calls

28 calls. Slowest were:

352.0ms
(* (- (* x x) (* y y)) (+ (pow y 3) (pow x 3)))
333.0ms
(* (- (* x x) (* y y)) (+ y x))
307.0ms
(* (- (pow x 3) (pow y 3)) (+ y x))

prune386.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 121
Calls

4 calls. Slowest were:

11.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))

series221.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
65.0ms
(/ (- x y) (hypot x y))
61.0ms
(/ (+ x y) (hypot x y))
29.0ms
(hypot x y)

simplify2.9s

Counts
105 → 133
Calls

105 calls. Slowest were:

323.0ms
(+ (- (log (- x y)) (log (hypot x y))) (- (log (+ x y)) (log (hypot x y))))
290.0ms
(/ (* (* (+ x y) (+ x y)) (+ x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))
261.0ms
(+ (- (log (- x y)) (log (hypot x y))) (log (/ (+ x y) (hypot x y))))

prune1.2s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize12.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 134
Calls

4 calls. Slowest were:

6.0ms
(* (/ 1 (/ (hypot x y) (- x y))) (/ (+ x y) (hypot x y)))
3.0ms
(/ (hypot x y) (- x y))
3.0ms
(/ (+ x y) (hypot x y))

series190.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

59.0ms
(/ (hypot x y) (- x y))
46.0ms
(* (/ 1 (/ (hypot x y) (- x y))) (/ (+ x y) (hypot x y)))
43.0ms
(/ (+ x y) (hypot x y))
41.0ms
(/ 1 (/ (hypot x y) (- x y)))

simplify2.6s

Counts
112 → 146
Calls

112 calls. Slowest were:

320.0ms
(/ (* (* (+ x y) (+ x y)) (+ x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))
278.0ms
(+ (log (/ 1 (/ (hypot x y) (- x y)))) (- (log (+ x y)) (log (hypot x y))))
208.0ms
(+ (log (/ 1 (/ (hypot x y) (- x y)))) (log (/ (+ x y) (hypot x y))))

prune1.3s

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

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

rewrite64.0ms

Algorithm
rewrite-expression-head
Counts
4 → 149
Calls

4 calls. Slowest were:

22.0ms
(* (/ 1 (cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y))))) (/ (+ x y) (hypot x y)))
17.0ms
(cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y))))
16.0ms
(* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y)))

series255.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

74.0ms
(* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y)))
65.0ms
(* (/ 1 (cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y))))) (/ (+ x y) (hypot x y)))
62.0ms
(/ (+ x y) (hypot x y))
53.0ms
(cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y))))

simplify5.5s

Counts
126 → 161
Calls

126 calls. Slowest were:

378.0ms
(+ (- (log (cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y)))))) (log (/ (+ x y) (hypot x y))))
375.0ms
(+ (- (log (cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y)))))) (- (log (+ x y)) (log (hypot x y))))
325.0ms
(sqrt (/ 1 (cbrt (* (* (/ (hypot x y) (- x y)) (/ (hypot x y) (- x y))) (/ (hypot x y) (- x y))))))

prune1.7s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

regimes55.0ms

Accuracy

0% (0.0b remaining)

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

bsearch2.0ms

end0.0ms

sample1.6s

Algorithm
intervals