Average Error: 7.0 → 0.2
Time: 44.9s
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

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. Using strategy rm
  3. Applied difference-of-squares7.0

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

start92.0ms

Algorithm
intervals

setup272.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 8.6b

localize31.0ms

Local error

Found 4 expressions with local error:

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

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

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

series108.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify5.2s

Counts
32 → 75
Calls

32 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)))
528.0ms
(* (- (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)) x.im)
434.0ms
(* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) x.im)

prune814.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.1b

localize18.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.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 x.re))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 84
Calls

4 calls. Slowest were:

11.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
9.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
5.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

series156.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

65.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))
20.0ms
(+ (* x.re x.im) (* x.im x.re))
20.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify17.9s

Counts
68 → 96
Calls

68 calls. Slowest were:

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) (* 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

11 alts after pruning (10 fresh and 1 done)

Merged error: 0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite28.0ms

Algorithm
rewrite-expression-head
Counts
4 → 83
Calls

4 calls. Slowest were:

19.0ms
(* (cbrt (+ (* x.re x.im) (* x.im x.re))) (cbrt (+ (* x.re x.im) (* x.im x.re))))
3.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
3.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))

series583.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

159.0ms
(* (cbrt (+ (* x.re x.im) (* x.im x.re))) (cbrt (+ (* x.re x.im) (* x.im x.re))))
150.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
141.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
133.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))

simplify8.7s

Counts
59 → 95
Calls

59 calls. Slowest were:

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

prune1.4s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0b

localize45.0ms

Local error

Found 4 expressions with local error:

11.8b
(cbrt (+ (* x.re x.im) (* x.im x.re)))
11.8b
(cbrt (+ (* x.re x.im) (* x.im x.re)))
1.0b
(cbrt 2)
0.6b
(cbrt x.im)

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

2.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
1.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
0.0ms
(cbrt 2)

series513.0ms

Counts
4 → 10
Calls

4 calls. Slowest were:

254.0ms
(cbrt x.im)
138.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
120.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
0.0ms
(cbrt 2)

simplify2.2s

Counts
20 → 60
Calls

20 calls. Slowest were:

550.0ms
(cbrt (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)))
518.0ms
(cbrt (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)))
216.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (* (* (cbrt (+ (* x.re x.im) (* x.im x.re))) (* (* (cbrt x.im) (cbrt 2)) (cbrt x.re))) (cbrt (+ (* x.re x.im) (* x.im x.re)))) x.re))

prune1.1s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0b

regimes161.0ms

Accuracy

0% (0.2b remaining)

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

bsearch3.0ms