Average Error: 37.1 → 12.9
Time: 14.0s
Precision: 64
Internal Precision: 128
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}\]
\[\sqrt{\left(\sqrt{re^2 + im^2}^* - re\right) \cdot 2.0} \cdot 0.5\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 37.1

    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}\]
  2. Simplified12.9

    \[\leadsto \color{blue}{0.5 \cdot \sqrt{\left(\sqrt{re^2 + im^2}^* - re\right) \cdot 2.0}}\]
  3. Final simplification12.9

    \[\leadsto \sqrt{\left(\sqrt{re^2 + im^2}^* - re\right) \cdot 2.0} \cdot 0.5\]

Reproduce

herbie shell --seed 2019002 +o rules:numerics
(FPCore (re im)
  :name "math.sqrt on complex, imaginary part, im greater than 0 branch"
  (* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))

Details

Time bar (total: 12.4s)Debug log

sample137.0ms

Algorithm
intervals

simplify81.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

81.0ms
(* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re))))

prune25.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 13.5b

localize16.0ms

Local error

Found 3 expressions with local error:

1.0b
(- (hypot re im) re)
0.0b
(sqrt (* (- (hypot re im) re) 2.0))
0.0b
(hypot re im)

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
3 → 39
Calls

3 calls. Slowest were:

5.0ms
(- (hypot re im) re)
3.0ms
(sqrt (* (- (hypot re im) re) 2.0))
0.0ms
(hypot re im)

series209.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

119.0ms
(sqrt (* (- (hypot re im) re) 2.0))
57.0ms
(- (hypot re im) re)
33.0ms
(hypot re im)

simplify338.0ms

Counts
14 → 48
Calls

14 calls. Slowest were:

243.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
77.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
6.0ms
(sqrt (- (hypot re im) re))

prune518.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 13.2b

localize14.0ms

Local error

Found 4 expressions with local error:

1.0b
(- (hypot re im) re)
1.0b
(- (hypot re im) re)
0.4b
(* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re)))
0.0b
(sqrt (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) 2.0))

rewrite39.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

17.0ms
(sqrt (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) 2.0))
12.0ms
(* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re)))
4.0ms
(- (hypot re im) re)

series262.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

118.0ms
(sqrt (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) 2.0))
49.0ms
(- (hypot re im) re)
49.0ms
(- (hypot re im) re)
46.0ms
(* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re)))

simplify2.4s

Counts
59 → 103
Calls

59 calls. Slowest were:

450.0ms
(* (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) (sqrt (- (hypot re im) re))) (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) (sqrt (- (hypot re im) re))))
223.0ms
(sqrt (* (* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt (- (hypot re im) re))) 2.0))
205.0ms
(sqrt (* (* (sqrt (- (hypot re im) re)) (sqrt (- (* (hypot re im) (hypot re im)) (* re re)))) 2.0))

prune1.2s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 13.2b

localize48.0ms

Local error

Found 4 expressions with local error:

15.3b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
1.0b
(- (hypot re im) re)
0.4b
(* (sqrt (- (hypot re im) re)) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
0.0b
(sqrt (hypot re im))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

17.0ms
(* (sqrt (- (hypot re im) re)) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
7.0ms
(- (hypot re im) re)
2.0ms
(sqrt (hypot re im))

series461.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

294.0ms
(* (sqrt (- (hypot re im) re)) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
74.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
56.0ms
(sqrt (hypot re im))
36.0ms
(- (hypot re im) re)

simplify732.0ms

Counts
36 → 81
Calls

36 calls. Slowest were:

214.0ms
(* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
186.0ms
(* (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) (sqrt (- (hypot re im) re))) (* (* (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))))
80.0ms
(* (- (hypot re im) re) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))

prune1.1s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 13.2b

localize40.0ms

Local error

Found 4 expressions with local error:

15.3b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
15.3b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
1.0b
(- (hypot re im) re)
1.0b
(- (hypot re im) re)

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

7.0ms
(- (hypot re im) re)
6.0ms
(- (hypot re im) re)
0.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))

series256.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

102.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
86.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
38.0ms
(- (hypot re im) re)
30.0ms
(- (hypot re im) re)

simplify16.0ms

Counts
16 → 64
Calls

16 calls. Slowest were:

2.0ms
(- im re)
1.0ms
(- im re)
1.0ms
(- im re)

prune1.1s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 13.2b

regimes212.0ms

Accuracy

0% (0.2b remaining)

Error of 12.9b against oracle of 12.6b and baseline of 12.9b

bsearch1.0ms

end0.0ms

sample3.1s

Algorithm
intervals