Average Error: 58.1 → 0.7
Time: 49.0s
Precision: 64
Internal Precision: 128
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(0.5 \cdot \cos 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

Original58.1
Target0.2
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos 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 \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 58.1

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

    \[\leadsto \left(0.5 \cdot \cos 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 \cos 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 2019002 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"

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

  (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))

Details

Time bar (total: 47.5s)Debug log

sample335.0ms

Algorithm
intervals

simplify173.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

173.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 58.3b

localize32.0ms

Local error

Found 2 expressions with local error:

7.0b
(- (exp (- 0 im)) (exp im))
0.0b
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

rewrite49.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

35.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
13.0ms
(- (exp (- 0 im)) (exp im))

series193.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

124.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
68.0ms
(- (exp (- 0 im)) (exp im))

simplify1.5s

Counts
24 → 43
Calls

24 calls. Slowest were:

214.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
182.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
173.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

prune536.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize33.0ms

Local error

Found 4 expressions with local error:

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

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

18.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
6.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
1.0ms
(* 1/3 (pow im 3))

series208.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

122.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
42.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
28.0ms
(* 1/60 (pow im 5))
16.0ms
(* 1/3 (pow im 3))

simplify3.4s

Counts
39 → 76
Calls

39 calls. Slowest were:

379.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
307.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
236.0ms
(* (- (+ (* 1/60 (pow im 5)) (* 2 im))) (* 0.5 (cos re)))

prune1.2s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

localize12.0ms

Local error

Found 4 expressions with local error:

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

rewrite53.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

19.0ms
(* (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))) (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))
12.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
10.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

series1.5s

Counts
4 → 12
Calls

4 calls. Slowest were:

593.0ms
(* (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))) (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))
330.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
300.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
248.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

simplify9.2s

Counts
49 → 77
Calls

49 calls. Slowest were:

651.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
420.0ms
(* (cbrt (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))) (cbrt (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))))
394.0ms
(sqrt (cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))))

prune1.3s

Pruning

13 alts after pruning (11 fresh and 2 done)

Merged error: 0.0b

localize27.0ms

Local error

Found 4 expressions with local error:

0.7b
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
0.7b
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
0.7b
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
0.6b
(* (cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))) (cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

rewrite76.0ms

Algorithm
rewrite-expression-head
Counts
4 → 110
Calls

4 calls. Slowest were:

42.0ms
(* (cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))) (cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
15.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
9.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

series720.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

221.0ms
(* (cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))) (cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
178.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
178.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
143.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

simplify11.2s

Counts
94 → 122
Calls

94 calls. Slowest were:

497.0ms
(cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3))))
474.0ms
(cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3))))
418.0ms
(cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3))))

prune2.1s

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 0.0b

regimes463.0ms

Accuracy

0% (0.7b remaining)

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

bsearch9.0ms

end0.0ms

sample13.1s

Algorithm
intervals