Simplification of Rational Polynomials

Hi, everyone!
Please, I have ZBBE (end of this message), an array of rational polynomials to be simplified. I’ve tried to use commands “simp_mode (%T)” before the equation that defines ZBBE and “simp(ZBBE)”, also separating numerators and denominators, and ZBBE has kept the same.
So I’ve tried to use “gcd” command, with the following script:

mdc1=gcd([ZBBE(k,1).num ZBBE(k,1).den]);
   if mdc1~=1
      simp_num=ZBBE(k,1).num./mdc1;
      simp_den=ZBBE(k,1).den./mdc1;
      ZBE(k,1)=simp_num/simp_den;
   end

Now I have ZBE (also at the end of this message). Some irreducible rational polynomials have kept the same as I expected. Others, like ZBBE(1,1) was properly simplified. But I have a problem with the last one, ZBBE(23,1), which became of even grater degree.
Please, could someone solve my problem or at least explain to me what is going wrong? I thank you a lot.

-> ZBBE
 ZBBE  = 

   0.0000124 +1.262D-09s +8.496D-12s² +4.316D-16s³ +1.453D-18s⁴  
   ------------------------------------------------------------  
   4.234D-08 +2.052D-12s +2.896D-14s² +7.018D-19s³ +4.952D-21s⁴  
                                                                 
                       3.135D+08 +200000s                        
                    -------------------------                    
                    353004.51 +1941.1718s +s²                    
                                                                 
   0.0000124 +1.284D-09s +8.645D-12s² +4.469D-16s³ +1.504D-18s⁴  
   ------------------------------------------------------------  
   4.234D-08 +2.088D-12s +2.947D-14s² +7.266D-19s³ +5.127D-21s⁴  
                                                                 
   1.818D-13 +2.236D-17s +1.505D-19s² +9.255D-24s³ +3.115D-26s⁴  
   ------------------------------------------------------------  
   3.240D-16 +1.636D-18s +4.695D-22s² +1.355D-24s³ +1.388D-28s⁴  
    +2.804D-31s⁵                                                 
                                                                 
                6.614D+11 +2.556D+08s +166666.67s²               
                ----------------------------------               
                   6613756.6s +2556.2372s² +s³                   
                                                                 
         0.0000008 +6.435D-10s +3.922D-13s² +1.046D-16s³         
        -------------------------------------------------        
        8.984D-12s +7.078D-15s² +2.987D-18s³ +6.274D-22s⁴        
                                                                 
                      0.014861s +0.0000095s²                     
                 --------------------------------                
                 2.972205 +0.001893s +7.431D-08s²                
                                                                 
                      1.135D+08 +166666.67s                      
                    -------------------------                    
                    96457.316 +951.74433s +s²                    
                                                                 
                      7.375D+08 +583333.33s                      
                    -------------------------                    
                    1839060.2 +4404.5491s +s²                    
                                                                 
   1.601D-13 +2.236D-17s +1.325D-19s² +9.255D-24s³ +2.743D-26s⁴  
   ------------------------------------------------------------  
   3.240D-16 +1.441D-18s +4.695D-22s² +1.193D-24s³ +1.388D-28s⁴  
    +2.469D-31s⁵                                                 
                                                                 
                        489383.56s +845s²                        
                    -------------------------                    
                    9411222.3 +16592.466s +s²                    
                                                                 
                2.987D+11 +1.439D+08s +111111.11s²               
                ----------------------------------               
                    3882915.2s +1871.042s² +s³                   
                                                                 
               1.632D-17s +2.601D-19s² +8.777D-22s³              
   ------------------------------------------------------------  
   4.410D-16 +7.029D-18s +2.387D-20s² +1.425D-24s³ +3.456D-27s⁴  
                                                                 
                     0.1760929s +0.0002869s²                     
                ---------------------------------                
                8.804645 +0.0143449s +0.0000009s²                
                                                                 
                     1.0174757s +0.0023123s²                     
                ----------------------------------               
                14.535367 +0.0330322s +0.0000071s²               
                                                                 
               1.125D-17s +1.176D-19s² +2.382D-22s³              
   ------------------------------------------------------------  
   2.250D-16 +2.351D-18s +4.866D-21s² +5.569D-25s³ +7.657D-28s⁴  
                                                                 
               2.644D-13 +6.668D-19s² +3.806D-25s⁴               
   ------------------------------------------------------------  
   6.480D-16 +2.115D-18s +1.634D-21s² +3.693D-24s³ +9.328D-28s⁴  
    +1.612D-30s⁵                                                 
                                                                 
                        449410.95s +816s²                        
                     -----------------------                     
                     7022046.1 +13096.5s +s²                     
                                                                 
                      0.0001426 +0.0000005s                      
                     -----------------------                     
                     2.139D-09s +3.060D-12s²                     
                                                                 
               1.192D-17s +1.253D-19s² +2.553D-22s³              
   ------------------------------------------------------------  
   2.250D-16 +2.364D-18s +4.924D-21s² +5.935D-25s³ +8.205D-28s⁴  
                                                                 
                     0.1937022s +0.0003156s²                     
                 --------------------------------                
                 8.804645 +0.0143449s +0.000001s²                
                                                                 
                1.417D+11 +23864070s +111111.11s²                
              --------------------------------------             
              2.435D+08 +1275510.2s +405.68919s² +s³             
                                                                 
               2.744D-18s +2.898D-20s² +6.638D-23s³              
   ------------------------------------------------------------  
   3.920D-16 +4.140D-18s +9.505D-21s² +1.475D-25s³ +2.478D-28s⁴ 



         





--> ZBE
 ZBE  = 

              4.248D-12 +4.316D-16s +1.453D-18s²               
                ----------------------------------               
                1.448D-14 +7.018D-19s +4.952D-21s²               
                                                                 
                       3.135D+08 +200000s                        
                    -------------------------                    
                    353004.51 +1941.1718s +s²                    
                                                                 
                4.322D-12 +4.469D-16s +1.504D-18s²               
                ----------------------------------               
                1.473D-14 +7.266D-19s +5.127D-21s²               
                                                                 
   1.818D-13 +2.236D-17s +1.505D-19s² +9.255D-24s³ +3.115D-26s⁴  
   ------------------------------------------------------------  
   3.240D-16 +1.636D-18s +4.695D-22s² +1.355D-24s³ +1.388D-28s⁴  
    +2.804D-31s⁵                                                 
                                                                 
                6.614D+11 +2.556D+08s +166666.67s²               
                ----------------------------------               
                   6613756.6s +2556.2372s² +s³                   
                                                                 
                3.218D-10 +1.267D-13s +1.046D-16s²               
               ------------------------------------              
               3.539D-15s +1.394D-18s² +6.274D-22s³              
                                                                 
                      0.014861s +0.0000095s²                     
                 --------------------------------                
                 2.972205 +0.001893s +7.431D-08s²                
                                                                 
                      1.135D+08 +166666.67s                      
                    -------------------------                    
                    96457.316 +951.74433s +s²                    
                                                                 
                      7.375D+08 +583333.33s                      
                    -------------------------                    
                    1839060.2 +4404.5491s +s²                    
                                                                 
   1.601D-13 +2.236D-17s +1.325D-19s² +9.255D-24s³ +2.743D-26s⁴  
   ------------------------------------------------------------  
   3.240D-16 +1.441D-18s +4.695D-22s² +1.193D-24s³ +1.388D-28s⁴  
    +2.469D-31s⁵                                                 
                                                                 
                        489383.56s +845s²                        
                    -------------------------                    
                    9411222.3 +16592.466s +s²                    
                                                                 
                2.987D+11 +1.439D+08s +111111.11s²               
                ----------------------------------               
                    3882915.2s +1871.042s² +s³                   
                                                                 
               1.632D-17s +2.601D-19s² +8.777D-22s³              
   ------------------------------------------------------------  
   4.410D-16 +7.029D-18s +2.387D-20s² +1.425D-24s³ +3.456D-27s⁴  
                                                                 
                     0.1760929s +0.0002869s²                     
                ---------------------------------                
                8.804645 +0.0143449s +0.0000009s²                
                                                                 
                     1.0174757s +0.0023123s²                     
                ----------------------------------               
                14.535367 +0.0330322s +0.0000071s²               
                                                                 
                     3.094D-20s +2.382D-22s²                     
         -----------------------------------------------         
         6.188D-19 +4.764D-21s +2.784D-25s² +7.657D-28s³         
                                                                 
               2.308D-19 -4.793D-37s +3.806D-25s²                
         -----------------------------------------------         
         5.657D-22 +1.846D-24s +9.328D-28s² +1.612D-30s³         
                                                                 
                        449410.95s +816s²                        
                     -----------------------                     
                     7022046.1 +13096.5s +s²                     
                                                                 
                      0.0001426 +0.0000005s                      
                     -----------------------                     
                     2.139D-09s +3.060D-12s²                     
                                                                 
               1.192D-17s +1.253D-19s² +2.553D-22s³              
   ------------------------------------------------------------  
   2.250D-16 +2.364D-18s +4.924D-21s² +5.935D-25s³ +8.205D-28s⁴  
                                                                 
                     0.1937022s +0.0003156s²                     
                 --------------------------------                
                 8.804645 +0.0143449s +0.000001s²                
                                                                 
                1.417D+11 +23864070s +111111.11s²                
              --------------------------------------             
              2.435D+08 +1275510.2s +405.68919s² +s³             
                                                                 
        3.813D-16s +6.771D-18s² +3.820D-20s³ +6.638D-23s⁴        
   ------------------------------------------------------------  
   5.448D-14 +9.673D-16s +5.460D-18s² +9.526D-21s³ +1.820D-25s⁴  
    +2.478D-28s⁵

Hello,

In Scilab polynomial and rational algebra is not exact (coefficients are encoded real number with the same finite precision as elsewhere). Hence, simplification does not necessary occur as it may occur with a symbolic math package (which Scilab does not have).

Could you save ZBEE in a Scilab binary data file with save("data.sod","ZBEE")and attach the file to your post (please edit your original post) ?

S.

Save ZBEE before any simplification please.

Thank you very much for your answer, @mottelet! I’ve saved the “data.sod”, but I’ve not found where I could attach the file to my post.

Just drag and drop the file when you are editing your post.

ZBBE_data.sod (30.2 KB)

You saved ZBBE after simplification, I have the same as above.

No, I really think this is ZBBE before simplification. But I will send you now ZBBE (before simplification) and ZBE = ZBBE (after simplification), exactly as they are above.
ZBBE_data.sod (30.2 KB)
ZBE_data.sod (30.2 KB)
Thank you very much.

I don’t see any simplification occuring in ZBBE(23,1):



--> simp_mode
 ans  =

  T

--> ZBBE(23,1)
 ans  =

               2.744D-18s +2.898D-20s^2 +6.638D-23s^3               
   ---------------------------------------------------------------  
   3.920D-16 +4.140D-18s +9.505D-21s^2 +1.475D-25s^3 +2.478D-28s^4  

--> simp(ZBBE(23,1))
 ans  =

               2.744D-18s +2.898D-20s^2 +6.638D-23s^3               
   ---------------------------------------------------------------  
   3.920D-16 +4.140D-18s +9.505D-21s^2 +1.475D-25s^3 +2.478D-28s^4  

That is exactly my problem. The command “simp” has made no simplification for me. Because of that, I’ve used gcd. I’ve got some simplifications with that, but the last one was worse.

Be warned that the relative magnitude of your coefficients in the denominator is 10^12 which seems to be the source of the problem. Moreover, the common divisor computation seems to also depend on the absolute magnitude of coefficients. By renormalizing (without loss of precision) the numerator and denominator you obtain the following results:

r = ZBBE(23,1);
rs = r.num*1e23/(r.den*1e23)
roots(r.num),roots(r.den)

--> r=ZBBE(23,1);

--> rsc=r.num*1e23/(r.den*1e23)
 rsc  = 

               274400s +2897.664s^2 +6.6382848s^3              
   ----------------------------------------------------------  
   39200000 +413952s +950.5216s^2 +0.0147517s^3 +0.0000248s^4  

--> roots(r.num),roots(r.den)
 ans  =

  -297.61905 + 0.i
  -138.88889 + 0.i
   0.        + 0.i
 ans  =

  -79.325044 + 6183.6046i
  -79.325044 - 6183.6046i
  -297.61905 + 0.i       
  -138.96896 + 0.i   

although the common root -297.61905 seems evident, the second one is not (-138.8888 vs. -138.96896). This is confirmed by

d = bezout(rsc.num,rsc.den)

--> d=bezout(rsc.num,rsc.den)
 d  = 
  297.61905 +s

You can then divide the numerator and denominator:

[r1,q1]=pdiv(rsc.num,d)
[r2,q2]=pdiv(rsc.den,d)
rsimp=q1/q2

--> [r1,q1]=pdiv(rsc.num,d)
 r1  = 

  -0.0004253
 q1  = 

  0.0000014 +921.984s +6.6382848s^2

--> [r2,q2]=pdiv(rsc.den,d)
 r2  = 

   0.0002042
 q2  = 

  131712 +948.3264s +0.0073759s^2 +0.0000248s^3

--> rsimp=q1/q2
 rsimp  = 

         0.0000014 +921.984s +6.6382848s^2        
   ---------------------------------------------  
   131712 +948.3264s +0.0073759s^2 +0.0000248s^3  

Thank you so much for your help, @mottelet ! I will implement your scripts, and now I see my problem be solved.