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

Error

Bits error versus x.re

Bits error versus x.im

Target

Original6.7
Target0.2
Herbie0.2
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)\]

Derivation

  1. Initial program 6.7

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  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.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  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.re\right)} - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  5. Using strategy rm
  6. Applied fma-neg0.2

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

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

Reproduce

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

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

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

Details

Time bar (total: 43.4s)Debug log

sample95.0ms

Algorithm
intervals

simplify322.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune22.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 7.7b

localize54.0ms

Local error

Found 4 expressions with local error:

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

rewrite40.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

17.0ms
(- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
9.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.re)
9.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

series106.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

33.0ms
(- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
29.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.re)
28.0ms
(- (* x.re x.re) (* x.im x.im))
16.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

simplify6.1s

Counts
38 → 80
Calls

38 calls. Slowest were:

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)))
510.0ms
(* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) x.re)
482.0ms
(fma (- x.im) (+ (* x.re x.im) (* x.im x.re)) (* x.im (+ (* x.re x.im) (* x.im x.re))))

prune737.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.1b

localize27.0ms

Local error

Found 4 expressions with local error:

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

rewrite46.0ms

Algorithm
rewrite-expression-head
Counts
4 → 87
Calls

4 calls. Slowest were:

17.0ms
(- (* (+ x.re x.im) (* (- x.re x.im) x.re)) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
16.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.re))
8.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

series116.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

39.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.re))
32.0ms
(* (- x.re x.im) x.re)
29.0ms
(- (* (+ x.re x.im) (* (- x.re x.im) x.re)) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
16.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

simplify18.6s

Counts
73 → 99
Calls

73 calls. Slowest were:

1.4s
(* (+ 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.3s
(* (- 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)))

prune937.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0b

localize6.0ms

Local error

Found 3 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
3 → 40
Calls

3 calls. Slowest were:

4.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)
3.0ms
(* (- x.re x.im) x.re)
0.0ms
(fma (+ x.re x.im) (* (- x.re x.im) x.re) (- (* (+ (* x.re x.im) (* x.im x.re)) x.im)))

series107.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

47.0ms
(fma (+ x.re x.im) (* (- x.re x.im) x.re) (- (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
31.0ms
(* (- x.re x.im) x.re)
28.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

simplify1.5s

Counts
17 → 49
Calls

17 calls. Slowest were:

473.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.im)
311.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.re)
178.0ms
(* (- (* (* x.re x.im) (* x.re x.im)) (* (* x.im x.re) (* x.im x.re))) x.im)

prune568.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0b

localize15.0ms

Local error

Found 4 expressions with local error:

23.0b
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))
23.0b
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))
23.0b
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))
0.4b
(* (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)) (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)))

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 73
Calls

4 calls. Slowest were:

22.0ms
(* (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)) (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
5.0ms
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))
5.0ms
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))

series650.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

204.0ms
(* (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)) (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
153.0ms
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))
150.0ms
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))
142.0ms
(cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im))

simplify9.1s

Counts
49 → 85
Calls

49 calls. Slowest were:

1.1s
(cbrt (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re)))))
986.0ms
(* (cbrt (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re))))) (cbrt (+ (* (* x.re x.im) (* x.re x.im)) (- (* (* x.im x.re) (* x.im x.re)) (* (* x.re x.im) (* x.im x.re))))))
526.0ms
(* (cbrt (* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.im)) (cbrt (* (+ (* x.re x.im) (* x.im x.re)) x.im)))

prune1000.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0b

regimes93.0ms

Accuracy

0% (0.2b remaining)

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

bsearch4.0ms

end0.0ms

sample3.1s

Algorithm
intervals