Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


Análisis Numérico: Métodos de Interpolación y Resolución de Ecuaciones, Ejercicios de Métodos Numéricos

Una colección de programas en lenguaje de programación matlab para resolver problemas de análisis numérico. Abarca métodos de interpolación como la interpolación lineal, la interpolación de lagrange y la interpolación de newton hacia adelante, así como métodos para la resolución de ecuaciones, incluyendo el método de la bisección, el método de la falsa posición, el método de newton-raphson, el método de la secante y el método de sustituciones sucesivas. Además, se incluyen programas para el cálculo de integrales numéricas utilizando el método del trapecio y la regla de simpson.

Tipo: Ejercicios

2024/2025

Subido el 15/01/2025

kevin-lucero-3
kevin-lucero-3 🇪🇨

2 documentos

1 / 11

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
UNIVERSIDAD DE CUENCA
FACULTAD DE CIENCIAS QUÍMICAS
CARRERA DE INGENIERÍA QUIMICA
ANÁLISIS NUMÉRICO
Programas desarrollados Primer Interciclo
Jaime Alejandro Bautista Morocho, Kevin Lucero Quizhpi
Universidad de Cuenca, Facultad de Ciencia Químicas, Carrera de Ingeniería
Química.
Cuenca – Ecuador
Autor para correspondencia: Ing. Paul Alvarez
Fecha de recepción: 09/05/2024
INTERPOLACIÓN LINEAL
%Programa Interpolación lineal
%Nombre: Jaime Bautista
%Desarrollo
disp('PROGRAMA DE INTERPOLACIÓN LINEAL')
a= input('Ingrese el valor de x0: ');
b=input('Ingrese el valor de x1: ');
fa=input('Ingrese el valor del f0: ');
fb=input('Ingrese el valor de f1: ');
x=input('Ingrese el valor de x: ');
fx =(((b-x)/(b-a)*fa)+((x-a)/(b-a))*fb);
disp("La interpolación lineal es:");
disp (fx);
INTERPOLACIÓN DE LAGRANGE
%Programa Interpolación de Lagrange
%Nombre: Jaime Bautista
%Desarrollo
pf3
pf4
pf5
pf8
pf9
pfa

Vista previa parcial del texto

¡Descarga Análisis Numérico: Métodos de Interpolación y Resolución de Ecuaciones y más Ejercicios en PDF de Métodos Numéricos solo en Docsity!

UNIVERSIDAD DE CUENCA

FACULTAD DE CIENCIAS QUÍMICAS

CARRERA DE INGENIERÍA QUIMICA

ANÁLISIS NUMÉRICO

Programas desarrollados Primer Interciclo

Jaime Alejandro Bautista Morocho, Kevin Lucero Quizhpi Universidad de Cuenca, Facultad de Ciencia Químicas, Carrera de Ingeniería Química. Cuenca – Ecuador Autor para correspondencia: Ing. Paul Alvarez Fecha de recepción: 09/05/ INTERPOLACIÓN LINEAL %Programa Interpolación lineal %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE INTERPOLACIÓN LINEAL') a= input('Ingrese el valor de x0: '); b=input('Ingrese el valor de x1: '); fa=input('Ingrese el valor del f0: '); fb=input('Ingrese el valor de f1: '); x=input('Ingrese el valor de x: '); fx =(((b-x)/(b-a)fa)+((x-a)/(b-a))fb); disp("La interpolación lineal es:"); disp (fx); INTERPOLACIÓN DE LAGRANGE %Programa Interpolación de Lagrange %Nombre: Jaime Bautista %Desarrollo

disp('PROGRAMA DE INTERPOLACIÓN DE LAGRANGE') function [C]=lagran(x,y) n1=length(x); n=n1-1; L=zeros(n1,n1); for k=1:n+ V=1; for j=1:n+ if k~=j; V=conv(V,poly(x(j)))/(x(k)-x(j)); end end L(k,:)=V; end C=y*L end INTERPOLACIÓN NEWTON HACIA ADELANTE %Programa Interpolación de newton hacia adelante %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE INTERPOLACIÓN DE NEWTON HACIA ADELANTE') function [yi, p, b]=pol_newton (x,y,xi) %Ingreso de variables n=length(x); b=zeros(n); b(:,1)=y(:); %Tabla de diferencias

disp('PROGRAMA DE METODO DE BISECCION') f=input('Ingrese la función: '); f=inline(f); a=input('Ingrese el límite inferior: '); b=input('Ingrese el límite superior: '); t=input('Ingrese la tolerancia de error: '); disp(f); x=a:0.1:b; plot(x,f(x)); grid on;hold on; if (f(a)f(b)>0) error ('Error, rectifique, se presenta incumplimiento del Teorema'); end cont=0; while (abs(b-a)>t) m=(a+b)/2; if (f(a)f(m)<0) b=m; end if (f(a)*f(b)<0) a=m; end if (abs(f(m))<eps) fprintf('\n La raíz es %f\n\n',m); return end cont=cont+1; fprintf('\n Iteracion %d, intervalo [%f, %f]', cont, a,b); x=a:0.1:b; plot(x,f(x),'g'); end MÉTODO DE LA FALSA POSICIÓN %Programa Método de la falsa posición %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE METODO DE LA FALSA POSICION')

function falsapos (fx,xl,xu,es,imax) %Ingreso de variables f=inline (fx); %Valorar en un punto fl=f(xl); fu=f(xu); iter=0; iu=0; il=0; xr=100; do=0; imax=0; while(do==0)%Bucle infinito xrold=xr; %Guardar valor anterior xr=xu-((fu(xl-xu))/(fl-fu)); fr=f(xr); iter=iter+1; %Contador de impresiones del programa if (xr~=0) %Cálculo del error ea=abs((xr-xrold)/xr)100; end test=fl-fr; if(test<0) xu=xr; fu=f(xu); iu=0; il=il+1; if (il>=2) fl=fl/2; end else if(test>0) xl=xr; fl=f(xl); il=0; iu=iu+1; if (iu>=2) fu=fu/2; end else ea=0; end if((ea<es)||(iter>=imax)) break; end end end disp(xr) MÉTODO NEWTON RAPHSON %Programa Método de Newton Raphson %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE METODO DE NEWTON RAPHSON') function Newton_raphson syms x; %Variable simbolica f=input('Ingrese con función f(x): '); df=diff (f); %Derivada de f xo= input ('Ingrese el valor inicial: ');

SUSTITUCIONES SUCESIVAS %Programa Método de Sustituciones Sucesivas %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE METODO DE SUSTITUCIONES SUCESIVAS') Xo=input('\nIngrese el valor inicial: '); iter=input('\nIngrese el número de iteraciones: '); tol=input('\nIngrese el valor de tolerancia: '); fun=input('\nIngrese la función entre comillas: '); g=input('\nIngrese la función despejada en(x)con comillas simple: '); f=inline(fun); gx=inline(g); Yn=f(Xo); error=tol+1; n=0; Z1=[n,Xo]; Z=[n,Xo]; while Yn~=0 & error>tol && n<iter Xn=gx(Xo); Yn=f(Xn); error=abs((Xn-Xo)/Xn); n=n+1; Z(n,1)=n; Z(n,2)=Xn; Xo=Xn; end if Yn== fprintf('\n\n SOLUCION: \n') fprintf('%g es raiz\n\n',Xo); else if error<tol fprintf('\n La raiz es: %f \n',Xo); else fprintf('\n\n solucion:\n') fprintf('No hay raiz en %g iteraciones\n\n',iter); end end fprintf('\n Tabla de Resultados\n\n n Xn \n\n') disp(Z1); disp(Z);

MÉTODO DEL TRAPECIO %Programa Método del trapecio %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE METODO DEL TRAPECIO') fprintf('Método del trapecio n puntos \n'); f=input('Ingrese la función: ','s'); a=input('Ingrese el límite inferior: '); b=input('Ingrese el límite superior: '); n=input('Puntos a dividir el trapecio: '); g=inline(f); h=(b-a)/n; s=0; m=(feval (g,a)+ feval (g,b))h/2; %Inicio del bucle for i=1:n- s=feval(g,a+(i)h)*h+s; %fprintf('Los trapecios centrales son: %10.2f\n',s); end Resp=m+s; fprintf('\t\tEl área aproximada bajo la curva es: %10.2f\n', Resp);

REGLA 3/8 DE SIMPSON %Programa Método de Regla 3/8 de Simpson %Nombre: Jaime Bautista %Desarrollo disp('PROGRAMA DE METODO DE REGLA 3/8 DE SIMPSON') f=inline(input('Ingrese la función a integrar: ','s')); a=input('Ingrese el intervalo inferior: '); b=input('Ingrese el intervalo superior: '); n=input('Ingrese el número de divisiones: '); h=(b-a)/n; c=0;suma=0;sumav=0; s=a; while (s<=b) c=c+1; s=s+h; end x=a:h:b; if(rem((c-1),3)~=0) disp('ERROR') disp('n debe ser divisible or 3') else p=4; for(i=1:c) fi=feval(f,x(i)); if(i==1 | i==c) suma=suma+fi; else if(i==p) sumav=sumav+(fi2); p=p+3; else sumav=sumav+(fi3); end end end end suma=suma+sumav; integral=((pi/4)*suma)/ t0=feval(f,x(1)); t1=feval(f,x(2));

t2=feval(f,x(3)); t3=feval(f,x(4)); t4=feval(f,x(5)); f4=(t4-(4t3)+(6t2)-(4t1)+t0)/(h^4); error=-((b-a)/80)(h^4)*f