Advertisement
franciscominajas

Untitled

Jul 6th, 2020
2,287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.42 KB | None | 0 0
  1. clc, clear all, close all
  2. %Segunda Derivada. Ejercicio 1.
  3. syms x
  4. xi=input('Ingresar xi: ');
  5. h=input('Ingresar h: ');
  6. f=input('Función f(x): ');
  7.  
  8. %Derivación. Términos
  9. fxi=subs(f,xi);
  10. fxih=subs(f,xi+h);
  11. fxihn=subs(f,xi-h);
  12.  
  13. %Derivación hacia adelante
  14. segundader= vpa((1/h^2)*(fxih - 2*fxi + fxihn),5)
  15.  
  16.  
  17. %Para calcular error
  18. derivada=subs(diff(f,1),xi);
  19.  
  20. error=vpa(abs(((derivada-segundader)/derivada)*100),4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement