Average Error: 37.7 → 13.2
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.2

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

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

Reproduce

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

sample205.0ms

Algorithm
intervals

simplify62.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
61.0ms
(* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re))))

prune52.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 10.4b

localize33.0ms

Local error

Found 3 expressions with local error:

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

rewrite19.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
fma-neg
add-cbrt-cube
pow1
expm1-log1p-u
flip--
associate-*l/
sqrt-div
flip3--
sqrt-prod
pow1/2
sub-neg
hypot-udef
Counts
3 → 39
Calls
3 calls:
Slowest
10.0ms
(- (hypot re im) re)
6.0ms
(sqrt (* (- (hypot re im) re) 2.0))
0.0ms
(hypot re im)

series232.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
135.0ms
(sqrt (* (- (hypot re im) re) 2.0))
68.0ms
(- (hypot re im) re)
28.0ms
(hypot re im)

simplify244.0ms

Counts
14 → 48
Calls
14 calls:
Slowest
138.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
84.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
7.0ms
(sqrt (- (hypot re im) re))
4.0ms
(* (cbrt (hypot re im)) (cbrt (hypot re im)))
2.0ms
(sqrt (hypot re im))

prune469.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 10.3b

localize10.0ms

Local error

Found 4 expressions with local error:

0.5b
(- (hypot re im) re)
0.4b
(* (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
Rules
10×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
sqrt-prod
add-exp-log
associate-*l*
add-cbrt-cube
pow1
add-log-exp
log1p-expm1-u
sqrt-div
expm1-log1p-u
flip--
associate-*r*
fma-neg
pow1/2
flip3--
associate-*l/
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
sub-neg
hypot-udef
rem-sqrt-square
Counts
4 → 68
Calls
4 calls:
Slowest
8.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
4.0ms
(sqrt (- (hypot re im) re))
3.0ms
(- (hypot re im) re)
0.0ms
(hypot re im)

series317.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
144.0ms
(* (sqrt (- (hypot re im) re)) (sqrt 2.0))
96.0ms
(sqrt (- (hypot re im) re))
41.0ms
(hypot re im)
35.0ms
(- (hypot re im) re)

simplify767.0ms

Counts
35 → 80
Calls
35 calls:
Slowest
341.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)))
116.0ms
(* (sqrt (- (* (hypot re im) (hypot re im)) (* re re))) (sqrt 2.0))
115.0ms
(sqrt (- (* (hypot re im) (hypot re im)) (* re re)))
30.0ms
(* (sqrt (- (pow (hypot re im) 3) (pow re 3))) (sqrt 2.0))
26.0ms
(* (- (hypot re im) re) 2.0)

prune893.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 10.3b

localize17.0ms

Local error

Found 4 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
fma-neg
cbrt-prod
add-log-exp
flip--
log1p-expm1-u
add-exp-log
add-cbrt-cube
flip3--
cbrt-div
pow1
expm1-log1p-u
pow1/3
sub-neg
Counts
4 → 62
Calls
4 calls:
Slowest
3.0ms
(- (hypot re im) re)
3.0ms
(- (hypot re im) re)
2.0ms
(cbrt (- (hypot re im) re))
2.0ms
(cbrt (- (hypot re im) re))

series396.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
188.0ms
(cbrt (- (hypot re im) re))
137.0ms
(cbrt (- (hypot re im) re))
36.0ms
(- (hypot re im) re)
35.0ms
(- (hypot re im) re)

simplify1.7s

Counts
26 → 74
Calls
26 calls:
Slowest
357.0ms
(exp (* 1/3 (- (+ (log 1/2) (log (/ 1 re))) (* 2 (log (/ 1 im))))))
338.0ms
(exp (* 1/3 (- (+ (log 1/2) (log (/ 1 re))) (* 2 (log (/ 1 im))))))
220.0ms
(- (+ (* 1/18 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3)) (* 1/3 (* re (pow (/ 1 (pow im 2)) 1/3))))
196.0ms
(- (+ (* 1/18 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3)) (* 1/3 (* re (pow (/ 1 (pow im 2)) 1/3))))
193.0ms
(exp (* 1/3 (- (log 2) (log (/ -1 re)))))

prune1.2s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 10.2b

localize29.0ms

Local error

Found 4 expressions with local error:

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Rules
pow1
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
sqrt-prod
add-exp-log
associate-*l*
associate-*r*
add-cbrt-cube
pow1/2
add-log-exp
log1p-expm1-u
expm1-log1p-u
flip--
pow-prod-up
associate-*l/
pow-prod-down
sqrt-div
flip3--
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
fma-neg
pow-plus
rem-square-sqrt
sub-neg
hypot-udef
pow2
Counts
4 → 69
Calls
4 calls:
Slowest
15.0ms
(sqrt (* (- (* (sqrt (hypot re im)) (sqrt (hypot re im))) re) 2.0))
14.0ms
(- (* (sqrt (hypot re im)) (sqrt (hypot re im))) re)
10.0ms
(* (sqrt (hypot re im)) (sqrt (hypot re im)))
0.0ms
(hypot re im)

series213.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
110.0ms
(sqrt (* (- (* (sqrt (hypot re im)) (sqrt (hypot re im))) re) 2.0))
42.0ms
(* (sqrt (hypot re im)) (sqrt (hypot re im)))
32.0ms
(hypot re im)
29.0ms
(- (* (sqrt (hypot re im)) (sqrt (hypot re im))) re)

simplify480.0ms

Counts
37 → 81
Calls
37 calls:
Slowest
269.0ms
(sqrt (* (- (* (* (sqrt (hypot re im)) (sqrt (hypot re im))) (* (sqrt (hypot re im)) (sqrt (hypot re im)))) (* re re)) 2.0))
142.0ms
(sqrt (* (- (pow (* (sqrt (hypot re im)) (sqrt (hypot re im))) 3) (pow re 3)) 2.0))
18.0ms
(* (* (* (sqrt (hypot re im)) (sqrt (hypot re im))) (sqrt (hypot re im))) (* (* (sqrt (hypot re im)) (sqrt (hypot re im))) (sqrt (hypot re im))))
4.0ms
(sqrt (- (* (sqrt (hypot re im)) (sqrt (hypot re im))) re))
4.0ms
(sqrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))

prune888.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 10.2b

regimes198.0ms

Accuracy

0% (0.3b remaining)

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

bsearch2.0ms

end0.0ms

sample3.0s

Algorithm
intervals