Average Error: 58.0 → 0.7
Time: 58.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.0
Target0.3
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. 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 2018365 
(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: 37.8s)Debug log

start412.0ms

Algorithm
intervals

setup201.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 57.5b

localize35.0ms

Local error

Found 2 expressions with local error:

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

rewrite43.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

29.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
14.0ms
(- (exp (- 0 im)) (exp im))

series172.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

102.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
70.0ms
(- (exp (- 0 im)) (exp im))

simplify1.5s

Counts
24 → 43
Calls

24 calls. Slowest were:

229.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
225.0ms
(* 0.5 (* (- (exp (- im)) (exp im)) (cos re)))
199.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))

prune633.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.1b

localize52.0ms

Local error

Found 4 expressions with local error:

0.1b
(* (* 0.5 (cos 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/60 (pow im 5)) (* 2 im))

rewrite50.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

40.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
5.0ms
(+ (* 1/60 (pow im 5)) (* 2 im))
2.0ms
(* 1/3 (pow im 3))

series276.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

151.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
70.0ms
(+ (* 1/60 (pow im 5)) (* 2 im))
32.0ms
(* 1/60 (pow im 5))
22.0ms
(* 1/3 (pow im 3))

simplify3.3s

Counts
37 → 74
Calls

37 calls. Slowest were:

375.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))))))
335.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
332.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

prune1.7s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

localize11.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.4b
(* (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)))))))

rewrite84.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

41.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)))))))
16.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
14.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:

608.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)))))))
345.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
305.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
280.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:

415.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))))))))
412.0ms
(cbrt (* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
411.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))))))))

prune2.0s

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 (- (+ (* 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.5b
(* (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))))))

rewrite80.0ms

Algorithm
rewrite-expression-head
Counts
4 → 110
Calls

4 calls. Slowest were:

52.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))))))
11.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)))))

series719.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

198.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
185.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))))))
172.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
164.0ms
(cbrt (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))

simplify11.5s

Counts
94 → 122
Calls

94 calls. Slowest were:

850.0ms
(cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3))))
486.0ms
(cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3))))
451.0ms
(* (cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3)))) (cbrt (- (+ (pow (* 1/3 (pow im 3)) 3) (pow (+ (* 1/60 (pow im 5)) (* 2 im)) 3)))))

prune3.3s

Pruning

14 alts after pruning (12 fresh and 2 done)

Merged error: 0.0b

regimes852.0ms

Accuracy

0% (0.6b remaining)

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

bsearch11.0ms