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

    \[\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. Simplified6.9

    \[\leadsto \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im \cdot x.im + x.im \cdot x.im\right)\right)}\]
  3. Taylor expanded around -inf 6.9

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

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

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

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

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

Reproduce

herbie shell --seed 2019018 
(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: 13.9s)Debug log

sample74.0ms

Algorithm
intervals
Results
50.0ms431×body80valid

simplify312.0ms

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

prune13.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 5.2b

localize15.0ms

Local error

Found 3 expressions with local error:

5.2b
(* x.re (- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im))))
0.1b
(- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im)))
0.0b
(+ (* x.im x.im) (* x.im x.im))

rewrite51.0ms

Algorithm
rewrite-expression-head
Rules
17×add-log-exp
frac-sub
*-un-lft-identity
add-sqr-sqrt
flip--
associate-*r/
associate--l+
diff-log
flip3--
sub-neg
flip-+
associate-*r*
flip3-+
add-cube-cbrt
distribute-lft-in
distribute-rgt-in
add-exp-log
add-cbrt-cube
sum-log
pow1
difference-of-squares
distribute-lft-out--
associate--r+
distribute-lft-out
*-commutative
distribute-rgt-out
+-commutative
associate--l-
Counts
3 → 65
Calls
3 calls:
Slowest
31.0ms
(* x.re (- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im))))
17.0ms
(- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im)))
2.0ms
(+ (* x.im x.im) (* x.im x.im))

series88.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
42.0ms
(* x.re (- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im))))
32.0ms
(- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im)))
14.0ms
(+ (* x.im x.im) (* x.im x.im))

simplify6.4s

Counts
50 → 74
Calls
50 calls:
Slowest
446.0ms
(+ (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im)))
416.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
390.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.im x.im) (* x.im x.im)) (- (* (* x.im x.im) (* x.im x.im)) (* (* x.im x.im) (* x.im x.im)))))
315.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.im x.im) (* x.im x.im)) (- (* (* x.im x.im) (* x.im x.im)) (* (* x.im x.im) (* x.im x.im)))))
248.0ms
(* (- (- (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im))) x.re)

prune693.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 5.1b

localize23.0ms

Local error

Found 3 expressions with local error:

6.3b
(* (pow x.im 2) x.re)
0.2b
(* 3 (* (pow x.im 2) x.re))
0.0b
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))

rewrite10.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
associate-*l*
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
*-commutative
unpow2
flip--
associate-*r*
diff-log
flip3--
sub-neg
Counts
3 → 33
Calls
3 calls:
Slowest
4.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
3.0ms
(* (pow x.im 2) x.re)
3.0ms
(* 3 (* (pow x.im 2) x.re))

series74.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
45.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
18.0ms
(* 3 (* (pow x.im 2) x.re))
11.0ms
(* (pow x.im 2) x.re)

simplify527.0ms

Counts
12 → 42
Calls
12 calls:
Slowest
152.0ms
(/ (exp (pow x.re 3)) (exp (* 3 (* (pow x.im 2) x.re))))
97.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
91.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
88.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
30.0ms
(* 3 (* (pow x.im 2) x.re))

prune472.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 3 expressions with local error:

0.2b
(* 3 (* x.im (* x.im x.re)))
0.2b
(* x.im (* x.im x.re))
0.0b
(- (pow x.re 3) (* 3 (* x.im (* x.im x.re))))

rewrite7.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
*-commutative
associate-*r*
flip--
diff-log
flip3--
sub-neg
Counts
3 → 30
Calls
3 calls:
Slowest
4.0ms
(- (pow x.re 3) (* 3 (* x.im (* x.im x.re))))
2.0ms
(* 3 (* x.im (* x.im x.re)))
1.0ms
(* x.im (* x.im x.re))

series51.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
27.0ms
(- (pow x.re 3) (* 3 (* x.im (* x.im x.re))))
12.0ms
(* 3 (* x.im (* x.im x.re)))
11.0ms
(* x.im (* x.im x.re))

simplify662.0ms

Counts
11 → 39
Calls
11 calls:
Slowest
145.0ms
(/ (exp (pow x.re 3)) (exp (* 3 (* x.im (* x.im x.re)))))
140.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
139.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
112.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
34.0ms
(* 3 (* (pow x.im 2) x.re))

prune388.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 2 expressions with local error:

0.2b
(* (* 3 x.im) (* x.im x.re))
0.0b
(- (pow x.re 3) (* (* 3 x.im) (* x.im x.re)))

rewrite16.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-exp-log
add-cbrt-cube
pow1
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
flip--
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
associate-*l*
associate-*r*
diff-log
flip3--
sub-neg
Counts
2 → 25
Calls
2 calls:
Slowest
8.0ms
(- (pow x.re 3) (* (* 3 x.im) (* x.im x.re)))
7.0ms
(* (* 3 x.im) (* x.im x.re))

series64.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
44.0ms
(- (pow x.re 3) (* (* 3 x.im) (* x.im x.re)))
20.0ms
(* (* 3 x.im) (* x.im x.re))

simplify1.2s

Counts
10 → 31
Calls
10 calls:
Slowest
649.0ms
(* (* (* (* 3 x.im) (* 3 x.im)) (* 3 x.im)) (* (* (* x.im x.re) (* x.im x.re)) (* x.im x.re)))
148.0ms
(/ (exp (pow x.re 3)) (exp (* (* 3 x.im) (* x.im x.re))))
104.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
101.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))
80.0ms
(- (pow x.re 3) (* 3 (* (pow x.im 2) x.re)))

prune263.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.0b

regimes103.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample2.4s

Algorithm
intervals
Results
2.2s14287×body80valid