Average Error: 37.8 → 13.2
Time: 11.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.8

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

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

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

Reproduce

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

sample138.0ms

Algorithm
intervals

simplify36.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune35.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 14.2b

localize18.0ms

Local error

Found 3 expressions with local error:

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

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
3 → 39
Calls

3 calls. Slowest were:

10.0ms
(- (hypot re im) re)
6.0ms
(sqrt (* (- (hypot re im) re) 2.0))
0.0ms
(hypot re im)

series221.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

122.0ms
(sqrt (* (- (hypot re im) re) 2.0))
52.0ms
(- (hypot re im) re)
46.0ms
(hypot re im)

simplify304.0ms

Counts
14 → 48
Calls

14 calls. Slowest were:

203.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
87.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
4.0ms
(sqrt (- (hypot re im) re))

prune437.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 14.0b

localize20.0ms

Local error

Found 4 expressions with local error:

16.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.0b
(hypot re im)
0.0b
(hypot re im)
0.0b
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
4 → 41
Calls

4 calls. Slowest were:

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

series299.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

128.0ms
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))
95.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
41.0ms
(hypot re im)
34.0ms
(hypot re im)

simplify23.0ms

Counts
13 → 53
Calls

13 calls. Slowest were:

9.0ms
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
3.0ms
(- im re)
3.0ms
(* -1 re)

prune721.0ms

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 14.0b

localize48.0ms

Local error

Found 4 expressions with local error:

16.4b
(fma (sqrt (hypot re im)) (sqrt (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (cbrt (hypot re im)))) (- re))
0.6b
(cbrt (hypot re im))
0.6b
(cbrt (hypot re im))
0.6b
(cbrt (hypot re im))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

1.0ms
(cbrt (hypot re im))
1.0ms
(cbrt (hypot re im))
1.0ms
(cbrt (hypot re im))

series433.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

129.0ms
(cbrt (hypot re im))
119.0ms
(cbrt (hypot re im))
100.0ms
(cbrt (hypot re im))
85.0ms
(fma (sqrt (hypot re im)) (sqrt (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (cbrt (hypot re im)))) (- re))

simplify146.0ms

Counts
21 → 61
Calls

21 calls. Slowest were:

48.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))
29.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))
29.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))

prune867.0ms

Pruning

17 alts after pruning (16 fresh and 1 done)

Merged error: 13.9b

localize41.0ms

Local error

Found 4 expressions with local error:

16.4b
(fma (sqrt (hypot re im)) (sqrt (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (* (sqrt (cbrt (hypot re im))) (sqrt (cbrt (hypot re im)))))) (- re))
0.6b
(cbrt (hypot re im))
0.6b
(cbrt (hypot re im))
0.6b
(cbrt (hypot re im))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

1.0ms
(cbrt (hypot re im))
1.0ms
(cbrt (hypot re im))
1.0ms
(cbrt (hypot re im))

series455.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

125.0ms
(cbrt (hypot re im))
125.0ms
(cbrt (hypot re im))
116.0ms
(cbrt (hypot re im))
89.0ms
(fma (sqrt (hypot re im)) (sqrt (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (* (sqrt (cbrt (hypot re im))) (sqrt (cbrt (hypot re im)))))) (- re))

simplify136.0ms

Counts
21 → 61
Calls

21 calls. Slowest were:

42.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))
33.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))
30.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))

prune952.0ms

Pruning

17 alts after pruning (16 fresh and 1 done)

Merged error: 13.9b

regimes358.0ms

Accuracy

0% (0.2b remaining)

Error of 13.2b against oracle of 13.0b and baseline of 13.2b

bsearch1.0ms

end0.0ms

sample3.0s

Algorithm
intervals