Average Error: 58.1 → 0.7
Time: 41.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 2019008 
(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: 39.4s)Debug log

sample372.0ms

Algorithm
intervals

simplify189.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

188.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

localize19.0ms

Local error

Found 2 expressions with local error:

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

32.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
9.0ms
(- (exp (- 0 im)) (exp im))

series149.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify1.3s

Counts
24 → 43
Calls

24 calls. Slowest were:

189.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
179.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
166.0ms
(* 0.5 (* (- (exp (- im)) (exp im)) (cos re)))

prune563.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.1b

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

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

series274.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

171.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
41.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
35.0ms
(* 1/60 (pow im 5))
27.0ms
(* 1/3 (pow im 3))

simplify3.3s

Counts
39 → 76
Calls

39 calls. Slowest were:

331.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
299.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
298.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.0s

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 0.0b

localize15.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.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)))))

rewrite51.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

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

series668.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify8.2s

Counts
59 → 87
Calls

59 calls. Slowest were:

585.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))))
556.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)))))
502.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))))

prune1.6s

Pruning

10 alts after pruning (7 fresh and 3 done)

Merged error: 0.0b

localize42.0ms

Local error

Found 4 expressions with local error:

0.7b
(cbrt (* (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))))))
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))))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

12.0ms
(cbrt (* (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))))))
6.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
4.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

series718.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

210.0ms
(cbrt (* (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))))))
177.0ms
(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))))
160.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

simplify5.8s

Counts
36 → 68
Calls

36 calls. Slowest were:

387.0ms
(- (+ (* 1/27 (* (pow im 2) (exp (* 1/9 (+ (* 2 (log im)) (log 4)))))) (exp (* 1/9 (+ (* 2 (log im)) (log 4))))) (* 2/3645 (* (pow im 4) (exp (* 1/9 (+ (* 2 (log im)) (log 4)))))))
297.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)))))
284.0ms
(- (+ (* 1/18 (* (exp (* 1/3 (+ (log 2) (log im)))) (pow im 2))) (exp (* 1/3 (+ (log 2) (log im))))) (* 1/3240 (* (exp (* 1/3 (+ (log 2) (log im)))) (pow im 4))))

prune1.4s

Pruning

11 alts after pruning (7 fresh and 4 done)

Merged error: 0.0b

regimes644.0ms

Accuracy

0% (0.6b remaining)

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

bsearch12.0ms

end0.0ms

sample13.0s

Algorithm
intervals