Average Error: 19.7 → 0.0
Time: 28.5s
Precision: 64
Internal Precision: 128
\[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
\[\sqrt[3]{\left(\frac{y + x}{\sqrt{x^2 + y^2}^*} \cdot \frac{x - y}{\sqrt{x^2 + y^2}^*}\right) \cdot \left(\left(\frac{y + x}{\sqrt{x^2 + y^2}^*} \cdot \frac{x - y}{\sqrt{x^2 + y^2}^*}\right) \cdot \left(\frac{y + x}{\sqrt{x^2 + y^2}^*} \cdot \frac{x - y}{\sqrt{x^2 + y^2}^*}\right)\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

Original19.7
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 19.7

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

    \[\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-sqrt19.8

    \[\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-frac19.8

    \[\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. Simplified19.8

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

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

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

Reproduce

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

sample58.0ms

Algorithm
intervals

simplify294.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 16.1b

localize16.0ms

Local error

Found 2 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
2 → 41
Calls

2 calls. Slowest were:

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

series54.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

36.0ms
(/ (* (- x y) (+ y x)) (fma x x (* y y)))
19.0ms
(fma x x (* y y))

simplify3.0s

Counts
28 → 47
Calls

28 calls. Slowest were:

554.0ms
(- (log (* (- x y) (+ y x))) (log (fma x x (* y y))))
342.0ms
(* (- (* x x) (* y y)) (+ y x))
311.0ms
(* (- (pow x 3) (pow y 3)) (+ y x))

prune438.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 3 expressions with local error:

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

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
3 → 111
Calls

3 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))

series204.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

79.0ms
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
77.0ms
(/ (+ x y) (hypot x y))
48.0ms
(/ (- x y) (hypot x y))

simplify3.3s

Counts
102 → 120
Calls

102 calls. Slowest were:

432.0ms
(* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y)))
322.0ms
(/ (* (* (+ x y) (+ x y)) (+ x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))
313.0ms
(+ (- (log (- x y)) (log (hypot x y))) (log (/ (+ x y) (hypot x y))))

prune1.2s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0b

localize14.0ms

Local error

Found 4 expressions with local error:

0.1b
(pow (/ (- x y) (hypot x y)) 3)
0.1b
(pow (/ (+ y x) (hypot x y)) 3)
0.0b
(/ (- x y) (hypot x y))
0.0b
(/ (+ y x) (hypot x y))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 151
Calls

4 calls. Slowest were:

3.0ms
(/ (+ y x) (hypot x y))
3.0ms
(pow (/ (- x y) (hypot x y)) 3)
3.0ms
(/ (- x y) (hypot x y))

series225.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(pow (/ (- x y) (hypot x y)) 3)
65.0ms
(pow (/ (+ y x) (hypot x y)) 3)
49.0ms
(/ (- x y) (hypot x y))
45.0ms
(/ (+ y x) (hypot x y))

simplify12.8s

Counts
131 → 163
Calls

131 calls. Slowest were:

958.0ms
(pow (/ 1 (* (cbrt (hypot x y)) (cbrt (hypot x y)))) 3)
876.0ms
(pow (/ 1 (* (cbrt (hypot x y)) (cbrt (hypot x y)))) 3)
860.0ms
(pow (/ 1 (* (cbrt (hypot x y)) (cbrt (hypot x y)))) 3)

prune1.9s

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
(/ (- x y) (hypot x y))
0.0b
(/ (- x y) (hypot x y))
0.0b
(/ (- x y) (hypot x y))
0.0b
(/ (+ x y) (hypot x y))

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 127
Calls

4 calls. Slowest were:

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

series176.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

45.0ms
(/ (- x y) (hypot x y))
44.0ms
(/ (- x y) (hypot x y))
44.0ms
(/ (- x y) (hypot x y))
43.0ms
(/ (+ x y) (hypot x y))

simplify1.2s

Counts
123 → 139
Calls

123 calls. Slowest were:

198.0ms
(/ (* (* (+ x y) (+ x y)) (+ x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))
111.0ms
(/ (* (* (- x y) (- x y)) (- x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))
91.0ms
(/ (* (* (- x y) (- x y)) (- x y)) (* (* (hypot x y) (hypot x y)) (hypot x y)))

prune1.4s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

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