Incorrect polynomial operations?

Hi, me again. This time I'm having a problem with polynomial multiplication. I have 9 equations in the form of G = k/(tau*s+1) which I wrote like G(i) = k(i)/(tau(i)*%s+1), where i goes from 1 to 9. Then, I'm tryng to perform the following calculation: G11 = (G(2)+G(3)*G(6))/(1-G(3)*G(7)). What Scilab gives me is this:

-0.0019137 - 0.0630427s
0.0000060 + 0.0515580s + s^2
But this is not correct, the right answer should be
-3.023e012 s^4 - 2.482e011 s^3 - 4.811e009 s^2 - 1.887e006 s - 187
4.795e013 s^5 + 4.953e012 s^4 + 1.292e011 s^3 + 6.579e007 s^2 + 1.098e004 s + 0.591
which Matlab does correctly, but Scilab does not. Am I missing something here? Thanks in advance.
P.S.: I get the correct result if I only multiply G(3)*G(6), but as soon as I add G(2) it wanders off again.

Scilab 04-08-17, 8:01 p.m. leohpaz



Hi leohpaz, can you provide the values of k(i) and tau(i) to do the calculations.

07-08-17, 8:39 a.m. ashutumho

Hi, sorry about that but I recently realized that the operation is in fact correct. Scilab simplifies the function by actually dividing the polynomials in the numerator and denominator and by simplifying the coefficients, so both Scilab's and Matlab's answers are equivalent.

07-08-17, 5 p.m. leohpaz

I was expecting the same. Here is an example 

Please run the given equation in Matlab and Scilab
sys = (s+1)*(s+2)*(s+1)/((s+1)*(s+5)*(s+1))
You will see the difference in final result. Matlab keeps the redundant roots in rational polynomials but Scilab not.  

10-08-17, 11:20 a.m. ashutumho

Login to add comment

Log-in to answer to this question.