Average Error: 26.0 → 26.0
Time: 27.5s
Precision: 64
Internal Precision: 128
\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.0
Target0.4
Herbie26.0
\[\begin{array}{l} \mathbf{if}\;\left|d\right| \lt \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array}\]

Derivation

  1. Initial program 26.0

    \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt26.0

    \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\]
  4. Applied associate-/r*25.9

    \[\leadsto \color{blue}{\frac{\frac{a \cdot c + b \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}}\]
  5. Using strategy rm
  6. Applied associate-/l/26.0

    \[\leadsto \color{blue}{\frac{a \cdot c + b \cdot d}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\]
  7. Using strategy rm
  8. Applied *-un-lft-identity26.0

    \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}\]
  9. Applied times-frac26.0

    \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{a \cdot c + b \cdot d}{\sqrt{c \cdot c + d \cdot d}}}\]
  10. Final simplification26.0

    \[\leadsto \frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}\]

Reproduce

herbie shell --seed 2019008 
(FPCore (a b c d)
  :name "Complex division, real part"

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))

  (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))

Details

Time bar (total: 26.8s)Debug log

sample48.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

5.0ms
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.3b

localize39.0ms

Local error

Found 3 expressions with local error:

28.3b
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
0.0b
(+ (* c c) (* d d))
0.0b
(+ (* a c) (* b d))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
3 → 53
Calls

3 calls. Slowest were:

10.0ms
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
2.0ms
(+ (* c c) (* d d))
2.0ms
(+ (* a c) (* b d))

series144.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

89.0ms
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
30.0ms
(+ (* c c) (* d d))
25.0ms
(+ (* a c) (* b d))

simplify810.0ms

Counts
40 → 62
Calls

40 calls. Slowest were:

203.0ms
(- (* (* a c) (* a c)) (* (* b d) (* b d)))
154.0ms
(+ (* (* c c) (* c c)) (- (* (* d d) (* d d)) (* (* c c) (* d d))))
118.0ms
(/ (* (* (+ (* a c) (* b d)) (+ (* a c) (* b d))) (+ (* a c) (* b d))) (* (* (+ (* c c) (* d d)) (+ (* c c) (* d d))) (+ (* c c) (* d d))))

prune622.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 27.8b

localize17.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (+ (* c c) (* d d)))
30.6b
(sqrt (+ (* c c) (* d d)))
17.2b
(/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))
0.1b
(/ (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))) (sqrt (+ (* c c) (* d d))))

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 262
Calls

4 calls. Slowest were:

18.0ms
(/ (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))) (sqrt (+ (* c c) (* d d))))
17.0ms
(/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))
4.0ms
(sqrt (+ (* c c) (* d d)))

series177.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

75.0ms
(/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))
59.0ms
(/ (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))) (sqrt (+ (* c c) (* d d))))
23.0ms
(sqrt (+ (* c c) (* d d)))
19.0ms
(sqrt (+ (* c c) (* d d)))

simplify11.1s

Counts
398 → 274
Calls

398 calls. Slowest were:

261.0ms
(- (* (* a c) (* a c)) (* (* b d) (* b d)))
252.0ms
(/ (/ (* (cbrt (+ (* a c) (* b d))) (cbrt (+ (* a c) (* b d)))) (* (cbrt (sqrt (+ (* c c) (* d d)))) (cbrt (sqrt (+ (* c c) (* d d)))))) 1)
236.0ms
(/ (/ (* (cbrt (+ (* a c) (* b d))) (cbrt (+ (* a c) (* b d)))) (sqrt 1)) (* (cbrt (sqrt (+ (* c c) (* d d)))) (cbrt (sqrt (+ (* c c) (* d d))))))

prune4.2s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 25.1b

localize13.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (+ (* c c) (* d d)))
30.6b
(sqrt (+ (* c c) (* d d)))
28.3b
(/ (+ (* a c) (* b d)) (* (sqrt (+ (* c c) (* d d))) (sqrt (+ (* c c) (* d d)))))
0.0b
(+ (* c c) (* d d))

rewrite28.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

15.0ms
(/ (+ (* a c) (* b d)) (* (sqrt (+ (* c c) (* d d))) (sqrt (+ (* c c) (* d d)))))
5.0ms
(+ (* c c) (* d d))
4.0ms
(sqrt (+ (* c c) (* d d)))

series136.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

65.0ms
(/ (+ (* a c) (* b d)) (* (sqrt (+ (* c c) (* d d))) (sqrt (+ (* c c) (* d d)))))
25.0ms
(+ (* c c) (* d d))
25.0ms
(sqrt (+ (* c c) (* d d)))
20.0ms
(sqrt (+ (* c c) (* d d)))

simplify2.3s

Counts
48 → 82
Calls

48 calls. Slowest were:

211.0ms
(- (* (* a c) (* a c)) (* (* b d) (* b d)))
198.0ms
(* (sqrt (+ (* (* c c) (* c c)) (- (* (* d d) (* d d)) (* (* c c) (* d d))))) (sqrt (- (* c c) (* d d))))
189.0ms
(* (sqrt (- (* c c) (* d d))) (sqrt (+ (* (* c c) (* c c)) (- (* (* d d) (* d d)) (* (* c c) (* d d))))))

prune994.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 25.1b

localize7.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (+ (* c c) (* d d)))
30.6b
(sqrt (+ (* c c) (* d d)))
17.2b
(/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))
0.2b
(* (/ 1 (sqrt (+ (* c c) (* d d)))) (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))))

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 119
Calls

4 calls. Slowest were:

23.0ms
(* (/ 1 (sqrt (+ (* c c) (* d d)))) (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))))
17.0ms
(/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))
2.0ms
(sqrt (+ (* c c) (* d d)))

series216.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

90.0ms
(/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))
79.0ms
(* (/ 1 (sqrt (+ (* c c) (* d d)))) (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))))
27.0ms
(sqrt (+ (* c c) (* d d)))
19.0ms
(sqrt (+ (* c c) (* d d)))

simplify3.1s

Counts
113 → 131
Calls

113 calls. Slowest were:

618.0ms
(* (* (* (/ 1 (sqrt (+ (* c c) (* d d)))) (/ 1 (sqrt (+ (* c c) (* d d))))) (/ 1 (sqrt (+ (* c c) (* d d))))) (* (* (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))) (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))) (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d))))))
262.0ms
(* (/ 1 (sqrt (+ (* c c) (* d d)))) (/ (+ (* a c) (* b d)) (sqrt (+ (* c c) (* d d)))))
201.0ms
(- (* (* a c) (* a c)) (* (* b d) (* b d)))

prune1.2s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 25.1b

regimes198.0ms

Accuracy

0% (2.6b remaining)

Error of 26.0b against oracle of 23.4b and baseline of 26.0b

bsearch3.0ms

end0.0ms

sample1.4s

Algorithm
intervals