
Results
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
| Original | 65.8% |
|---|---|
| Target | 99.8% |
| Herbie | 99.8% |
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.5 or 4.0000000000000001e-8 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -0.5 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 4.0000000000000001e-8Initial program 27.0%
Taylor expanded in im around 0 99.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
mul-1-neg99.9%
*-commutative99.9%
distribute-lft-neg-in99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
distribute-lft-out99.9%
Simplified99.9%
Final simplification99.9%
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -2e-3 or 4.0000000000000001e-8 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.9%
if -2e-3 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 4.0000000000000001e-8Initial program 26.5%
Taylor expanded in im around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*l*99.9%
distribute-lft-out--99.9%
Simplified99.9%
Final simplification99.9%
if im < -3.9000000000000001e114 or 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -3.9000000000000001e114 < im < -12.5 or 4.2000000000000002e-4 < im < 4.4000000000000001e61Initial program 99.4%
Taylor expanded in re around 0 82.7%
if -12.5 < im < 4.2000000000000002e-4Initial program 26.6%
Taylor expanded in im around 0 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
Simplified99.2%
Final simplification96.8%
if im < -3.9000000000000001e114 or 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -3.9000000000000001e114 < im < -12.5 or 0.00119999999999999989 < im < 4.4000000000000001e61Initial program 99.7%
Taylor expanded in re around 0 82.7%
if -12.5 < im < 0.00119999999999999989Initial program 27.1%
Taylor expanded in im around 0 99.2%
mul-1-neg99.2%
unsub-neg99.2%
*-commutative99.2%
associate-*l*99.2%
distribute-lft-out--99.2%
Simplified99.2%
Final simplification96.8%
if im < -3.39999999999999991 or 4.2000000000000002e61 < im Initial program 100.0%
Taylor expanded in im around 0 91.6%
+-commutative91.6%
associate-+r+91.6%
+-commutative91.6%
mul-1-neg91.6%
*-commutative91.6%
distribute-lft-neg-in91.6%
*-commutative91.6%
associate-*r*91.6%
distribute-rgt-out91.6%
associate-*r*91.6%
*-commutative91.6%
associate-*l*91.6%
distribute-lft-out91.6%
Simplified91.6%
Taylor expanded in im around inf 91.6%
*-commutative91.6%
Simplified91.6%
if -3.39999999999999991 < im < 1.25999999999999999e-9Initial program 25.8%
Taylor expanded in im around 0 99.9%
mul-1-neg99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
if 1.25999999999999999e-9 < im < 4.2000000000000002e61Initial program 96.9%
Taylor expanded in im around 0 20.1%
+-commutative20.1%
associate-+r+20.1%
+-commutative20.1%
mul-1-neg20.1%
*-commutative20.1%
distribute-lft-neg-in20.1%
*-commutative20.1%
associate-*r*20.1%
distribute-rgt-out20.1%
associate-*r*20.1%
*-commutative20.1%
associate-*l*20.1%
distribute-lft-out20.1%
Simplified20.1%
Taylor expanded in re around 0 36.6%
Taylor expanded in im around 0 35.8%
Final simplification91.0%
if im < -2.7e7Initial program 100.0%
Taylor expanded in im around 0 90.3%
+-commutative90.3%
associate-+r+90.3%
+-commutative90.3%
mul-1-neg90.3%
*-commutative90.3%
distribute-lft-neg-in90.3%
*-commutative90.3%
associate-*r*90.3%
distribute-rgt-out90.3%
associate-*r*90.3%
*-commutative90.3%
associate-*l*90.3%
distribute-lft-out90.3%
Simplified90.3%
Taylor expanded in re around 0 81.1%
Taylor expanded in im around inf 81.1%
if -2.7e7 < im < 7.5e7Initial program 30.3%
Taylor expanded in im around 0 95.1%
mul-1-neg95.1%
*-commutative95.1%
distribute-rgt-neg-in95.1%
Simplified95.1%
if 7.5e7 < im Initial program 100.0%
Taylor expanded in im around 0 76.5%
+-commutative76.5%
associate-+r+76.5%
+-commutative76.5%
mul-1-neg76.5%
*-commutative76.5%
distribute-lft-neg-in76.5%
*-commutative76.5%
associate-*r*76.5%
distribute-rgt-out76.5%
associate-*r*76.5%
*-commutative76.5%
associate-*l*76.5%
distribute-lft-out76.5%
Simplified76.5%
Taylor expanded in re around 0 65.1%
Taylor expanded in im around inf 65.1%
Final simplification84.3%
if im < -2.4e9 or 2.8e6 < im Initial program 100.0%
Taylor expanded in im around 0 83.0%
+-commutative83.0%
associate-+r+83.0%
+-commutative83.0%
mul-1-neg83.0%
*-commutative83.0%
distribute-lft-neg-in83.0%
*-commutative83.0%
associate-*r*83.0%
distribute-rgt-out83.0%
associate-*r*83.0%
*-commutative83.0%
associate-*l*83.0%
distribute-lft-out83.0%
Simplified83.0%
Taylor expanded in re around 0 72.6%
Taylor expanded in im around inf 72.6%
if -2.4e9 < im < 2.8e6Initial program 30.3%
Taylor expanded in im around 0 95.1%
mul-1-neg95.1%
*-commutative95.1%
distribute-rgt-neg-in95.1%
Simplified95.1%
Final simplification84.3%
if im < -2.20000000000000001e43 or 3.8e8 < im Initial program 100.0%
Taylor expanded in im around 0 4.4%
mul-1-neg4.4%
*-commutative4.4%
distribute-rgt-neg-in4.4%
Simplified4.4%
Taylor expanded in re around 0 12.4%
mul-1-neg12.4%
*-commutative12.4%
distribute-rgt-neg-in12.4%
Simplified12.4%
if -2.20000000000000001e43 < im < 3.8e8Initial program 32.3%
Taylor expanded in im around 0 92.4%
mul-1-neg92.4%
*-commutative92.4%
distribute-rgt-neg-in92.4%
Simplified92.4%
Final simplification55.2%
Initial program 63.8%
Taylor expanded in im around 0 51.5%
mul-1-neg51.5%
*-commutative51.5%
distribute-rgt-neg-in51.5%
Simplified51.5%
Taylor expanded in re around 0 31.9%
mul-1-neg31.9%
*-commutative31.9%
distribute-rgt-neg-in31.9%
Simplified31.9%
Final simplification31.9%
Initial program 63.8%
Taylor expanded in im around 0 89.7%
+-commutative89.7%
associate-+r+89.7%
+-commutative89.7%
mul-1-neg89.7%
*-commutative89.7%
distribute-lft-neg-in89.7%
*-commutative89.7%
associate-*r*89.7%
distribute-rgt-out89.7%
associate-*r*89.7%
*-commutative89.7%
associate-*l*89.7%
distribute-lft-out89.7%
Simplified89.7%
Applied egg-rr2.8%
Final simplification2.8%
Initial program 63.8%
Taylor expanded in im around 0 89.7%
+-commutative89.7%
associate-+r+89.7%
+-commutative89.7%
mul-1-neg89.7%
*-commutative89.7%
distribute-lft-neg-in89.7%
*-commutative89.7%
associate-*r*89.7%
distribute-rgt-out89.7%
associate-*r*89.7%
*-commutative89.7%
associate-*l*89.7%
distribute-lft-out89.7%
Simplified89.7%
Applied egg-rr2.9%
Final simplification2.9%
Initial program 63.8%
Taylor expanded in im around 0 89.7%
+-commutative89.7%
associate-+r+89.7%
+-commutative89.7%
mul-1-neg89.7%
*-commutative89.7%
distribute-lft-neg-in89.7%
*-commutative89.7%
associate-*r*89.7%
distribute-rgt-out89.7%
associate-*r*89.7%
*-commutative89.7%
associate-*l*89.7%
distribute-lft-out89.7%
Simplified89.7%
Applied egg-rr2.9%
Final simplification2.9%
Initial program 63.8%
Taylor expanded in im around 0 89.7%
+-commutative89.7%
associate-+r+89.7%
+-commutative89.7%
mul-1-neg89.7%
*-commutative89.7%
distribute-lft-neg-in89.7%
*-commutative89.7%
associate-*r*89.7%
distribute-rgt-out89.7%
associate-*r*89.7%
*-commutative89.7%
associate-*l*89.7%
distribute-lft-out89.7%
Simplified89.7%
Applied egg-rr12.4%
Final simplification12.4%
herbie shell --seed 2023166
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))