Average Error: 37.5 → 13.4
Time: 14.0s
Precision: 64
Internal Precision: 128
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}\]
\[0.5 \cdot \left(\sqrt{2.0} \cdot \sqrt{\sqrt{re^2 + im^2}^* - re}\right)\]

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.5

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

    \[\leadsto 0.5 \cdot \sqrt{\left(\sqrt{re^2 + im^2}^* - re\right) \cdot 2.0}\]
  3. Using strategy rm
  4. Applied sqrt-prod13.4

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

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

Reproduce

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

start282.0ms

Algorithm
intervals

setup84.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 13.0b

localize19.0ms

Local error

Found 3 expressions with local error:

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

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

series166.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

99.0ms
(sqrt (* (- (hypot re im) re) 2.0))
42.0ms
(- (hypot re im) re)
24.0ms
(hypot re im)

simplify355.0ms

Counts
14 → 48
Calls

14 calls. Slowest were:

260.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
75.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
3.0ms
(- im re)

prune750.0ms

Pruning

9 alts after pruning (8 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.3b
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
0.0b
(sqrt (- (hypot re im) re))
0.0b
(hypot re im)

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

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

series264.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

97.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
97.0ms
(sqrt (- (hypot re im) re))
37.0ms
(- (hypot re im) re)
33.0ms
(hypot re im)

simplify682.0ms

Counts
35 → 80
Calls

35 calls. Slowest were:

290.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)))
143.0ms
(* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt 2.0))
114.0ms
(sqrt (- (* (hypot re im) (hypot re im)) (* re re)))

prune1.0s

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 12.4b

localize23.0ms

Local error

Found 4 expressions with local error:

0.5b
(- (hypot re im) re)
0.5b
(- (hypot re im) re)
0.5b
(- (hypot re im) re)
0.4b
(cbrt (sqrt (- (hypot re im) re)))

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 66
Calls

4 calls. Slowest were:

3.0ms
(- (hypot re im) re)
3.0ms
(- (hypot re im) re)
3.0ms
(- (hypot re im) re)

series264.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

156.0ms
(cbrt (sqrt (- (hypot re im) re)))
40.0ms
(- (hypot re im) re)
38.0ms
(- (hypot re im) re)
31.0ms
(- (hypot re im) re)

simplify1.0s

Counts
26 → 78
Calls

26 calls. Slowest were:

404.0ms
(exp (* 1/6 (- (+ (log 1/2) (log (/ 1 re))) (* 2 (log (/ 1 im))))))
239.0ms
(- (+ (* 1/72 (* (pow re 2) (pow (/ 1 (pow im 11)) 1/6))) (pow im 1/6)) (* 1/6 (* re (pow (/ 1 (pow im 5)) 1/6))))
156.0ms
(exp (* 1/6 (- (log 2) (log (/ -1 re)))))

prune1.8s

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 12.4b

localize17.0ms

Local error

Found 4 expressions with local error:

0.5b
(- (hypot re im) re)
0.5b
(- (hypot re im) re)
0.5b
(- (hypot re im) re)
0.5b
(- (hypot re im) re)

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

3.0ms
(- (hypot re im) re)
3.0ms
(- (hypot re im) re)
3.0ms
(- (hypot re im) re)

series141.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

43.0ms
(- (hypot re im) re)
41.0ms
(- (hypot re im) re)
29.0ms
(- (hypot re im) re)
28.0ms
(- (hypot re im) re)

simplify43.0ms

Counts
20 → 76
Calls

20 calls. Slowest were:

3.0ms
(- im re)
3.0ms
(- im re)
3.0ms
(- im re)

prune1.5s

Pruning

10 alts after pruning (7 fresh and 3 done)

Merged error: 12.4b

regimes219.0ms

Accuracy

0% (0.5b remaining)

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

bsearch2.0ms