Average Error: 37.7 → 13.7
Time: 13.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.7

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

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

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

Reproduce

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

sample123.0ms

Algorithm
intervals

simplify32.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune31.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 11.7b

localize17.0ms

Local error

Found 2 expressions with local error:

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
2 → 29
Calls

2 calls. Slowest were:

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

series196.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

132.0ms
(sqrt (* (- (hypot re im) re) 2.0))
64.0ms
(- (hypot re im) re)

simplify332.0ms

Counts
11 → 35
Calls

11 calls. Slowest were:

237.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
74.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
6.0ms
(sqrt (- (hypot re im) re))

prune380.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 11.6b

localize18.0ms

Local error

Found 4 expressions with local error:

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

rewrite37.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

24.0ms
(* (sqrt (sqrt (* (- (hypot re im) re) 2.0))) (sqrt (sqrt (* (- (hypot re im) re) 2.0))))
5.0ms
(- (hypot re im) re)
3.0ms
(- (hypot re im) re)

series389.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

188.0ms
(sqrt (sqrt (* (- (hypot re im) re) 2.0)))
129.0ms
(* (sqrt (sqrt (* (- (hypot re im) re) 2.0))) (sqrt (sqrt (* (- (hypot re im) re) 2.0))))
43.0ms
(- (hypot re im) re)
29.0ms
(- (hypot re im) re)

simplify3.1s

Counts
59 → 103
Calls

59 calls. Slowest were:

374.0ms
(* (sqrt (sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))) (sqrt (sqrt (* (- (hypot re im) re) 2.0))))
330.0ms
(* (sqrt (sqrt 2.0)) (exp (* 1/4 (- (+ (log 1/2) (log (/ 1 re))) (* 2 (log (/ 1 im)))))))
266.0ms
(* (sqrt (sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))) (sqrt (sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))))

prune1.4s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 11.6b

localize29.0ms

Local error

Found 2 expressions with local error:

13.2b
(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))

rewrite2.0ms

Algorithm
rewrite-expression-head
Counts
2 → 21
Calls

2 calls. Slowest were:

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

series212.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

137.0ms
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))
76.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))

simplify9.0ms

Counts
7 → 27
Calls

7 calls. Slowest were:

6.0ms
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
1.0ms
(- im re)
0.0ms
(- (+ re (- (+ (* +nan.0 (/ (pow im 2) (pow re 2))) (- +nan.0)))))

prune321.0ms

Pruning

10 alts after pruning (7 fresh and 3 done)

Merged error: 11.6b

localize13.0ms

Local error

Found 3 expressions with local error:

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

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

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

series198.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

139.0ms
(sqrt (* (+ (* (sqrt (hypot re im)) (sqrt (hypot re im))) (- re)) 2.0))
34.0ms
(+ (* (sqrt (hypot re im)) (sqrt (hypot re im))) (- re))
25.0ms
(* (sqrt (hypot re im)) (sqrt (hypot re im)))

simplify556.0ms

Counts
35 → 71
Calls

35 calls. Slowest were:

249.0ms
(sqrt (* (- (* (* (sqrt (hypot re im)) (sqrt (hypot re im))) (* (sqrt (hypot re im)) (sqrt (hypot re im)))) (* (- re) (- re))) 2.0))
177.0ms
(sqrt (* (+ (pow (* (sqrt (hypot re im)) (sqrt (hypot re im))) 3) (pow (- re) 3)) 2.0))
40.0ms
(* (exp (* (sqrt (hypot re im)) (sqrt (hypot re im)))) (exp (- re)))

prune814.0ms

Pruning

13 alts after pruning (10 fresh and 3 done)

Merged error: 11.5b

regimes150.0ms

Accuracy

0% (0.2b remaining)

Error of 13.7b against oracle of 13.5b and baseline of 13.7b

bsearch1.0ms

end0.0ms

sample3.1s

Algorithm
intervals