Average Error: 7.0 → 0.2
Time: 7.2s
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\]
\[x.re \cdot \left(\left(3 \cdot x.im\right) \cdot x.re\right) - {x.im}^{3}\]

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

Original7.0
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.0

    \[\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. Simplified7.0

    \[\leadsto \color{blue}{(x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(\left(x.re \cdot x.re\right) \cdot \left(x.im + x.im\right)\right))_*}\]
  3. Taylor expanded around 0 7.0

    \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot {x.re}^{2}\right) - {x.im}^{3}}\]
  4. Using strategy rm
  5. Applied unpow27.0

    \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) - {x.im}^{3}\]
  6. Applied associate-*r*0.2

    \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} - {x.im}^{3}\]
  7. Using strategy rm
  8. Applied associate-*r*0.2

    \[\leadsto \color{blue}{\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re} - {x.im}^{3}\]
  9. Using strategy rm
  10. Applied associate-*r*0.2

    \[\leadsto \color{blue}{\left(\left(3 \cdot x.im\right) \cdot x.re\right)} \cdot x.re - {x.im}^{3}\]
  11. Final simplification0.2

    \[\leadsto x.re \cdot \left(\left(3 \cdot x.im\right) \cdot x.re\right) - {x.im}^{3}\]

Reproduce

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

sample103.0ms

Algorithm
intervals

simplify250.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

249.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: 8.6b

localize39.0ms

Local error

Found 3 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 48
Calls

3 calls. Slowest were:

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

series80.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

36.0ms
(fma x.im (- (* x.re x.re) (* x.im x.im)) (* (* x.re x.re) (+ x.im x.im)))
23.0ms
(- (* x.re x.re) (* x.im x.im))
20.0ms
(* (* x.re x.re) (+ x.im x.im))

simplify624.0ms

Counts
24 → 57
Calls

24 calls. Slowest were:

109.0ms
(* (* (* (* x.re x.re) (* x.re x.re)) (* x.re x.re)) (* (* (+ x.im x.im) (+ x.im x.im)) (+ x.im x.im)))
98.0ms
(- (* 3 (* x.im (pow x.re 2))) (pow x.im 3))
92.0ms
(- (* 3 (* x.im (pow x.re 2))) (pow x.im 3))

prune619.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 8.4b

localize14.0ms

Local error

Found 2 expressions with local error:

9.6b
(* x.im (pow x.re 2))
0.2b
(* 3 (* x.im (pow x.re 2)))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 25
Calls

2 calls. Slowest were:

2.0ms
(* 3 (* x.im (pow x.re 2)))
1.0ms
(* x.im (pow x.re 2))

series37.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

19.0ms
(* x.im (pow x.re 2))
18.0ms
(* 3 (* x.im (pow x.re 2)))

simplify97.0ms

Counts
10 → 31
Calls

10 calls. Slowest were:

32.0ms
(* 3 (* x.im (pow x.re 2)))
20.0ms
(* 3 (* x.im (pow x.re 2)))
17.0ms
(* 3 (* x.im (pow x.re 2)))

prune303.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 2 expressions with local error:

0.2b
(* (* x.im x.re) x.re)
0.2b
(* 3 (* (* x.im x.re) x.re))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
2 → 22
Calls

2 calls. Slowest were:

4.0ms
(* 3 (* (* x.im x.re) x.re))
2.0ms
(* (* x.im x.re) x.re)

series59.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

32.0ms
(* 3 (* (* x.im x.re) x.re))
26.0ms
(* (* x.im x.re) x.re)

simplify101.0ms

Counts
6 → 28
Calls

6 calls. Slowest were:

33.0ms
(* 3 (* x.im (pow x.re 2)))
28.0ms
(* 3 (* x.im (pow x.re 2)))
17.0ms
(* 3 (* x.im (pow x.re 2)))

prune349.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 2 expressions with local error:

0.3b
(* 3 (* x.im x.re))
0.2b
(* (* 3 (* x.im x.re)) x.re)

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
2 → 22
Calls

2 calls. Slowest were:

6.0ms
(* (* 3 (* x.im x.re)) x.re)
2.0ms
(* 3 (* x.im x.re))

series38.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

20.0ms
(* (* 3 (* x.im x.re)) x.re)
17.0ms
(* 3 (* x.im x.re))

simplify76.0ms

Counts
6 → 28
Calls

6 calls. Slowest were:

20.0ms
(* 3 (* x.im (pow x.re 2)))
17.0ms
(* 3 (* x.im (pow x.re 2)))
17.0ms
(* 3 (* x.im (pow x.re 2)))

prune230.0ms

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 0b

regimes142.0ms

Accuracy

0% (0.2b remaining)

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

bsearch2.0ms

end0.0ms

sample2.9s

Algorithm
intervals