Average Error: 6.8 → 0.2
Time: 4.3m
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

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

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

    \[\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 2019016 
(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: 4.3m)Debug log

sample112.0ms

Algorithm
intervals
Results
474×(pre true 80)
474×(body real 80)

simplify188.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
188.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))

prune17.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 5.8b

localize25.0ms

Local error

Found 4 expressions with local error:

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

rewrite21.0ms

Algorithm
rewrite-expression-head
Rules
12×associate-*l/
add-log-exp
associate-*l*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
flip-+
flip3-+
add-exp-log
frac-add
add-cbrt-cube
pow1
flip--
flip3--
*-commutative
sum-log
+-commutative
difference-of-squares
Counts
4 → 53
Calls
4 calls:
Slowest
10.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
4.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
4.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
2.0ms
(+ (* x.re x.im) (* x.im x.re))

series95.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
36.0ms
(* (- (* x.re x.re) (* x.im x.im)) x.im)
35.0ms
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
12.0ms
(+ (* x.re x.im) (* x.im x.re))
11.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify5.7s

Counts
31 → 65
Calls
31 calls:
Slowest
2.3s
(* (exp (* (- (* x.re x.re) (* x.im x.im)) x.im)) (exp (* (+ (* x.re x.im) (* x.im x.re)) x.re)))
536.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)
490.0ms
(* (+ (* (* 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)))
356.0ms
(* (- (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)) x.im)
323.0ms
(+ (* (* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) 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))))) (* (+ (* x.re x.re) (* x.im x.im)) (* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)))

prune570.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

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

rewrite38.0ms

Algorithm
rewrite-expression-head
Rules
44×associate-*l/
19×flip-+
19×flip3-+
16×frac-add
12×frac-times
10×flip--
10×flip3--
associate-*l*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-exp-log
associate-*r/
add-cbrt-cube
pow1
*-commutative
cbrt-unprod
prod-exp
pow-prod-down
associate-*r*
sum-log
+-commutative
Counts
4 → 76
Calls
4 calls:
Slowest
14.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
13.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
8.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)
2.0ms
(* (- x.re x.im) x.im)

series113.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
43.0ms
(+ (* (+ x.re x.im) (* (- x.re x.im) x.im)) (* (+ (* x.re x.im) (* x.im x.re)) x.re))
37.0ms
(* (+ x.re x.im) (* (- x.re x.im) x.im))
21.0ms
(* (- x.re x.im) x.im)
12.0ms
(* (+ (* x.re x.im) (* x.im x.re)) x.re)

simplify13.2s

Counts
70 → 88
Calls
70 calls:
Slowest
619.0ms
(* (+ 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)))))
594.0ms
(+ (* (* (+ (pow x.re 3) (pow x.im 3)) (* (- (* x.re x.re) (* x.im x.im)) x.im)) (- (* x.re x.im) (* x.im x.re))) (* (* (+ (* x.re x.re) (- (* x.im x.im) (* x.re x.im))) (+ x.re x.im)) (* (- (* (* x.re x.im) (* x.re x.im)) (* (* x.im x.re) (* x.im x.re))) x.re)))
531.0ms
(+ (* (* (- (* x.re x.re) (* x.im x.im)) (* (- (* x.re x.re) (* x.im x.im)) 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))))) (* (* (- x.re x.im) (+ x.re x.im)) (* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)))
526.0ms
(* (- 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)))))
501.0ms
(* (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)) x.re)

prune824.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 4 expressions with local error:

14.3b
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
14.3b
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
14.3b
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
0.3b
(* (* (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))))

rewrite194.0ms

Algorithm
rewrite-expression-head
Rules
2200×frac-times
2120×associate-*l/
1968×cbrt-div
738×flip--
738×flip-+
738×flip3--
738×flip3-+
572×associate-*r/
18×pow1
add-exp-log
pow1/3
pow-prod-up
add-cube-cbrt
pow-prod-down
add-cbrt-cube
pow-plus
*-un-lft-identity
add-sqr-sqrt
add-log-exp
associate-*r*
cbrt-prod
cbrt-unprod
prod-exp
pow2
*-commutative
pow3
associate-*l*
Counts
4 → 807
Calls
4 calls:
Slowest
99.0ms
(* (* (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))))
5.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
5.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
5.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))

series515.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
169.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
157.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
133.0ms
(cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))
56.0ms
(* (* (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im)))) (cbrt (* (+ x.re x.im) (* (- x.re x.im) x.im))))

simplify3.7m

Counts
1431 → 819
Calls
1431 calls:
Slowest
805.0ms
(* (* (cbrt (* (- (* x.re x.re) (* x.im x.im)) (* (- (* x.re x.re) (* x.im x.im)) x.im))) (cbrt (* (+ (pow x.re 3) (pow x.im 3)) (* (- (pow x.re 3) (pow x.im 3)) x.im)))) (cbrt (* (- (* x.re x.re) (* x.im x.im)) (* (- (* x.re x.re) (* x.im x.im)) x.im))))
763.0ms
(* (* (cbrt (* (+ (pow x.re 3) (pow x.im 3)) (* (- (pow x.re 3) (pow x.im 3)) x.im))) (cbrt (* (+ (pow x.re 3) (pow x.im 3)) (* (- (pow x.re 3) (pow x.im 3)) x.im)))) (cbrt (* (+ (pow x.re 3) (pow x.im 3)) (* (- (* x.re x.re) (* x.im x.im)) x.im))))
703.0ms
(* (* (cbrt (* (+ (* x.re x.re) (- (* x.im x.im) (* x.re x.im))) (+ (* x.re x.re) (+ (* x.im x.im) (* x.re x.im))))) (cbrt (+ (* x.re x.re) (+ (* x.im x.im) (* x.re x.im))))) (cbrt (+ x.re x.im)))
670.0ms
(* (* (cbrt (* (- x.re x.im) (+ x.re x.im))) (cbrt (- x.re x.im))) (cbrt (* (+ (* x.re x.re) (- (* x.im x.im) (* x.re x.im))) (+ (* x.re x.re) (+ (* x.im x.im) (* x.re x.im))))))
659.0ms
(* (* (cbrt (* (- (* x.re x.re) (* x.im x.im)) (* (- (pow x.re 3) (pow x.im 3)) x.im))) (cbrt (* (- (* x.re x.re) (* x.im x.im)) (* (- (pow x.re 3) (pow x.im 3)) x.im)))) (cbrt (* (+ x.re x.im) (* (- (pow x.re 3) (pow x.im 3)) x.im))))

prune13.3s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.0b

localize23.0ms

Local error

Found 4 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*r/
18×cbrt-div
flip-+
flip3-+
pow1
add-cube-cbrt
pow1/3
*-un-lft-identity
add-sqr-sqrt
cbrt-prod
add-exp-log
add-log-exp
associate-*l*
associate-*r*
add-cbrt-cube
frac-times
pow-prod-up
associate-*l/
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 67
Calls
4 calls:
Slowest
6.0ms
(* (cbrt (* x.re (+ x.im x.im))) (cbrt (* x.re (+ x.im x.im))))
1.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
1.0ms
(cbrt (* x.re (+ x.im x.im)))
1.0ms
(cbrt (* x.re (+ x.im x.im)))

series400.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
123.0ms
(* (cbrt (* x.re (+ x.im x.im))) (cbrt (* x.re (+ x.im x.im))))
96.0ms
(cbrt (+ (* x.re x.im) (* x.im x.re)))
91.0ms
(cbrt (* x.re (+ x.im x.im)))
91.0ms
(cbrt (* x.re (+ x.im x.im)))

simplify2.1s

Counts
51 → 79
Calls
51 calls:
Slowest
264.0ms
(* (* x.re (+ x.im x.im)) (* x.re (+ x.im x.im)))
264.0ms
(* (* x.re (+ x.im x.im)) (* x.re (+ x.im x.im)))
201.0ms
(cbrt (+ (pow (* x.re x.im) 3) (pow (* x.im x.re) 3)))
155.0ms
(* (pow (cbrt 2) 2) (exp (* 1/3 (+ (* 2 (log x.im)) (* 2 (log x.re))))))
95.0ms
(* (exp (* -1/3 (+ (* 2 (log (/ 1 x.im))) (* 2 (log (/ 1 x.re)))))) (pow (cbrt 2) 2))

prune681.0ms

Pruning

8 alts after pruning (5 fresh and 3 done)

Merged error: 0.0b

regimes94.0ms

Accuracy

0% (0.2b remaining)

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

bsearch2.0ms

end0.0ms

sample1.8s

Algorithm
intervals
Results
14405×(pre true 80)
14405×(body real 80)