Average Error: 58.0 → 0.7
Time: 37.4s
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 2019021 
(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: 35.9s)Debug log

sample281.0ms

Algorithm
intervals
Results
137.0ms185×body1280valid
57.0ms114×body640valid
34.0ms16×body160valid
18.0ms57×body320valid
13.0ms133×body80valid

simplify143.0ms

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 58.3b

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

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

series142.0ms

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

simplify1.4s

Counts
24 → 43
Calls
24 calls:
Slowest
223.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))
202.0ms
(* 0.5 (* (- (exp (- im)) (exp im)) (cos re)))
201.0ms
(* 0.5 (* (- (exp (* -1 im)) (exp im)) (cos re)))
150.0ms
(- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
137.0ms
(* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

prune545.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.1b

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

rewrite53.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
36.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
12.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
2.0ms
(* 1/3 (pow im 3))
2.0ms
(* 1/60 (pow im 5))

series202.0ms

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

simplify3.0s

Counts
39 → 76
Calls
39 calls:
Slowest
318.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))))
304.0ms
(* (* 0.5 (cos re)) (- (+ (* 1/60 (pow im 5)) (* 2 im))))
266.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))))))
184.0ms
(+ (log (* 0.5 (cos re))) (log (- (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))))
181.0ms
(- (* 0.5 (* (pow re 2) im)) (+ (* 0.16666666666666666 (pow im 3)) (* 1.0 im)))

prune975.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.1b

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

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
18×cbrt-div
15×cbrt-prod
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
flip-+
flip3-+
pow1
pow1/3
add-exp-log
associate-*l*
associate-*r*
add-log-exp
add-cbrt-cube
frac-times
pow-prod-up
associate-*r/
associate-*l/
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 75
Calls
4 calls:
Slowest
19.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)))))
4.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))))
4.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

series617.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
168.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)))))
164.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
157.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
128.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

simplify8.2s

Counts
59 → 87
Calls
59 calls:
Slowest
597.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))))
512.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))))
425.0ms
(+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im)))
349.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))))))))
293.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

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

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

rewrite37.0ms

Algorithm
rewrite-expression-head
Rules
12×cbrt-prod
add-cube-cbrt
*-un-lft-identity
cbrt-div
add-sqr-sqrt
add-log-exp
flip-+
add-exp-log
pow1/3
add-cbrt-cube
flip3-+
pow1
Counts
4 → 52
Calls
4 calls:
Slowest
12.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))))
8.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))))

series589.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
168.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
143.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
141.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))
136.0ms
(cbrt (+ (* 1/3 (pow im 3)) (+ (* 1/60 (pow im 5)) (* 2 im))))

simplify4.4s

Counts
32 → 64
Calls
32 calls:
Slowest
308.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)))))
297.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))))
295.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))))
268.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)))))
257.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.1s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 0.0b

regimes446.0ms

Accuracy

0% (0.7b remaining)

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

bsearch18.0ms

end0.0ms

sample12.2s

Algorithm
intervals
Results
7.1s5691×body1280valid
2.7s3506×body640valid
1.1s4337×body80valid
837.0ms1502×body320valid
221.0ms701×body160valid