Average Error: 37.7 → 13.4
Time: 9.8s
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. Simplified13.4

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

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

Reproduce

herbie shell --seed 2019007 +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.2s)Debug log

sample175.0ms

Algorithm
intervals

simplify106.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune141.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 11.9b

localize32.0ms

Local error

Found 2 expressions with local error:

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

series143.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

98.0ms
(sqrt (* (- (hypot re im) re) 2.0))
45.0ms
(- (hypot re im) re)

simplify229.0ms

Counts
11 → 35
Calls

11 calls. Slowest were:

163.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
55.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
3.0ms
(sqrt (- (hypot re im) re))

prune324.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 11.7b

localize10.0ms

Local error

Found 2 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
2 → 42
Calls

2 calls. Slowest were:

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

series123.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

91.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
32.0ms
(- (hypot re im) re)

simplify419.0ms

Counts
23 → 48
Calls

23 calls. Slowest were:

221.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)))
100.0ms
(* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt 2.0))
30.0ms
(* (sqrt (- (pow (hypot re im) 3) (pow re 3))) (sqrt 2.0))

prune539.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 11.7b

localize33.0ms

Local error

Found 4 expressions with local error:

14.5b
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
0.0b
(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))
2.0ms
(sqrt (hypot re im))
2.0ms
(sqrt (hypot re im))

series339.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

137.0ms
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))
111.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
46.0ms
(sqrt (hypot re im))
45.0ms
(sqrt (hypot re im))

simplify28.0ms

Counts
21 → 61
Calls

21 calls. Slowest were:

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

prune467.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 11.7b

localize13.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.4b
(* (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 (hypot re im))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
4 → 66
Calls

4 calls. Slowest were:

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

series362.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

116.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
96.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
92.0ms
(* (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))) (sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))))
58.0ms
(sqrt (hypot re im))

simplify383.0ms

Counts
39 → 78
Calls

39 calls. Slowest were:

113.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)))))
47.0ms
(* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
42.0ms
(* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))

prune978.0ms

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 11.7b

regimes274.0ms

Accuracy

0% (0.2b remaining)

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

bsearch2.0ms

end0.0ms

sample3.0s

Algorithm
intervals