Average Error: 58.0 → 0.7
Time: 48.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(\frac{-1}{3} \cdot im\right) \cdot im + -2)_*\right) \cdot im + \left({im}^{5} \cdot \frac{-1}{60}\right))_*\]

Error

Bits error versus re

Bits error versus im

Target

Original58.0
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.0

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

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

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

Reproduce

herbie shell --seed 2018360 +o rules:numerics
(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: 31.4s)Debug log

start399.0ms

Algorithm
intervals

setup206.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 58.2b

localize30.0ms

Local error

Found 2 expressions with local error:

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

rewrite28.0ms

Algorithm
rewrite-expression-head
Counts
2 → 91
Calls

2 calls. Slowest were:

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

series127.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

86.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
41.0ms
(- (exp (- 0 im)) (exp im))

simplify9.3s

Counts
88 → 97
Calls

88 calls. Slowest were:

455.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
371.0ms
(* (fma (- (cbrt (exp im))) (* (cbrt (exp im)) (cbrt (exp im))) (* (cbrt (exp im)) (* (cbrt (exp im)) (cbrt (exp im))))) (* 0.5 (cos re)))
370.0ms
(* (fma (- (cbrt (exp im))) (* (cbrt (exp im)) (cbrt (exp im))) (* (cbrt (exp im)) (* (cbrt (exp im)) (cbrt (exp im))))) (* 0.5 (cos re)))

prune1.4s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.2b

localize27.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

10.0ms
(* (* 0.5 (cos re)) (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
4.0ms
(* (pow im 5) -1/60)
0.0ms
(* -1/3 im)

series183.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

115.0ms
(* (* 0.5 (cos re)) (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
28.0ms
(fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))
26.0ms
(* (pow im 5) -1/60)
15.0ms
(* -1/3 im)

simplify2.3s

Counts
22 → 64
Calls

22 calls. Slowest were:

400.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
272.0ms
(- (+ (* 1.0 (* im (cos re))) (+ (* 0.16666666666666666 (* (pow im 3) (cos re))) (* 0.008333333333333333 (* (pow im 5) (cos re))))))
267.0ms
(- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

prune1.3s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

0.6b
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.6b
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.6b
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.4b
(* (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))) (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

9.0ms
(* (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))) (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))))
1.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
1.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))

series640.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

177.0ms
(* (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))) (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))))
170.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
155.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
138.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))

simplify5.4s

Counts
41 → 81
Calls

41 calls. Slowest were:

602.0ms
(* (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)) (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
463.0ms
(+ (* 40/3 (/ (exp (* 1/3 (- (log 1/3600) (* 10 (log (/ 1 im)))))) (pow im 2))) (+ (* 320/9 (/ (exp (* 1/3 (- (log 1/3600) (* 10 (log (/ 1 im)))))) (pow im 4))) (exp (* 1/3 (- (log 1/3600) (* 10 (log (/ 1 im))))))))
458.0ms
(- (+ (exp (* 1/3 (+ (log im) (log -2)))) (* 1/18 (* (exp (* 1/3 (+ (log im) (log -2)))) (pow im 2)))) (* 1/3240 (* (exp (* 1/3 (+ (log im) (log -2)))) (pow im 4))))

prune2.0s

Pruning

14 alts after pruning (12 fresh and 2 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 4 expressions with local error:

0.6b
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.6b
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.6b
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.4b
(* (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))) (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))))

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

5.0ms
(* (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))) (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))))
1.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
0.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))

series557.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

150.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
142.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
136.0ms
(cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60)))
129.0ms
(* (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))) (cbrt (fma (fma (* -1/3 im) im -2) im (* (pow im 5) -1/60))))

simplify4.8s

Counts
41 → 81
Calls

41 calls. Slowest were:

418.0ms
(+ (* 40/3 (/ (exp (* 1/3 (- (log 1/3600) (* 10 (log (/ 1 im)))))) (pow im 2))) (+ (* 320/9 (/ (exp (* 1/3 (- (log 1/3600) (* 10 (log (/ 1 im)))))) (pow im 4))) (exp (* 1/3 (- (log 1/3600) (* 10 (log (/ 1 im))))))))
395.0ms
(- (+ (exp (* 1/3 (+ (log im) (log -2)))) (* 1/18 (* (exp (* 1/3 (+ (log im) (log -2)))) (pow im 2)))) (* 1/3240 (* (exp (* 1/3 (+ (log im) (log -2)))) (pow im 4))))
390.0ms
(- (+ (exp (* 1/3 (+ (log im) (log -2)))) (* 1/18 (* (exp (* 1/3 (+ (log im) (log -2)))) (pow im 2)))) (* 1/3240 (* (exp (* 1/3 (+ (log im) (log -2)))) (pow im 4))))

prune1.8s

Pruning

14 alts after pruning (11 fresh and 3 done)

Merged error: 0.0b

regimes674.0ms

Accuracy

0% (0.7b remaining)

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

bsearch3.0ms