Average Error: 37.2 → 13.0
Time: 10.2s
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.2

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

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

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

Reproduce

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

sample167.0ms

Algorithm
intervals
Results
21.0ms188×body80valid
13.0ms21×body2560valid
11.0ms21×body1280valid
9.0ms12×body5120valid
2.0msbody640valid
1.0msbody320valid
0.0msbody160valid

simplify66.0ms

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

prune28.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 14.6b

localize29.0ms

Local error

Found 3 expressions with local error:

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

rewrite17.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
9.0ms
(- (hypot re im) re)
6.0ms
(sqrt (* (- (hypot re im) re) 2.0))
0.0ms
(hypot re im)

series205.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
104.0ms
(sqrt (* (- (hypot re im) re) 2.0))
69.0ms
(- (hypot re im) re)
31.0ms
(hypot re im)

simplify280.0ms

Counts
14 → 48
Calls
14 calls:
Slowest
181.0ms
(sqrt (* (- (* (hypot re im) (hypot re im)) (* re re)) 2.0))
76.0ms
(sqrt (* (- (pow (hypot re im) 3) (pow re 3)) 2.0))
6.0ms
(sqrt (- (hypot re im) re))
3.0ms
(- im re)
2.0ms
(* -1 re)

prune436.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 14.4b

localize33.0ms

Local error

Found 4 expressions with local error:

12.1b
(- (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (cbrt (hypot re im))) re)
0.5b
(* (cbrt (hypot re im)) (cbrt (hypot re im)))
0.5b
(cbrt (hypot re im))
0.5b
(cbrt (hypot re im))

rewrite23.0ms

Algorithm
rewrite-expression-head
Rules
12×cbrt-prod
10×add-cube-cbrt
10×*-un-lft-identity
10×add-sqr-sqrt
pow1
add-exp-log
associate-*l*
associate-*r*
pow1/3
add-log-exp
log1p-expm1-u
add-cbrt-cube
expm1-log1p-u
pow-prod-up
pow-prod-down
flip--
cbrt-unprod
*-commutative
prod-exp
fma-neg
flip3--
pow-plus
sub-neg
pow2
Counts
4 → 70
Calls
4 calls:
Slowest
15.0ms
(- (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (cbrt (hypot re im))) re)
5.0ms
(* (cbrt (hypot re im)) (cbrt (hypot re im)))
1.0ms
(cbrt (hypot re im))
1.0ms
(cbrt (hypot re im))

series400.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
154.0ms
(* (cbrt (hypot re im)) (cbrt (hypot re im)))
105.0ms
(cbrt (hypot re im))
94.0ms
(cbrt (hypot re im))
48.0ms
(- (* (* (cbrt (hypot re im)) (cbrt (hypot re im))) (cbrt (hypot re im))) re)

simplify174.0ms

Counts
39 → 82
Calls
39 calls:
Slowest
50.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))
33.0ms
(+ (pow im 2/3) (* 1/3 (* (pow re 2) (pow (/ 1 (pow im 4)) 1/3))))
30.0ms
(+ (* 1/6 (* (pow re 2) (pow (/ 1 (pow im 5)) 1/3))) (pow im 1/3))
4.0ms
(pow (/ 1 re) -1/3)
4.0ms
(pow (/ 1 re) -1/3)

prune886.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 14.4b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite2.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
log1p-expm1-u
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
expm1-log1p-u
add-sqr-sqrt
hypot-udef
fma-udef
sqrt-prod
pow1/2
Counts
4 → 41
Calls
4 calls:
Slowest
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)
0.0ms
(hypot re im)

series247.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
114.0ms
(sqrt (* (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)) 2.0))
77.0ms
(fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re))
29.0ms
(hypot re im)
28.0ms
(hypot re im)

simplify17.0ms

Counts
13 → 53
Calls
13 calls:
Slowest
7.0ms
(sqrt (fma (sqrt (hypot re im)) (sqrt (hypot re im)) (- re)))
2.0ms
(- im re)
1.0ms
(* -1 re)
1.0ms
(* -1 re)
0.0ms
re

prune582.0ms

Pruning

17 alts after pruning (16 fresh and 1 done)

Merged error: 14.4b

localize34.0ms

Local error

Found 4 expressions with local error:

12.1b
(- (* (* (* (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im)))) (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))) (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))) (cbrt (hypot re im))) re)
0.5b
(cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
0.5b
(cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
0.5b
(cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))

rewrite132.0ms

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

series327.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
101.0ms
(cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
94.0ms
(cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
90.0ms
(cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))
42.0ms
(- (* (* (* (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im)))) (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))) (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))) (cbrt (hypot re im))) re)

simplify99.0ms

Counts
16 → 59
Calls
16 calls:
Slowest
28.0ms
(+ (* 1/9 (* (pow re 2) (pow (/ 1 (pow im 16)) 1/9))) (pow im 2/9))
25.0ms
(+ (* 1/9 (* (pow re 2) (pow (/ 1 (pow im 16)) 1/9))) (pow im 2/9))
23.0ms
(+ (* 1/9 (* (pow re 2) (pow (/ 1 (pow im 16)) 1/9))) (pow im 2/9))
4.0ms
(* (* (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im)))) (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im))))) (cbrt (* (cbrt (hypot re im)) (cbrt (hypot re im)))))
2.0ms
(pow (/ 1 re) -2/9)

prune719.0ms

Pruning

19 alts after pruning (18 fresh and 1 done)

Merged error: 14.4b

regimes284.0ms

Accuracy

0% (0.2b remaining)

Error of 13.0b against oracle of 12.8b and baseline of 13.0b

bsearch1.0ms

end0.0ms

sample2.7s

Algorithm
intervals
Results
933.0ms6069×body80valid
675.0ms468×body1280valid
494.0ms685×body2560valid
285.0ms301×body5120valid
116.0ms275×body640valid
72.0ms138×body320valid
13.0ms64×body160valid