Average Error: 7.1 → 0.2
Time: 33.5s
Precision: 64
Internal Precision: 128
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\[(\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right) + \left(\left(x.re \cdot x.im + x.re \cdot x.im\right) \cdot x.re\right))_*\]

Error

Bits error versus x.re

Bits error versus x.im

Target

Original7.1
Target0.2
Herbie0.2
\[\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\]

Derivation

  1. Initial program 7.1

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  2. Using strategy rm
  3. Applied difference-of-squares7.1

    \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  4. Applied associate-*l*0.2

    \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  5. Using strategy rm
  6. Applied fma-def0.2

    \[\leadsto \color{blue}{(\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right) + \left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right))_*}\]
  7. Final simplification0.2

    \[\leadsto (\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right) + \left(\left(x.re \cdot x.im + x.re \cdot x.im\right) \cdot x.re\right))_*\]

Reproduce

herbie shell --seed 2019022 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"

  :herbie-target
  (+ (* (* x.re x.im) (* 2 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im)))

  (+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))

Details

Time bar (total: 32.5s)Debug log

sample67.0ms

Algorithm
intervals
Results
53.0ms440×body80valid

simplify265.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
265.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))

prune21.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 7.9b

localize46.0ms

Local error

Found 4 expressions with local error:

8.0b
(* (- (* x.re x.re) (* x.im x.im)) x.im)
0.2b
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
0.2b
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
0.0b
(+ (* x.re x.im) (* x.im x.re))

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
12×associate-*l/
add-log-exp
associate-*l*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
flip-+
flip3-+
log1p-expm1-u
add-exp-log
frac-add
add-cbrt-cube
pow1
expm1-log1p-u
flip--
flip3--
*-commutative
fma-def
sum-log
+-commutative
difference-of-squares
Counts
4 → 63
Calls
4 calls:
Slowest
7.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
5.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
5.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
2.0ms
(+ (* x.re x.im) (* x.im x.re))

series116.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
43.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
41.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
19.0ms
(+ (* x.re x.im) (* x.im x.re))
12.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify4.9s

Counts
32 → 75
Calls
32 calls:
Slowest
1.3s
(* (+ (* (* x.re x.re) (* x.re x.re)) (+ (* (* x.im x.im) (* x.im x.im)) (* (* x.re x.re) (* x.im x.im)))) (- (* x.re x.im) (* x.im x.re)))
459.0ms
(* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) x.im)
410.0ms
(* (- (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)) x.im)
348.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)
314.0ms
(+ (* (* (- (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)) x.im) (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re))))) (* (+ (* (* x.re x.re) (* x.re x.re)) (+ (* (* x.im x.im) (* x.im x.im)) (* (* x.re x.re) (* x.im x.im)))) (* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)))

prune745.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.1b

localize15.0ms

Local error

Found 4 expressions with local error:

0.3b
(* (+ x.re x.im) (* (- x.re x.im) x.im))
0.2b
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
0.2b
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
0.0b
(* (- x.re x.im) x.im)

rewrite52.0ms

Algorithm
rewrite-expression-head
Rules
44×associate-*l/
19×flip-+
19×flip3-+
16×frac-add
12×frac-times
10×flip--
10×flip3--
associate-*l*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-exp-log
associate-*r/
add-cbrt-cube
pow1
log1p-expm1-u
expm1-log1p-u
*-commutative
cbrt-unprod
prod-exp
pow-prod-down
associate-*r*
fma-def
sum-log
+-commutative
Counts
4 → 85
Calls
4 calls:
Slowest
20.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
17.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
9.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
4.0ms
(* (- x.re x.im) x.im)

series143.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
54.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
51.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
21.0ms
(* (- x.re x.im) x.im)
17.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify16.1s

Counts
71 → 97
Calls
71 calls:
Slowest
1.5s
(* (+ x.re x.im) (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re)))))
1.2s
(* (- x.re x.im) (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re)))))
1.2s
(* (* (- x.re x.im) (+ x.re x.im)) (- (* x.re x.im) (* x.im x.re)))
765.0ms
(* (- (* x.re x.re) (* x.im x.im)) (* (- x.re x.im) x.im))
725.0ms
(+ (* (* (- (* x.re x.re) (* x.im x.im)) (* (- (* x.re x.re) (* x.im x.im)) x.im)) (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re))))) (* (* (- x.re x.im) (+ x.re x.im)) (* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)))

prune959.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 4 expressions with local error:

0.2b
(fma (+ x.re x.im) (* (- x.re x.im) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
0.2b
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
0.0b
(* (- x.re x.im) x.im)
0.0b
(+ (* x.re x.im) (* x.im x.re))

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
associate-*l*
*-un-lft-identity
add-sqr-sqrt
log1p-expm1-u
add-exp-log
associate-*l/
add-cbrt-cube
pow1
expm1-log1p-u
flip-+
*-commutative
flip3-+
flip--
fma-udef
flip3--
fma-def
sum-log
+-commutative
Counts
4 → 54
Calls
4 calls:
Slowest
9.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
5.0ms
(* (- x.re x.im) x.im)
2.0ms
(+ (* x.re x.im) (* x.im x.re))
0.0ms
(fma (+ x.re x.im) (* (- x.re x.im) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))

series142.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
68.0ms
(fma (+ x.re x.im) (* (- x.re x.im) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
35.0ms
(* (- x.re x.im) x.im)
20.0ms
(+ (* x.re x.im) (* x.im x.re))
19.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify1.3s

Counts
21 → 66
Calls
21 calls:
Slowest
330.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)
290.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
156.0ms
(* (- (* (* x.re x.im) (* x.re x.im)) (* (* x.im x.re) (* x.im x.re))) x.re)
96.0ms
(- (* 3 (* x.im (pow x.re 2))) (pow x.im 3))
93.0ms
(- (* 3 (* x.im (pow x.re 2))) (pow x.im 3))

prune712.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0b

localize38.0ms

Local error

Found 4 expressions with local error:

0.6b
(* (cbrt (- x.re x.im)) (cbrt (- x.re x.im)))
0.5b
(cbrt (- x.re x.im))
0.5b
(cbrt (- x.re x.im))
0.5b
(cbrt (- x.re x.im))

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
18×cbrt-div
15×cbrt-prod
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
flip--
flip3--
pow1
pow1/3
add-exp-log
associate-*l*
associate-*r*
add-log-exp
log1p-expm1-u
add-cbrt-cube
frac-times
expm1-log1p-u
pow-prod-up
associate-*r/
associate-*l/
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 83
Calls
4 calls:
Slowest
11.0ms
(* (cbrt (- x.re x.im)) (cbrt (- x.re x.im)))
1.0ms
(cbrt (- x.re x.im))
1.0ms
(cbrt (- x.re x.im))
1.0ms
(cbrt (- x.re x.im))

series594.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
167.0ms
(cbrt (- x.re x.im))
147.0ms
(cbrt (- x.re x.im))
144.0ms
(cbrt (- x.re x.im))
135.0ms
(* (cbrt (- x.re x.im)) (cbrt (- x.re x.im)))

simplify2.1s

Counts
59 → 95
Calls
59 calls:
Slowest
188.0ms
(- (pow x.im 2/3) (+ (* 1/9 (* (pow (/ 1 (pow x.im 4)) 1/3) (pow x.re 2))) (* 2/3 (* (pow (/ 1 x.im) 1/3) x.re))))
167.0ms
(exp (* 1/3 (- (log -1) (log (/ -1 x.re)))))
167.0ms
(- (exp (* 1/3 (+ (log x.im) (log -1)))) (+ (* 1/3 (* x.re (exp (* 1/3 (- (log -1) (* 2 (log x.im))))))) (* 1/9 (* (pow x.re 2) (exp (* 1/3 (- (log -1) (* 5 (log x.im)))))))))
166.0ms
(- (exp (* 1/3 (+ (log x.im) (log -1)))) (+ (* 1/3 (* x.re (exp (* 1/3 (- (log -1) (* 2 (log x.im))))))) (* 1/9 (* (pow x.re 2) (exp (* 1/3 (- (log -1) (* 5 (log x.im)))))))))
163.0ms
(* (cbrt (- (* x.re x.re) (* x.im x.im))) (cbrt (- x.re x.im)))

prune1.2s

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 0b

regimes118.0ms

Accuracy

0% (0.2b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 0.2b

bsearch1.0ms

end0.0ms

sample2.8s

Algorithm
intervals
Results
2.6s14459×body80valid