File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 26282628 *
26292629 */
26302630 function cosine ( Ctor , x ) {
2631- var k , y ,
2632- len = x . d . length ;
2633-
2631+ var k , len , y ;
2632+
2633+ if ( x . isZero ( ) ) return x ;
2634+
26342635 // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1
26352636 // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1
26362637
26372638 // Estimate the optimum number of times to use the argument reduction.
2639+ len = x . d . length ;
26382640 if ( len < 32 ) {
26392641 k = Math . ceil ( len / 3 ) ;
26402642 y = ( 1 / tinyPow ( 4 , k ) ) . toString ( ) ;
36633665 function sine ( Ctor , x ) {
36643666 var k ,
36653667 len = x . d . length ;
3666-
3667- if ( len < 3 ) return taylorSeries ( Ctor , 2 , x , x ) ;
3668+
3669+ if ( len < 3 ) {
3670+ return x . isZero ( ) ? x : taylorSeries ( Ctor , 2 , x , x ) ;
3671+ }
36683672
36693673 // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x)
36703674 // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5)
You can’t perform that action at this time.
0 commit comments