Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ro, k, soma] = calculo_cos(x, erro)
- % paulogp
- % Algoritmo que, a partir de uma valor x lido em graus, permite o calculo
- % de y = cos(x)
- %
- % exemplo -> [ro, k, soma] = calculo(60, 10^-3)
- disp(' ');
- disp('###################');
- disp(' ');
- % formato de saida
- format long
- erroTrunc = (erro / 2);
- erroArr = (erro / 2);
- k = 0;
- ro = (x^(2*k+2)) / factorial(2*k+2);
- while (ro >= erroTrunc)
- ro = abs( (x^(2*k+2)) / factorial(2*k+2) );
- k = k + 1;
- end
- eap = (erroArr / k);
- soma = 0;
- for i=0:k
- soma = soma + ((-1)^i) * (x^(2*i)) / (factorial(2*i));
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement