Average Error: 58.0 → 0.8
Time: 28.0s
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 2019022 
(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: 26.5s)Debug log

sample733.0ms

Algorithm
intervals
Results
579.0ms175×body1280valid
84.0ms107×body640valid
24.0ms46×body320valid
18.0ms118×body80valid
9.0ms27×body160valid

simplify184.0ms

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 58.9b

localize41.0ms

Local error

Found 2 expressions with local error:

6.8b
(- (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
13.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
9.0ms
(- (exp (- 0 im)) (exp im))

series153.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
96.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))
56.0ms
(- (exp (- 0 im)) (exp im))

simplify1.3s

Counts
24 → 43
Calls
24 calls:
Slowest
191.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
174.0ms
(* 0.5 (* (- (exp (- im)) (exp im)) (cos re)))
154.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
150.0ms
(- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
146.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

prune481.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.1b

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

rewrite31.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
18.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
9.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
1.0ms
(* 1/60 (pow im 5))
1.0ms
(* 1/3 (pow im 3))

series195.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
117.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
32.0ms
(* 1/60 (pow im 5))
28.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
18.0ms
(* 1/3 (pow im 3))

simplify3.2s

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

prune980.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 0.0b

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

rewrite33.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
16.0ms
(* (cos re) (- (* 1.0 (- im)) (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
7.0ms
(+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))
6.0ms
(* (* 0.16666666666666666 im) (* im im))
2.0ms
(* 0.008333333333333333 (pow im 5))

series299.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
164.0ms
(* (cos re) (- (* 1.0 (- im)) (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
73.0ms
(+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))
35.0ms
(* 0.008333333333333333 (pow im 5))
28.0ms
(* (* 0.16666666666666666 im) (* im im))

simplify3.3s

Counts
33 → 70
Calls
33 calls:
Slowest
342.0ms
(* (* (* (* 0.16666666666666666 im) (* 0.16666666666666666 im)) (* 0.16666666666666666 im)) (* (* (* im im) (* im im)) (* im im)))
318.0ms
(* (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))) (cos re))
301.0ms
(* (cos re) (- (* 1.0 (- im)) (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
297.0ms
(* (cos re) (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))
279.0ms
(* (cos re) (- (+ (* 0.008333333333333333 (pow im 5)) (* (* 0.16666666666666666 im) (* im im)))))

prune929.0ms

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 0.0b

localize15.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.3b
(* (cbrt (cos re)) (cbrt (cos re)))

rewrite13.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
9.0ms
(* (cbrt (cos re)) (cbrt (cos re)))
1.0ms
(cbrt (cos re))
1.0ms
(cbrt (cos re))
1.0ms
(cbrt (cos re))

series694.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
234.0ms
(* (cbrt (cos re)) (cbrt (cos re)))
168.0ms
(cbrt (cos re))
157.0ms
(cbrt (cos re))
135.0ms
(cbrt (cos re))

simplify375.0ms

Counts
41 → 73
Calls
41 calls:
Slowest
91.0ms
(- 1 (+ (* 1/6 (pow re 2)) (* 1/72 (pow re 4))))
83.0ms
(- 1 (+ (* 1/6 (pow re 2)) (* 1/72 (pow re 4))))
80.0ms
(- 1 (+ (* 1/405 (pow re 6)) (* 1/3 (pow re 2))))
54.0ms
(- 1 (+ (* 1/6 (pow re 2)) (* 1/72 (pow re 4))))
3.0ms
(pow (cos re) 1/3)

prune1.1s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 0.0b

regimes503.0ms

Accuracy

0% (0.7b remaining)

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

bsearch8.0ms

end0.0ms

sample12.0s

Algorithm
intervals
Results
7.5s5772×body1280valid
2.5s3500×body640valid
786.0ms1488×body320valid
632.0ms4318×body80valid
197.0ms705×body160valid