Average Error: 58.0 → 0.8
Time: 28.8s
Precision: 64
Internal Precision: 128
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(im \cdot \left(-1.0\right) - \left(\left(0.16666666666666666 \cdot im\right) \cdot \left(im \cdot im\right) + 0.008333333333333333 \cdot {im}^{5}\right)\right) \cdot \cos re\]

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.2
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. Taylor expanded around inf 0.8

    \[\leadsto \color{blue}{-\left(1.0 \cdot \left(im \cdot \cos re\right) + \left(0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + 0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)\right)\right)}\]
  4. Simplified0.8

    \[\leadsto \color{blue}{\cos re \cdot \left(1.0 \cdot \left(-im\right) - \left(0.008333333333333333 \cdot {im}^{5} + \left(0.16666666666666666 \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\]
  5. Final simplification0.8

    \[\leadsto \left(im \cdot \left(-1.0\right) - \left(\left(0.16666666666666666 \cdot im\right) \cdot \left(im \cdot im\right) + 0.008333333333333333 \cdot {im}^{5}\right)\right) \cdot \cos re\]

Reproduce

herbie shell --seed 2019016 
(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: 27.3s)Debug log

sample371.0ms

Algorithm
intervals
Results
520×(pre true 80)
191×(body real 1280)
144×(body real 80)
109×(body real 640)
52×(body real 320)
24×(body real 160)

simplify128.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
128.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

prune16.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 58.1b

localize33.0ms

Local error

Found 2 expressions with local error:

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

rewrite22.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
add-sqr-sqrt
associate-*r*
add-log-exp
add-exp-log
add-cbrt-cube
pow1
add-cube-cbrt
sub-neg
difference-of-squares
distribute-lft-out--
flip--
associate-*r/
flip3--
distribute-lft-in
distribute-rgt-in
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
associate-*l*
diff-log
Counts
2 → 37
Calls
2 calls:
Slowest
14.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
7.0ms
(- (exp (- 0 im)) (exp im))

series153.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
109.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
182.0ms
(* 0.5 (* (- (exp (- im)) (exp im)) (cos re)))
172.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
168.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
127.0ms
(- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
123.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

prune540.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

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

rewrite38.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*r*
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
*-commutative
distribute-rgt-neg-in
sum-log
distribute-lft-neg-in
distribute-neg-frac
flip-+
associate-*r/
flip3-+
distribute-neg-in
cbrt-unprod
distribute-rgt-neg-out
prod-exp
pow-prod-down
associate-*l*
unpow3
distribute-lft-in
neg-mul-1
associate-+r+
+-commutative
cube-mult
distribute-rgt-in
Counts
4 → 64
Calls
4 calls:
Slowest
26.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))
1.0ms
(* 1/60 (pow im 5))

series240.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
143.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
39.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
35.0ms
(* 1/60 (pow im 5))
22.0ms
(* 1/3 (pow im 3))

simplify3.4s

Counts
39 → 76
Calls
39 calls:
Slowest
340.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
332.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
280.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))))))
253.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
226.0ms
(* (- (+ (* 1/60 (pow im 5)) (* 2 im))) (* 0.5 (cos re)))

prune1.5s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize31.0ms

Local error

Found 4 expressions with local error:

0.1b
(* (cos re) (- (* 1.0 (- im)) (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
0.1b
(* (* 0.16666666666666666 im) (* im im))
0.1b
(* 0.008333333333333333 (pow im 5))
0.0b
(+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))

rewrite30.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
add-cbrt-cube
pow1
add-cube-cbrt
associate-*r*
*-un-lft-identity
add-sqr-sqrt
add-log-exp
associate-*l*
*-commutative
cbrt-unprod
associate-*r/
prod-exp
pow-prod-down
distribute-lft-in
sub-neg
distribute-rgt-in
flip--
flip-+
flip3--
flip3-+
sum-log
+-commutative
Counts
4 → 58
Calls
4 calls:
Slowest
22.0ms
(* (cos re) (- (* 1.0 (- im)) (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
4.0ms
(+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))
3.0ms
(* (* 0.16666666666666666 im) (* im im))
1.0ms
(* 0.008333333333333333 (pow im 5))

series243.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
119.0ms
(* (cos re) (- (* 1.0 (- im)) (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
72.0ms
(+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))
28.0ms
(* (* 0.16666666666666666 im) (* im im))
23.0ms
(* 0.008333333333333333 (pow im 5))

simplify3.1s

Counts
33 → 70
Calls
33 calls:
Slowest
355.0ms
(* (* (* (* 0.16666666666666666 im) (* 0.16666666666666666 im)) (* 0.16666666666666666 im)) (* (* (* im im) (* im im)) (* im im)))
316.0ms
(* (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))) (cos re))
280.0ms
(* (cos re) (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
263.0ms
(* (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))) (cos re))
242.0ms
(* (cos re) (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))

prune979.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 4 expressions with local error:

0.3b
(cbrt (cos re))
0.3b
(cbrt (cos re))
0.3b
(cbrt (cos re))
0.2b
(* (cbrt (cos re)) (cbrt (cos re)))

rewrite7.0ms

Algorithm
rewrite-expression-head
Rules
15×cbrt-prod
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
pow1
pow1/3
add-exp-log
associate-*l*
associate-*r*
add-log-exp
add-cbrt-cube
pow-prod-up
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 61
Calls
4 calls:
Slowest
5.0ms
(* (cbrt (cos re)) (cbrt (cos re)))
1.0ms
(cbrt (cos re))
1.0ms
(cbrt (cos re))
1.0ms
(cbrt (cos re))

series716.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
222.0ms
(* (cbrt (cos re)) (cbrt (cos re)))
175.0ms
(cbrt (cos re))
160.0ms
(cbrt (cos re))
158.0ms
(cbrt (cos re))

simplify313.0ms

Counts
41 → 73
Calls
41 calls:
Slowest
72.0ms
(- 1 (+ (* 1/405 (pow re 6)) (* 1/3 (pow re 2))))
62.0ms
(- 1 (+ (* 1/6 (pow re 2)) (* 1/72 (pow re 4))))
61.0ms
(- 1 (+ (* 1/6 (pow re 2)) (* 1/72 (pow re 4))))
59.0ms
(- 1 (+ (* 1/6 (pow re 2)) (* 1/72 (pow re 4))))
4.0ms
(pow (cos re) 1/3)

prune1.1s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

regimes471.0ms

Accuracy

0% (0.7b remaining)

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

bsearch10.0ms

end0.0ms

sample12.5s

Algorithm
intervals
Results
15930×(pre true 80)
5734×(body real 1280)
4437×(body real 80)
3638×(body real 640)
1483×(body real 320)
638×(body real 160)