Average Error: 6.5 → 0.2
Time: 38.0s
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

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

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

    \[\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 2019002 +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: 37.2s)Debug log

sample107.0ms

Algorithm
intervals

simplify260.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune20.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 5.0b

localize52.0ms

Local error

Found 4 expressions with local error:

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

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

14.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
10.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
9.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

series150.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

63.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
51.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
20.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
15.0ms
(+ (* x.re x.im) (* x.im x.re))

simplify5.6s

Counts
32 → 75
Calls

32 calls. Slowest were:

1.4s
(* (+ (* (* 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)))
650.0ms
(* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) x.im)
432.0ms
(* (- (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)) x.im)

prune682.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.0b

localize28.0ms

Local error

Found 4 expressions with local error:

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

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 84
Calls

4 calls. Slowest were:

16.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
10.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
5.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

series120.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

46.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
42.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
16.0ms
(+ (* x.re x.im) (* x.im x.re))
16.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify18.1s

Counts
68 → 96
Calls

68 calls. Slowest were:

2.0s
(* (- 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.6s
(* (+ 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.5s
(* (* (- x.re x.im) (+ x.re x.im)) (- (* x.re x.im) (* x.im x.re)))

prune1.1s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 0.0b

localize6.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.1b
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
0.0b
(+ (* x.re x.im) (* x.im x.re))
0.0b
(* (- x.re x.im) x.im)

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
4 → 54
Calls

4 calls. Slowest were:

5.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
3.0ms
(* (- x.re x.im) x.im)
2.0ms
(+ (* x.re x.im) (* x.im x.re))

series150.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

80.0ms
(fma (+ x.re x.im) (* (- x.re x.im) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
32.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.5s

Counts
21 → 66
Calls

21 calls. Slowest were:

520.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
332.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)
158.0ms
(* (- (* (* x.re x.im) (* x.re x.im)) (* (* x.im x.re) (* x.im x.re))) x.re)

prune673.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

localize41.0ms

Local error

Found 4 expressions with local error:

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

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

18.0ms
(* (cbrt (* (+ x.im x.im) x.re)) (cbrt (* (+ x.im x.im) x.re)))
8.0ms
(cbrt (* (+ x.im x.im) x.re))
3.0ms
(cbrt (* (+ x.im x.im) x.re))

series574.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

174.0ms
(* (cbrt (* (+ x.im x.im) x.re)) (cbrt (* (+ x.im x.im) x.re)))
161.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
129.0ms
(cbrt (* (+ x.im x.im) x.re))
110.0ms
(cbrt (* (+ x.im x.im) x.re))

simplify3.4s

Counts
51 → 87
Calls

51 calls. Slowest were:

554.0ms
(cbrt (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)))
257.0ms
(* (exp (* 1/3 (+ (* 2 (log x.im)) (* 2 (log x.re))))) (pow (cbrt 2) 2))
244.0ms
(* (* (+ x.im x.im) x.re) (* (+ x.im x.im) x.re))

prune1.2s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

regimes154.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms

end0.0ms

sample3.2s

Algorithm
intervals