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

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.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 7.0

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

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

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

Reproduce

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

sample98.0ms

Algorithm
intervals

simplify337.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune16.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 6.7b

localize45.0ms

Local error

Found 3 expressions with local error:

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

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
3 → 39
Calls

3 calls. Slowest were:

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

series125.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

64.0ms
(fma x.re (fma (- x.im) (+ x.im x.im) (* x.re x.re)) (* (* x.im x.im) (- x.re)))
42.0ms
(fma (- x.im) (+ x.im x.im) (* x.re x.re))
19.0ms
(* (* x.im x.im) (- x.re))

simplify908.0ms

Counts
15 → 48
Calls

15 calls. Slowest were:

273.0ms
(* (* (* (* x.im x.im) (* x.im x.im)) (* x.im x.im)) (* (* (- x.re) (- x.re)) (- x.re)))
148.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
123.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))

prune458.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 6.5b

localize19.0ms

Local error

Found 1 expressions with local error:

6.6b
(fma (* x.re -3) (* x.im x.im) (pow x.re 3))

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
1 → 10
Calls

1 calls. Slowest were:

0.0ms
(fma (* x.re -3) (* x.im x.im) (pow x.re 3))

series42.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

42.0ms
(fma (* x.re -3) (* x.im x.im) (pow x.re 3))

simplify318.0ms

Counts
3 → 13
Calls

3 calls. Slowest were:

121.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
103.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
94.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))

prune132.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 6.5b

localize37.0ms

Local error

Found 4 expressions with local error:

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

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

12.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)
10.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.re)
8.0ms
(- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im))

series133.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

45.0ms
(- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
30.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.re)
30.0ms
(- (* x.re x.re) (* x.im x.im))
28.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

simplify5.9s

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)))
531.0ms
(* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) x.re)
366.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.im)

prune771.0ms

Pruning

7 alts after pruning (5 fresh and 2 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.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)

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 87
Calls

4 calls. Slowest were:

14.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.re))
13.0ms
(- (* (+ x.re x.im) (* (- x.re x.im) x.re)) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
4.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

series124.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

44.0ms
(- (* (+ x.re x.im) (* (- x.re x.im) x.re)) (* (+ (* x.re x.im) (* x.im x.re)) x.im))
29.0ms
(* (- x.re x.im) x.re)
29.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.re))
22.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.im)

simplify19.5s

Counts
73 → 99
Calls

73 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.2s
(* (* (- x.re x.im) (+ x.re x.im)) (- (* x.re x.im) (* x.im x.re)))

prune964.0ms

Pruning

8 alts after pruning (5 fresh and 3 done)

Merged error: 0.0b

regimes221.0ms

Accuracy

0% (0.2b remaining)

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

bsearch3.0ms

end0.0ms

sample3.0s

Algorithm
intervals