Page 24 - 《软件学报》2020年第12期
P. 24

3690                                Journal of Software  软件学报 Vol.31, No.12, December 2020

         明完毕.                                                                                  □
             由上面的讨论,我们可得主算法的“出口”子算法.其中,f 是算术表达式(可以包含π与 e),或若干常数与若干
         变元的和,或变元与常数相乘或相除,或两个变元相乘或相除.
             算法 1. Sub1_AccurateEnough( {( , ) |1y ε i  ≤≤  n }, ( , ,...,f x x 2  x n ),ε ).

                                               i
                                        i
                                                      1
             1:   enough⇐true;
             2:   if f 是算术表达式  then
             3:      y⇐ f  ε ;
             4:   else if  f =  r 1 i ∑  c + ∑  l  x  ,其中 ≥ 0,l ≥ 0,l +  r >  0,{ ,d d  ,..., }d ⊆  {1,2,..., },n 每个 为常数   then
                                                                                c
                                          ,r
                           i=     i=  1 d  i               1  2  l               i
             5:      if  (l =  0) (∨  ∑ l i= 1 d i  ) ε   then
                               ε ≤
             6:         y ⇐  r 1 i ∑  c + ∑  l  y   ;
                          i=     i=  1  i d
             7:      else
             8:         ( , ,k ε  enough ) ⇐  ({ε  ,ε  ,...,ε  }中最大者的下标 , ( / ),false)lδ  ε  ;
                       0            1 d  2 d  l d
             9:      end if
             10: else if f 表示为 x i 与 d 的乘积(其中,d∈{c,1/c},c 为非 0 常数) then
             11:     if d×ε i <ε then
             12:        y ⇐  d ×    y      i ε  ;
             13:     else
             14:       (k,ε 0 ,enough)⇐(i,δ(ε/d),false);
             15:     end if
             16: else if f=x i ×x j  then
             17:     if ε ×  i  (| y +  j  | ε    j ) ε  +  j  ×  (| y +  i  | ε   i ) ε  <    then
             18:        y ⇐  y ×    i  y    j  ;
             19:     else
             20:        ( , ,k ε  enough ) ⇐  ( , ( /(2(|d δε  y    | ε+  ))),false) ,
                       0           1        2 d  2 d
                    其中:若 (| yε  | ε   ) ε +  >  (| y +  | ε   ) ,则 d 1 =i,d 2 =j;否则,d 1 =j,d 2 =i;
                           i  j   j   j  i  i
             21:     end if
             22: else if f=x i /x j  then
             23:    // y    i  y   或 的误差限可以为 0.这时 , y 或 为常数 .
                                             y
                                           i
                        j
                                              j
             24:     if  | y    j  | 2ε>  j    then
             25:        if 4(| yε j  i  | ε   i ) ε +  <  | y    j  | (| y −  j  | ε    j  )   then
                            | y ε   then
             26:           if  4ε <   j  |
                          i

             27:              y ⇐      y i  / y    j ε /2  ;
             28:           else
             29:              (, ,k ε 0  enough ) ⇐ ( , (|i δ  y    j  | / 4),false)ε  ;
             30:           end if
             31:        else
             32:           ( , ,k ε 0  enough ) ⇐  ( ,min{ (( |j  δε  y    j  | (| y    j  | ε−  j  ))/(4(| y    i  | ε+  i ))), (δ ε j  /10 )},false) ;
             33:        end if
             34:     else
             35:        ( , ,k ε 0  enough ) ⇐  ( ,min{ (|j  δ  y    j  | / 2), (δ  ε  j  /10 )},false) ;
             36:     end if
   19   20   21   22   23   24   25   26   27   28   29