Average Error: 43.4 → 0.7
Time: 41.0s
Precision: 64
Internal Precision: 128
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\left(0.5 \cdot \sin re\right) \cdot \left(\left(im \cdot -2 + \frac{-1}{60} \cdot {im}^{5}\right) + \frac{-1}{3} \cdot {im}^{3}\right)\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original43.4
Target0.3
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(\frac{1}{6} \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(\frac{1}{120} \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 43.4

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
  2. Taylor expanded around 0 0.7

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)}\]
  3. Final simplification0.7

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(im \cdot -2 + \frac{-1}{60} \cdot {im}^{5}\right) + \frac{-1}{3} \cdot {im}^{3}\right)\]

Reproduce

herbie shell --seed 2019008 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"

  :herbie-target
  (if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

Details

Time bar (total: 39.0s)Debug log

sample430.0ms

Algorithm
intervals

simplify151.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

151.0ms
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 45.6b

localize39.0ms

Local error

Found 2 expressions with local error:

5.0b
(- (exp (- im)) (exp im))
0.0b
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

14.0ms
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))
10.0ms
(- (exp (- im)) (exp im))

series148.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

105.0ms
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))
43.0ms
(- (exp (- im)) (exp im))

simplify997.0ms

Counts
24 → 43
Calls

24 calls. Slowest were:

160.0ms
(* 0.5 (* (sin re) (- (exp (- im)) (exp im))))
153.0ms
(* 0.5 (* (sin re) (- (exp (* -1 im)) (exp im))))
118.0ms
(- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

prune456.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.1b

localize35.0ms

Local error

Found 4 expressions with local error:

0.1b
(* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
0.1b
(* 1/3 (pow im 3))
0.1b
(* 1/60 (pow im 5))
0.0b
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

20.0ms
(* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
12.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
2.0ms
(* 1/3 (pow im 3))

series242.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

157.0ms
(* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
30.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
27.0ms
(* 1/3 (pow im 3))
27.0ms
(* 1/60 (pow im 5))

simplify3.0s

Counts
39 → 76
Calls

39 calls. Slowest were:

357.0ms
(* (* 0.5 (sin re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
317.0ms
(* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
274.0ms
(* (* (* (* 0.5 (sin re)) (* 0.5 (sin re))) (* 0.5 (sin re))) (* (* (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

prune1.1s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

12.9b
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
12.9b
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
12.9b
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
0.5b
(* (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))) (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))

rewrite105.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

41.0ms
(* (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))) (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))
21.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
21.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

series1.4s

Counts
4 → 12
Calls

4 calls. Slowest were:

405.0ms
(* (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))) (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))
380.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
334.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
285.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

simplify9.5s

Counts
49 → 77
Calls

49 calls. Slowest were:

517.0ms
(+ (* (pow (cbrt 0.5) 2) (exp (* 1/3 (- (log (* 1/3600 (pow (sin re) 2))) (* 10 (log (/ -1 im))))))) (* 40/3 (/ (* (pow (cbrt 0.5) 2) (exp (* 1/3 (- (log (* 1/3600 (pow (sin re) 2))) (* 10 (log (/ -1 im))))))) (pow im 2))))
380.0ms
(sqrt (cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))
380.0ms
(- (+ (* (cbrt -0.5) (exp (* 1/3 (+ (log 2) (+ (log im) (log re)))))) (* 1/18 (* (pow im 2) (* (cbrt -0.5) (exp (* 1/3 (+ (log 2) (+ (log im) (log re))))))))) (* 1/18 (* (pow re 2) (* (cbrt -0.5) (exp (* 1/3 (+ (log 2) (+ (log im) (log re)))))))))

prune1.5s

Pruning

11 alts after pruning (8 fresh and 3 done)

Merged error: 0.0b

localize33.0ms

Local error

Found 4 expressions with local error:

12.9b
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
12.9b
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
0.7b
(cbrt (* 0.5 (sin re)))
0.7b
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

rewrite59.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

21.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
20.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
16.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

series947.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

303.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
293.0ms
(cbrt (* (* 0.5 (sin re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
196.0ms
(cbrt (* 0.5 (sin re)))
155.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

simplify4.4s

Counts
31 → 63
Calls

31 calls. Slowest were:

382.0ms
(+ (* 20/3 (/ (* (cbrt -0.5) (exp (* 1/3 (- (log (* 1/60 (sin re))) (* 5 (log (/ 1 im))))))) (pow im 2))) (* (cbrt -0.5) (exp (* 1/3 (- (log (* 1/60 (sin re))) (* 5 (log (/ 1 im))))))))
373.0ms
(cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3))))
365.0ms
(- (+ (* (cbrt -0.5) (exp (* 1/3 (+ (log 2) (+ (log im) (log re)))))) (* 1/18 (* (pow im 2) (* (cbrt -0.5) (exp (* 1/3 (+ (log 2) (+ (log im) (log re))))))))) (* 1/18 (* (pow re 2) (* (cbrt -0.5) (exp (* 1/3 (+ (log 2) (+ (log im) (log re)))))))))

prune1.3s

Pruning

12 alts after pruning (8 fresh and 4 done)

Merged error: 0.0b

regimes566.0ms

Accuracy

0% (0.6b remaining)

Error of 0.7b against oracle of 0.1b and baseline of 0.7b

bsearch10.0ms

end0.0ms

sample12.5s

Algorithm
intervals