Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function L = limiteRaizes(n, c)
- L = zeros(4);
- // n -> grau do polinomio
- // c -> coeficientes do polinomio
- if( c(1) == 0 )
- print("coeficiente c(1) nulo");
- break;
- end
- t = n+1;
- c(t+1) = 0;
- while(1) // REVISAR
- if(c(t) ~= 0) break; end
- t = t - 1;
- end
- // calculo dos quatro limites reais
- for( i = 1:4 )
- if( i == 2 | i == 4)
- for(j = 1:t/2)
- Aux = c(j);
- c(j) = c(t-j+1);
- c(t-j+1) = Aux;
- end
- else
- if( i == 3 )
- for( j = 1:t/2)
- Aux = c(j);
- c(j) = c(t-j+1);
- c(t-j+1) = Aux;
- end
- for(j = t-1:-2:1) c(j) = -1*c(j); end
- end
- end
- // se c(1) negativo
- if(c(1) < 0)
- for(j = 1:t) c(j) = -1 * c(j); end
- end
- k = 2;
- while(1)
- if(c(k) < 0 | k > t) break; end
- k = k + 1;
- end // calculo de B, o maior coeficiente negativo em modulo
- if( k <= t )
- B = 0;
- for( j = 2:t )
- if( c(j) < 0 & abs(c(j)) > B) B = abs(c(j)); end
- end
- // limite das raizes positivas de P(x) = 0 e das equa çáes auxiliares
- L(i) = 1 + (B/c(1)).^(1/(k-1));
- else
- L(i) = 10.^100;
- end
- end
- Aux = L(1);
- L(1) = 1/L(2);
- L(2) = Aux;
- L(3) = -1*(L(3));
- L(4) = -1/(L(4));
- endfunction
- // parametros de entrada
- n = 4;
- c = [1 2 -13 -14 24];
- // resultados
- disp(limiteRaizes(n,c));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement