Average Error: 37.4 → 12.9
Time: 10.1s
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.4

    \[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 2019005 +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.1s)Debug log

sample169.0ms

Algorithm
intervals

simplify30.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune27.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 14.9b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite9.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)

series177.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

98.0ms
(sqrt (* (- (hypot re im) re) 2.0))
42.0ms
(hypot re im)
37.0ms
(- (hypot re im) re)

simplify277.0ms

Counts
14 → 48
Calls

14 calls. Slowest were:

149.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
109.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
6.0ms
(sqrt (- (hypot re im) re))

prune526.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 14.5b

localize10.0ms

Local error

Found 3 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 52
Calls

3 calls. Slowest were:

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

series199.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

119.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
40.0ms
(- (hypot re im) re)
39.0ms
(hypot re im)

simplify556.0ms

Counts
26 → 61
Calls

26 calls. Slowest were:

278.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)))
125.0ms
(* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt 2.0))
29.0ms
(* (sqrt (- (pow (hypot re im) 3) (pow re 3))) (sqrt 2.0))

prune538.0ms

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 14.5b

localize18.0ms

Local error

Found 4 expressions with local error:

16.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
(hypot re im)
0.0b
(hypot re im)

rewrite2.0ms

Algorithm
rewrite-expression-head
Counts
4 → 41
Calls

4 calls. Slowest were:

1.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)

series287.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

140.0ms
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))
101.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
23.0ms
(hypot re im)
23.0ms
(hypot re im)

simplify13.0ms

Counts
13 → 53
Calls

13 calls. Slowest were:

5.0ms
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
1.0ms
(- im re)
1.0ms
(* -1 re)

prune530.0ms

Pruning

14 alts after pruning (12 fresh and 2 done)

Merged error: 14.5b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

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

series387.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

132.0ms
(sqrt (* (* (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))) 2.0))
87.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
86.0ms
(* (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
81.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))

simplify341.0ms

Counts
36 → 75
Calls

36 calls. Slowest were:

75.0ms
(* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
72.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)))))
52.0ms
(* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))

prune759.0ms

Pruning

15 alts after pruning (13 fresh and 2 done)

Merged error: 14.5b

regimes234.0ms

Accuracy

0% (0.2b remaining)

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

bsearch2.0ms

end0.0ms

sample3.0s

Algorithm
intervals