Average Error: 6.8 → 0.2
Time: 11.1s
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 \cdot x.im\right) \cdot 3\right) \cdot x.re - {x.im}^{3}\]

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

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

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

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

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

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

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

Reproduce

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

sample69.0ms

Algorithm
intervals
Results
53.0ms431×body80valid

simplify150.0ms

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

prune18.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 7.0b

localize37.0ms

Local error

Found 2 expressions with local error:

7.0b
(* x.im (+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re))))
0.1b
(+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re)))

rewrite42.0ms

Algorithm
rewrite-expression-head
Rules
14×associate-*r/
frac-add
add-log-exp
flip-+
flip3-+
flip--
flip3--
add-cube-cbrt
associate-*r*
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
distribute-lft-in
sum-log
associate-+r+
associate-+l+
pow1
distribute-rgt-in
associate-+l-
*-commutative
diff-log
sub-neg
+-commutative
Counts
2 → 40
Calls
2 calls:
Slowest
24.0ms
(* x.im (+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re))))
17.0ms
(+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re)))

series66.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
45.0ms
(* x.im (+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re))))
21.0ms
(+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re)))

simplify5.2s

Counts
32 → 46
Calls
32 calls:
Slowest
679.0ms
(+ (* (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))) (+ (* x.re x.re) (- (* x.re x.re) (* x.re x.re)))) (* (+ (* x.re x.re) (* x.im x.im)) (* x.re (+ (pow x.re 3) (pow x.re 3)))))
618.0ms
(- (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re)))
566.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.re) (- (* x.re x.re) (* x.re x.re))))
559.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.re) (- (* x.re x.re) (* x.re x.re))))
394.0ms
(+ (- (* x.re x.re) (* x.im x.im)) (* x.re (+ x.re x.re)))

prune402.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 6.8b

localize26.0ms

Local error

Found 2 expressions with local error:

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

rewrite7.0ms

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

series53.0ms

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

simplify105.0ms

Counts
10 → 27
Calls
10 calls:
Slowest
31.0ms
(* 3 (* x.im (pow x.re 2)))
31.0ms
(* 3 (* x.im (pow x.re 2)))
26.0ms
(* 3 (* x.im (pow x.re 2)))
4.0ms
(* x.im (pow x.re 2))
4.0ms
(* x.im (pow x.re 2))

prune265.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

localize12.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.0ms

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

series59.0ms

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

simplify76.0ms

Counts
6 → 24
Calls
6 calls:
Slowest
28.0ms
(* 3 (* x.im (pow x.re 2)))
22.0ms
(* 3 (* x.im (pow x.re 2)))
16.0ms
(* 3 (* x.im (pow x.re 2)))
3.0ms
(* x.im (pow x.re 2))
3.0ms
(* x.im (pow x.re 2))

prune285.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 2 expressions with local error:

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

rewrite8.0ms

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

series44.0ms

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

simplify107.0ms

Counts
6 → 24
Calls
6 calls:
Slowest
27.0ms
(* 3 (* x.im (pow x.re 2)))
27.0ms
(* 3 (* x.im (pow x.re 2)))
27.0ms
(* 3 (* x.im (pow x.re 2)))
11.0ms
(* 3 (* x.im x.re))
8.0ms
(* 3 (* x.im x.re))

prune216.0ms

Pruning

8 alts after pruning (5 fresh and 3 done)

Merged error: 0.0b

regimes116.0ms

Accuracy

0% (0.1b remaining)

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

bsearch1.0ms

end0.0ms

sample2.8s

Algorithm
intervals
Results
2.2s14348×body80valid