Average Error: 36.9 → 13.0
Time: 14.9s
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 36.9

    \[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 2018365 +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: 9.7s)Debug log

start250.0ms

Algorithm
intervals

setup94.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 12.7b

localize32.0ms

Local error

Found 2 expressions with local error:

0.5b
(- (hypot re im) re)
0.2b
(sqrt (* (- (hypot re im) re) 2.0))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
2 → 29
Calls

2 calls. Slowest were:

8.0ms
(- (hypot re im) re)
5.0ms
(sqrt (* (- (hypot re im) re) 2.0))

series654.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

581.0ms
(sqrt (* (- (hypot re im) re) 2.0))
73.0ms
(- (hypot re im) re)

simplify271.0ms

Counts
11 → 35
Calls

11 calls. Slowest were:

181.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
80.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
3.0ms
(sqrt (- (hypot re im) re))

prune438.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 12.4b

localize16.0ms

Local error

Found 3 expressions with local error:

0.5b
(- (hypot re im) re)
0.3b
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
0.0b
(sqrt (- (hypot re im) re))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
3 → 58
Calls

3 calls. Slowest were:

7.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
4.0ms
(- (hypot re im) re)
4.0ms
(sqrt (- (hypot re im) re))

series222.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

120.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
71.0ms
(sqrt (- (hypot re im) re))
30.0ms
(- (hypot re im) re)

simplify830.0ms

Counts
32 → 67
Calls

32 calls. Slowest were:

375.0ms
(* (* (* (sqrt (- (hypot re im) re)) (sqrt (- (hypot re im) re))) (sqrt (- (hypot re im) re))) (* (* (sqrt 2.0) (sqrt 2.0)) (sqrt 2.0)))
160.0ms
(* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt 2.0))
141.0ms
(sqrt (- (* (hypot re im) (hypot re im)) (* re re)))

prune838.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 12.4b

localize11.0ms

Local error

Found 4 expressions with local error:

0.5b
(- (hypot re im) re)
0.5b
(- (hypot re im) re)
0.4b
(* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re))))
0.3b
(* (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re)))) (sqrt 2.0))

rewrite48.0ms

Algorithm
rewrite-expression-head
Counts
4 → 108
Calls

4 calls. Slowest were:

28.0ms
(* (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re)))) (sqrt 2.0))
12.0ms
(* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re))))
3.0ms
(- (hypot re im) re)

series260.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

110.0ms
(* (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re)))) (sqrt 2.0))
88.0ms
(* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re))))
31.0ms
(- (hypot re im) re)
30.0ms
(- (hypot re im) re)

simplify2.5s

Counts
76 → 120
Calls

76 calls. Slowest were:

388.0ms
(* (* (* (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re)))) (sqrt (sqrt (- (hypot re im) re)))) (* (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re)))) (sqrt (sqrt (- (hypot re im) re))))) (* (* (sqrt 2.0) (sqrt 2.0)) (sqrt 2.0)))
231.0ms
(* (* (sqrt (sqrt (- (* (hypot re im) (hypot re im)) (* re re)))) (sqrt (sqrt (- (hypot re im) re)))) (sqrt 2.0))
202.0ms
(* (* (* (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re)))) (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re))))) (* (sqrt (sqrt (- (hypot re im) re))) (sqrt (sqrt (- (hypot re im) re))))) (* (* (sqrt 2.0) (sqrt 2.0)) (sqrt 2.0)))

prune1.8s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 12.3b

localize31.0ms

Local error

Found 4 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

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

series363.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

146.0ms
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))
105.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
56.0ms
(sqrt (hypot re im))
55.0ms
(sqrt (hypot re im))

simplify21.0ms

Counts
21 → 61
Calls

21 calls. Slowest were:

5.0ms
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
2.0ms
(sqrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
2.0ms
(sqrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))

prune793.0ms

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 12.3b

regimes237.0ms

Accuracy

0% (0.3b remaining)

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

bsearch2.0ms