@@ -318,18 +318,6 @@ def mul_dekker(ctx, x, y, C=None):
318318    return  mul_dw (ctx , x , y , xh , xl , yh , yl )
319319
320320
321- def  _mul_series_scalar (ctx , x , y ):
322-     assert  type (y ) is  not tuple 
323-     terms  =  tuple (x_  *  y  for  x_  in  x [1 :])
324-     return  ctx ._series (terms , dict (unit_index = x [0 ][0 ], scaling_exp = x [0 ][1 ]))
325- 
326- 
327- def  _mul_scalar_series (ctx , x , y ):
328-     assert  type (x ) is  not tuple 
329-     terms  =  tuple (x  *  y_  for  y_  in  y [1 :])
330-     return  ctx ._series (terms , dict (unit_index = y [0 ][0 ], scaling_exp = y [0 ][1 ]))
331- 
332- 
333321def  _div_series_scalar (ctx , x , y ):
334322    assert  type (y ) is  not tuple 
335323    terms  =  tuple (x_  /  y  for  x_  in  x [1 :])
@@ -343,16 +331,13 @@ def _mul_series_series(ctx, x, y):
343331
344332    terms  =  []
345333    for  n  in  range (len (terms1 ) +  len (terms2 ) -  1 ):
346-         xy  =  None 
347334        for  i , x  in  enumerate (terms1 ):
348335            for  j , y  in  enumerate (terms2 ):
349336                if  i  +  j  ==  n :
350-                     if  xy   is   None :
351-                         xy   =   x   *   y 
337+                     if  ctx . parameters . get ( "series_uses_dekker" ) :
338+                         _terms_add ( ctx ,  terms ,  n ,  * mul_dekker ( ctx ,  x ,  y )) 
352339                    else :
353-                         xy  +=  x  *  y 
354-         assert  xy  is  not None 
355-         terms .append (xy )
340+                         _terms_add (ctx , terms , n , x  *  y )
356341
357342    return  ctx ._series (tuple (terms ), dict (unit_index = index1  +  index2 , scaling_exp = sexp1 ))
358343
@@ -364,10 +349,10 @@ def mul_series(ctx, x, y):
364349    if  type (x ) is  tuple :
365350        if  type (y ) is  tuple :
366351            return  _mul_series_series (ctx , x , y )
367-         return  _mul_series_scalar (ctx , x , y )
352+         return  _mul_series_series (ctx , x , (( 0 ,  0 ),  y ) )
368353    elif  type (y ) is  tuple :
369-         return  _mul_scalar_series (ctx , x , y )
370-     return  x   *   y 
354+         return  _mul_series_series (ctx , (( 0 ,  0 ),  x ) , y )
355+     return  _mul_series_series ( ctx , (( 0 ,  0 ),  x ), (( 0 ,  0 ),  y )) 
371356
372357
373358def  div_series (ctx , x , y ):
@@ -1415,8 +1400,14 @@ def sine_taylor_dekker(ctx, x, order=7):
14151400    C , f  =  [x ], 1 
14161401    for  i  in  range (3 , order  +  1 , 2 ):
14171402        f  *=  - i  *  (i  -  1 )
1418-         f1  =  ctx .constant (1  /  f , x )
1419-         C .append (mul_series (ctx , x , f1 ))
1403+         # See sine_taylor: 
1404+         if  i  >=  5 :
1405+             f1  =  ctx .constant (1  /  f , x )
1406+             C .append (mul_series (ctx , x , f1 ))
1407+         else :
1408+             fh , fl  =  split_veltkamp (ctx , ctx .constant (f , x ))
1409+             a  =  fl  /  fh 
1410+             C .append (ctx .series (x  /  fh , - a  *  x  /  fh ))
14201411    xx  =  mul_series (ctx , x , x )
14211412    # Horner's scheme is most accurate 
14221413    return  fast_polynomial_dekker (
0 commit comments