
Results
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -inf.0 or 9.9999999999999995e-8 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 9.9999999999999995e-8Initial program 32.4%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification99.9%
if im < -1.8500000000000001e143 or 1.30000000000000003e102 < im Initial program 100.0%
Taylor expanded in im around 0 98.8%
mul-1-neg98.8%
unsub-neg98.8%
*-commutative98.8%
associate-*l*98.8%
distribute-lft-out--98.8%
Simplified98.8%
Taylor expanded in im around inf 98.8%
*-commutative98.8%
associate-*l*98.8%
*-commutative98.8%
Simplified98.8%
if -1.8500000000000001e143 < im < -0.021499999999999998 or 0.0115 < im < 1.30000000000000003e102Initial program 100.0%
Taylor expanded in re around 0 85.1%
if -0.021499999999999998 < im < 0.0115Initial program 32.4%
Taylor expanded in im around 0 99.7%
mul-1-neg99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Final simplification96.8%
if im < -1.8500000000000001e143 or 1.30000000000000003e102 < im Initial program 100.0%
Taylor expanded in im around 0 98.8%
mul-1-neg98.8%
unsub-neg98.8%
*-commutative98.8%
associate-*l*98.8%
distribute-lft-out--98.8%
Simplified98.8%
Taylor expanded in im around inf 98.8%
*-commutative98.8%
associate-*l*98.8%
*-commutative98.8%
Simplified98.8%
if -1.8500000000000001e143 < im < -0.154999999999999999 or 0.0580000000000000029 < im < 1.30000000000000003e102Initial program 100.0%
Taylor expanded in re around 0 85.1%
if -0.154999999999999999 < im < 0.0580000000000000029Initial program 32.4%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification96.8%
if im < -2.99999999999999991e95 or 6.40000000000000032e97 < im Initial program 100.0%
Taylor expanded in im around 0 93.5%
mul-1-neg93.5%
unsub-neg93.5%
*-commutative93.5%
associate-*l*93.5%
distribute-lft-out--93.5%
Simplified93.5%
Taylor expanded in im around inf 93.5%
*-commutative93.5%
associate-*l*93.5%
*-commutative93.5%
Simplified93.5%
if -2.99999999999999991e95 < im < -640Initial program 100.0%
Taylor expanded in im around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
distribute-rgt-neg-in3.2%
Simplified3.2%
Taylor expanded in re around 0 7.7%
Taylor expanded in re around inf 20.5%
add-sqr-sqrt20.5%
sqrt-unprod53.8%
swap-sqr53.9%
pow-prod-up53.9%
metadata-eval53.9%
Applied egg-rr53.9%
*-commutative53.9%
metadata-eval53.9%
pow-sqr53.9%
swap-sqr53.8%
rem-sqrt-square53.8%
*-commutative53.8%
Simplified53.8%
if -640 < im < 1.2e17Initial program 33.9%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
if 1.2e17 < im < 6.40000000000000032e97Initial program 100.0%
Taylor expanded in re around 0 88.2%
Taylor expanded in im around 0 43.4%
+-commutative43.4%
mul-1-neg43.4%
unsub-neg43.4%
*-commutative43.4%
associate-*l*43.4%
*-commutative43.4%
distribute-lft-out--43.4%
Simplified43.4%
Taylor expanded in im around inf 43.4%
Final simplification90.1%
if im < -4.2e95 or 6.40000000000000032e97 < im Initial program 100.0%
Taylor expanded in im around 0 93.5%
mul-1-neg93.5%
unsub-neg93.5%
*-commutative93.5%
associate-*l*93.5%
distribute-lft-out--93.5%
Simplified93.5%
Taylor expanded in im around inf 93.5%
*-commutative93.5%
associate-*l*93.5%
*-commutative93.5%
Simplified93.5%
if -4.2e95 < im < -600Initial program 100.0%
Taylor expanded in im around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
distribute-rgt-neg-in3.2%
Simplified3.2%
Taylor expanded in re around 0 7.7%
Taylor expanded in re around inf 20.5%
add-sqr-sqrt20.5%
sqrt-unprod53.8%
swap-sqr53.9%
pow-prod-up53.9%
metadata-eval53.9%
Applied egg-rr53.9%
*-commutative53.9%
metadata-eval53.9%
pow-sqr53.9%
swap-sqr53.8%
rem-sqrt-square53.8%
*-commutative53.8%
Simplified53.8%
if -600 < im < 1.8e21Initial program 33.9%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
if 1.8e21 < im < 6.40000000000000032e97Initial program 100.0%
Taylor expanded in re around 0 88.2%
Taylor expanded in im around 0 43.4%
+-commutative43.4%
mul-1-neg43.4%
unsub-neg43.4%
*-commutative43.4%
associate-*l*43.4%
*-commutative43.4%
distribute-lft-out--43.4%
Simplified43.4%
Taylor expanded in im around inf 43.4%
*-commutative43.4%
*-commutative43.4%
associate-*l*43.4%
Simplified43.4%
add-cube-cbrt43.4%
pow343.4%
cbrt-prod43.4%
rem-cbrt-cube43.4%
Applied egg-rr43.4%
Final simplification90.1%
if im < -6.7999999999999996e83 or 1.8e17 < im < 6.50000000000000001e100 or 3.2999999999999999e155 < im Initial program 100.0%
Taylor expanded in re around 0 73.6%
Taylor expanded in im around 0 61.1%
+-commutative61.1%
mul-1-neg61.1%
unsub-neg61.1%
*-commutative61.1%
associate-*l*61.1%
*-commutative61.1%
distribute-lft-out--61.1%
Simplified61.1%
add-sqr-sqrt29.8%
sqrt-unprod48.4%
swap-sqr48.4%
metadata-eval48.4%
pow-prod-up48.4%
metadata-eval48.4%
Applied egg-rr48.4%
metadata-eval48.4%
metadata-eval48.4%
pow-sqr48.4%
swap-sqr48.4%
sqrt-unprod29.8%
add-sqr-sqrt61.1%
unpow361.1%
associate-*r*61.1%
Applied egg-rr61.1%
if -6.7999999999999996e83 < im < -620Initial program 100.0%
Taylor expanded in im around 0 3.1%
mul-1-neg3.1%
*-commutative3.1%
distribute-rgt-neg-in3.1%
Simplified3.1%
Taylor expanded in re around 0 8.6%
Taylor expanded in re around inf 23.6%
add-sqr-sqrt23.6%
sqrt-unprod54.4%
swap-sqr54.4%
pow-prod-up54.4%
metadata-eval54.4%
Applied egg-rr54.4%
*-commutative54.4%
metadata-eval54.4%
pow-sqr54.4%
swap-sqr54.4%
rem-sqrt-square54.4%
*-commutative54.4%
Simplified54.4%
if -620 < im < 1.8e17Initial program 33.9%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
if 6.50000000000000001e100 < im < 3.2999999999999999e155Initial program 100.0%
Taylor expanded in im around 0 4.0%
mul-1-neg4.0%
*-commutative4.0%
distribute-rgt-neg-in4.0%
Simplified4.0%
Taylor expanded in re around 0 17.8%
+-commutative17.8%
mul-1-neg17.8%
unsub-neg17.8%
associate-*r*17.8%
distribute-rgt-out--67.8%
Simplified67.8%
Final simplification81.1%
if im < -1450 or 1.1e22 < im < 6.50000000000000016e101 or 4.2e155 < im Initial program 100.0%
Taylor expanded in re around 0 74.0%
Taylor expanded in im around 0 54.8%
+-commutative54.8%
mul-1-neg54.8%
unsub-neg54.8%
*-commutative54.8%
associate-*l*54.8%
*-commutative54.8%
distribute-lft-out--54.8%
Simplified54.8%
add-sqr-sqrt27.4%
sqrt-unprod45.5%
swap-sqr45.5%
metadata-eval45.5%
pow-prod-up45.5%
metadata-eval45.5%
Applied egg-rr45.5%
metadata-eval45.5%
metadata-eval45.5%
pow-sqr45.5%
swap-sqr45.5%
sqrt-unprod27.4%
add-sqr-sqrt54.8%
unpow354.8%
associate-*r*54.8%
Applied egg-rr54.8%
if -1450 < im < 1.1e22Initial program 33.9%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
if 6.50000000000000016e101 < im < 4.2e155Initial program 100.0%
Taylor expanded in im around 0 4.0%
mul-1-neg4.0%
*-commutative4.0%
distribute-rgt-neg-in4.0%
Simplified4.0%
Taylor expanded in re around 0 17.8%
+-commutative17.8%
mul-1-neg17.8%
unsub-neg17.8%
associate-*r*17.8%
distribute-rgt-out--67.8%
Simplified67.8%
Final simplification78.8%
if im < -640 or 2.5e17 < im < 9.99999999999999977e101 or 3.2999999999999999e155 < im Initial program 100.0%
Taylor expanded in re around 0 74.0%
Taylor expanded in im around 0 54.8%
+-commutative54.8%
mul-1-neg54.8%
unsub-neg54.8%
*-commutative54.8%
associate-*l*54.8%
*-commutative54.8%
distribute-lft-out--54.8%
Simplified54.8%
add-sqr-sqrt27.4%
sqrt-unprod45.5%
swap-sqr45.5%
metadata-eval45.5%
pow-prod-up45.5%
metadata-eval45.5%
Applied egg-rr45.5%
metadata-eval45.5%
metadata-eval45.5%
pow-sqr45.5%
swap-sqr45.5%
sqrt-unprod27.4%
add-sqr-sqrt54.8%
unpow354.8%
associate-*r*54.8%
Applied egg-rr54.8%
if -640 < im < 2.5e17Initial program 33.9%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
if 9.99999999999999977e101 < im < 3.2999999999999999e155Initial program 100.0%
Taylor expanded in im around 0 4.0%
mul-1-neg4.0%
*-commutative4.0%
distribute-rgt-neg-in4.0%
Simplified4.0%
Taylor expanded in re around 0 17.8%
Taylor expanded in re around inf 67.0%
Final simplification78.8%
if im < -430 or 1.1e18 < im Initial program 100.0%
Taylor expanded in re around 0 69.8%
Taylor expanded in im around 0 52.6%
+-commutative52.6%
mul-1-neg52.6%
unsub-neg52.6%
*-commutative52.6%
associate-*l*52.6%
*-commutative52.6%
distribute-lft-out--52.6%
Simplified52.6%
add-sqr-sqrt24.5%
sqrt-unprod47.7%
swap-sqr47.7%
metadata-eval47.7%
pow-prod-up47.7%
metadata-eval47.7%
Applied egg-rr47.7%
metadata-eval47.7%
metadata-eval47.7%
pow-sqr47.7%
swap-sqr47.7%
sqrt-unprod24.5%
add-sqr-sqrt52.6%
unpow352.6%
associate-*r*52.6%
Applied egg-rr52.6%
if -430 < im < 1.1e18Initial program 33.9%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
Final simplification77.2%
Initial program 63.8%
Taylor expanded in re around 0 49.1%
Taylor expanded in im around 0 48.8%
+-commutative48.8%
mul-1-neg48.8%
unsub-neg48.8%
*-commutative48.8%
associate-*l*48.8%
*-commutative48.8%
distribute-lft-out--48.8%
Simplified48.8%
add-sqr-sqrt33.6%
sqrt-unprod46.9%
swap-sqr46.9%
metadata-eval46.9%
pow-prod-up46.9%
metadata-eval46.9%
Applied egg-rr46.9%
metadata-eval46.9%
metadata-eval46.9%
pow-sqr46.9%
swap-sqr46.9%
sqrt-unprod33.6%
add-sqr-sqrt48.8%
unpow348.8%
associate-*r*48.8%
Applied egg-rr48.8%
Final simplification48.8%
Initial program 63.8%
Taylor expanded in re around 0 49.1%
Taylor expanded in im around 0 33.0%
mul-1-neg33.0%
distribute-rgt-neg-in33.0%
Simplified33.0%
Final simplification33.0%
Initial program 63.8%
Taylor expanded in re around 0 49.1%
Applied egg-rr2.8%
Final simplification2.8%
Initial program 63.8%
Taylor expanded in re around 0 49.1%
Applied egg-rr2.9%
Final simplification2.9%
Initial program 63.8%
Taylor expanded in re around 0 49.1%
Applied egg-rr17.3%
Final simplification17.3%
herbie shell --seed 2023167
(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))))