Advertisement
FacundoCruz

Untitled

Sep 9th, 2023 (edited)
1,699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.51 KB | None | 0 0
  1. function [valorVerdadero,valorAproximado,errorRelativo]=f(x,n)
  2.     if modulo(n,2)==0 then
  3.         disp('n es par');
  4.         valorVerdadero=cos(x);
  5.         valorAproximado=0;
  6.         for i=0:n
  7.             valorAproximado=valorAproximado+(-1)^i*x^(2*i)/factorial(2*i);
  8.         end
  9.         errorRelativo=(abs(valorVerdadero-valorAproximado)/valorVerdadero)*100;
  10.     else
  11.         disp('n tiene que ser par');
  12.         valorVerdadero=0;
  13.         valorAproximado=0;
  14.         errorRelativo=0;
  15.     end
  16. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement