diff options
Diffstat (limited to 'macros/sosbreak.sci')
-rw-r--r-- | macros/sosbreak.sci | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/macros/sosbreak.sci b/macros/sosbreak.sci index dc78f95..c82935f 100644 --- a/macros/sosbreak.sci +++ b/macros/sosbreak.sci @@ -1,7 +1,28 @@ //Author: Parthasarathi Panda //parthasarathipanda314@gmail.com function [zerosort,g]=sosbreak(p) -//function for breaking a polynomial in second order polynomials (and an extra linear) +//function for breaking a polynomial in second order polynomials and an extra linear term (g) +//where +//g:-the interger multiple obtained after breaking the polynomial +//zerosort:-the array of the broken polynomials +//p:-the input polynomial + + +//EXAMPLE: +//v=[1+4*%s+6*%s^2+4*%s^3+%s^4]; +// [zerosort,g]=sosbreak(v); +//OUTPUT: +// g =1. + //zerosort = + // zerosort(1) +// 2 +// 1 + 2s + s +// zerosort(2) +// 2 +//1.0000000 + 2s + s + +//NOTE :To verify the output use coeff(zerosort(1)) and coeff(zerosort(2)) + [zero,g]=factors(p);//factorising into real coefficient polynomials degn=degree(p); zerosort=list(); @@ -16,7 +37,7 @@ function [zerosort,g]=sosbreak(p) zerosort($+1)=q; end end - + if (modulo(degn,2))==0 then e=length(zerosort); //leave the last linear element if an odd degree polynomial @@ -28,7 +49,8 @@ function [zerosort,g]=sosbreak(p) if degree(q)==2 then break; end - zerosort(i)=q*zerosort(i-1);//combining 2 linear polynomial into one quadratic polynomial + zerosort(i)=q.*zerosort(i-1);//combining 2 linear polynomial into one quadratic polynomial zerosort(i-1)=null();//removing leftover linear polynomial + end endfunction |