Average Error: 6.7 → 0.2
Time: 13.4s
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.7
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.7

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

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

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

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

sample76.0ms

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

simplify256.0ms

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

prune18.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 6.0b

localize38.0ms

Local error

Found 4 expressions with local error:

6.0b
(* 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))
0.0b
(- (* x.re x.re) (* x.im x.im))

rewrite72.0ms

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

series134.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
46.0ms
(* x.re (- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im))))
37.0ms
(- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im)))
27.0ms
(- (* x.re x.re) (* x.im x.im))
24.0ms
(+ (* x.im x.im) (* x.im x.im))

simplify6.3s

Counts
56 → 90
Calls
56 calls:
Slowest
449.0ms
(* (- (+ (* x.im x.im) (* x.im x.im))) x.re)
413.0ms
(+ (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im)))
323.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)))))
277.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)))))
251.0ms
(cbrt (- (- (* x.re x.re) (* x.im x.im)) (+ (* x.im x.im) (* x.im x.im))))

prune804.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 5.9b

localize29.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.0ms

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

series37.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
19.0ms
(* 3 (* (pow x.im 2) x.re))
18.0ms
(* (pow x.im 2) x.re)

simplify105.0ms

Counts
8 → 27
Calls
8 calls:
Slowest
33.0ms
(* 3 (* (pow x.im 2) x.re))
32.0ms
(* 3 (* (pow x.im 2) x.re))
20.0ms
(* 3 (* (pow x.im 2) x.re))
5.0ms
(* (pow x.im 2) x.re)
4.0ms
(* (pow x.im 2) x.re)

prune272.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 2 expressions with local error:

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

rewrite3.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
*-commutative
add-exp-log
associate-*r*
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
Counts
2 → 18
Calls
2 calls:
Slowest
2.0ms
(* 3 (* x.im (* x.im x.re)))
1.0ms
(* x.im (* x.im x.re))

series28.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
14.0ms
(* 3 (* x.im (* x.im x.re)))
13.0ms
(* x.im (* x.im x.re))

simplify102.0ms

Counts
7 → 24
Calls
7 calls:
Slowest
33.0ms
(* 3 (* (pow x.im 2) x.re))
25.0ms
(* 3 (* (pow x.im 2) x.re))
18.0ms
(* 3 (* (pow x.im 2) x.re))
8.0ms
(* (pow x.im 2) x.re)
7.0ms
(* (pow x.im 2) x.re)

prune253.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 1 expressions with local error:

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

rewrite6.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
add-cbrt-cube
pow1
add-log-exp
cbrt-unprod
add-cube-cbrt
*-commutative
prod-exp
pow-prod-down
associate-*l*
associate-*r*
*-un-lft-identity
add-sqr-sqrt
Counts
1 → 13
Calls
1 calls:
Slowest
6.0ms
(* (* 3 x.im) (* x.im x.re))

series21.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
21.0ms
(* (* 3 x.im) (* x.im x.re))

simplify809.0ms

Counts
6 → 16
Calls
6 calls:
Slowest
691.0ms
(* (* (* (* 3 x.im) (* 3 x.im)) (* 3 x.im)) (* (* (* x.im x.re) (* x.im x.re)) (* x.im x.re)))
33.0ms
(* 3 (* (pow x.im 2) x.re))
26.0ms
(* 3 (* (pow x.im 2) x.re))
24.0ms
(* (* 3 x.im) (* x.im x.re))
18.0ms
(+ (log (* 3 x.im)) (log (* x.im x.re)))

prune122.0ms

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 0.0b

regimes115.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample3.0s

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