Average Error: 58.0 → 0.8
Time: 45.3s
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.0
Target0.3
Herbie0.8
\[\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.0

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

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

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

sample387.0ms

Algorithm
intervals

simplify522.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 57.9b

localize19.0ms

Local error

Found 2 expressions with local error:

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

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

18.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
7.0ms
(- (exp (- 0 im)) (exp im))

series146.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

101.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
45.0ms
(- (exp (- 0 im)) (exp im))

simplify1.3s

Counts
24 → 43
Calls

24 calls. Slowest were:

212.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
192.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
185.0ms
(* 0.5 (* (- (exp (- im)) (exp im)) (cos re)))

prune566.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.1b

localize48.0ms

Local error

Found 4 expressions with local error:

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

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

21.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)))
2.0ms
(* 1/3 (pow im 3))

series237.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

165.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
26.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
26.0ms
(* 1/3 (pow im 3))
20.0ms
(* 1/60 (pow im 5))

simplify3.5s

Counts
39 → 76
Calls

39 calls. Slowest were:

388.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
355.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
263.0ms
(* (* (* (* 0.5 (cos re)) (* 0.5 (cos re))) (* 0.5 (cos 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 (10 fresh and 1 done)

Merged error: 0.0b

localize30.0ms

Local error

Found 4 expressions with local error:

0.6b
(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))))
0.6b
(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)))))

rewrite65.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

41.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)))))
8.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
8.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

series598.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

158.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)))))
156.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
150.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
134.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

simplify8.3s

Counts
59 → 87
Calls

59 calls. Slowest were:

580.0ms
(* (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))) (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
534.0ms
(* (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))) (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
334.0ms
(cbrt (- (* (* 1/3 (pow im 3)) (* 1/3 (pow im 3))) (* (+ (* 1/60 (pow im 5)) (* 2 im)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

prune1.6s

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 4 expressions with local error:

0.7b
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
0.7b
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
0.7b
(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)))))))

rewrite62.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

26.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))))))
12.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:

562.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)))))))
306.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
298.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
296.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))

simplify8.9s

Counts
49 → 77
Calls

49 calls. Slowest were:

472.0ms
(- (+ (* (exp (* 1/3 (+ (* 2 (log im)) (log 4)))) (pow (cbrt -0.5) 2)) (* 1/9 (* (exp (* 1/3 (+ (* 2 (log im)) (log 4)))) (* (pow im 2) (pow (cbrt -0.5) 2))))) (* 4/3 (* (pow im 2) (* (pow re 2) (* (exp (* 1/3 (- (log 1/16) (* 4 (log im))))) (pow (cbrt -0.5) 2))))))
386.0ms
(+ (* (exp (* 1/3 (- (log (* 1/60 (cos re))) (* 5 (log (/ 1 im)))))) (cbrt -0.5)) (* 20/3 (/ (* (exp (* 1/3 (- (log (* 1/60 (cos re))) (* 5 (log (/ 1 im)))))) (cbrt -0.5)) (pow im 2))))
373.0ms
(+ (* 20/3 (/ (* (cbrt 0.5) (exp (* 1/3 (- (log (* 1/60 (cos re))) (* 5 (log (/ -1 im))))))) (pow im 2))) (* (cbrt 0.5) (exp (* 1/3 (- (log (* 1/60 (cos re))) (* 5 (log (/ -1 im))))))))

prune1.3s

Pruning

12 alts after pruning (9 fresh and 3 done)

Merged error: 0.0b

regimes731.0ms

Accuracy

0% (0.7b remaining)

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

bsearch9.0ms

end0.0ms

sample12.6s

Algorithm
intervals