Average Error: 6.7 → 0.2
Time: 1.4m
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(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(x.im + x.re\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]

Error

Bits error versus x.re

Bits error versus x.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.7
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 6.7

    \[\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-squares6.7

    \[\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. Final simplification0.2

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

Reproduce

herbie shell --seed 2018365 
(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: 1.4m)Debug log

start103.0ms

Algorithm
intervals

setup191.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 7.1b

localize53.0ms

Local error

Found 4 expressions with local error:

7.2b
(* (- (* x.re x.re) (* x.im x.im)) x.im)
0.2b
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
0.1b
(+ (* (- (* 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.re) (* x.im x.im))

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

13.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
9.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
8.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

series140.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

51.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
51.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
23.0ms
(- (* x.re x.re) (* x.im x.im))
14.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify6.3s

Counts
33 → 67
Calls

33 calls. Slowest were:

2.6s
(* (exp (* (- (* x.re x.re) (* x.im x.im)) x.im)) (exp (* (+ (* x.re x.im) (* x.im x.re)) x.re)))
614.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)
401.0ms
(* (+ (* (* 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)))

prune752.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

localize27.0ms

Local error

Found 4 expressions with local error:

0.2b
(* (+ x.re x.im) (* (- x.re x.im) x.im))
0.2b
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
0.1b
(+ (* (+ 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)

rewrite53.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

22.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
15.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
9.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

series122.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

45.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
42.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
20.0ms
(* (- x.re x.im) x.im)
15.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify13.9s

Counts
70 → 88
Calls

70 calls. Slowest were:

783.0ms
(* (+ (* x.re x.re) (- (* x.im x.im) (* x.re x.im))) (+ (* x.re x.re) (+ (* x.im x.im) (* x.re x.im))))
610.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)))
540.0ms
(* (+ (* x.re x.re) (+ (* x.im x.im) (* x.re x.im))) (- (* x.re x.im) (* x.im x.re)))

prune892.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 4 expressions with local error:

14.5b
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
14.5b
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
14.5b
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
0.3b
(* (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))))

rewrite44.0ms

Algorithm
rewrite-expression-head
Counts
4 → 155
Calls

4 calls. Slowest were:

25.0ms
(* (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))))
5.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
5.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))

series576.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

156.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
152.0ms
(* (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))))
148.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
120.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))

simplify52.9s

Counts
199 → 167
Calls

199 calls. Slowest were:

791.0ms
(* (cbrt (* (- (* x.re x.re) (* x.im x.im)) (* (- (* x.re x.re) (* x.im x.im)) x.im))) (cbrt (* (+ (pow x.re 3) (pow x.im 3)) (* (- (* x.re x.re) (* x.im x.im)) x.im))))
733.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
677.0ms
(* (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ x.re x.im) (* (- x.re x.im) x.im)))

prune3.2s

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 4 expressions with local error:

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

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

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

series614.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

180.0ms
(* (cbrt (+ x.re x.im)) (cbrt (+ x.re x.im)))
160.0ms
(cbrt (+ x.re x.im))
152.0ms
(cbrt (+ x.re x.im))
123.0ms
(cbrt (+ x.re x.im))

simplify1.4s

Counts
59 → 87
Calls

59 calls. Slowest were:

185.0ms
(- (+ (* 1/3 (* (pow (/ 1 (pow x.im 2)) 1/3) x.re)) (pow x.im 1/3)) (* 1/9 (* (pow (/ 1 (pow x.im 5)) 1/3) (pow x.re 2))))
155.0ms
(- (+ (* 1/3 (* (pow (/ 1 (pow x.im 2)) 1/3) x.re)) (pow x.im 1/3)) (* 1/9 (* (pow (/ 1 (pow x.im 5)) 1/3) (pow x.re 2))))
135.0ms
(- (+ (* 1/3 (* (pow (/ 1 (pow x.im 2)) 1/3) x.re)) (pow x.im 1/3)) (* 1/9 (* (pow (/ 1 (pow x.im 5)) 1/3) (pow x.re 2))))

prune951.0ms

Pruning

10 alts after pruning (7 fresh and 3 done)

Merged error: 0.0b

regimes132.0ms

Accuracy

0% (0.2b remaining)

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

bsearch3.0ms