Average Error: 37.7 → 13.0
Time: 11.6s
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.7

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

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

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

Reproduce

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

start241.0ms

Algorithm
intervals

setup184.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 12.9b

localize71.0ms

Local error

Found 2 expressions with local error:

0.9b
(- (hypot re im) re)
0.0b
(hypot re im)

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
2 → 26
Calls

2 calls. Slowest were:

9.0ms
(- (hypot re im) re)
0.0ms
(hypot re im)

series170.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

129.0ms
(- (hypot re im) re)
40.0ms
(hypot re im)

simplify11.0ms

Counts
8 → 32
Calls

8 calls. Slowest were:

2.0ms
(* -2 re)
2.0ms
(- im re)
1.0ms
(* -1 re)

prune582.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 12.7b

localize21.0ms

Local error

Found 4 expressions with local error:

14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.0b
(hypot re im)
0.0b
(hypot re im)
0.0b
(sqrt (hypot re im))

rewrite2.0ms

Algorithm
rewrite-expression-head
Counts
4 → 44
Calls

4 calls. Slowest were:

1.0ms
(sqrt (hypot re im))
0.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.0ms
(hypot re im)

series245.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

100.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
69.0ms
(sqrt (hypot re im))
39.0ms
(hypot re im)
37.0ms
(hypot re im)

simplify17.0ms

Counts
16 → 56
Calls

16 calls. Slowest were:

4.0ms
(sqrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
2.0ms
(sqrt 1)
1.0ms
(- im re)

prune703.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 12.7b

localize27.0ms

Local error

Found 4 expressions with local error:

14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.5b
(* (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
0.0b
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 66
Calls

4 calls. Slowest were:

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

series414.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

111.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
106.0ms
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
102.0ms
(* (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
94.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))

simplify657.0ms

Counts
39 → 78
Calls

39 calls. Slowest were:

361.0ms
(* (* (* (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)))) (* (* (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)))))
70.0ms
(* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
46.0ms
(* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))

prune1.1s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 12.7b

localize37.0ms

Local error

Found 4 expressions with local error:

14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.5b
(cbrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
4 → 43
Calls

4 calls. Slowest were:

1.0ms
(cbrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
0.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))

series332.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

115.0ms
(cbrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
75.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
71.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
71.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))

simplify259.0ms

Counts
15 → 55
Calls

15 calls. Slowest were:

233.0ms
(- (+ (* 1/18 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3)) (* 1/3 (* re (pow (/ 1 (pow im 2)) 1/3))))
6.0ms
(cbrt (* (cbrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (cbrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))))
5.0ms
(cbrt (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))

prune693.0ms

Pruning

14 alts after pruning (13 fresh and 1 done)

Merged error: 12.7b

regimes236.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms