Está en la página 1de 19

UNIVERSIDAD MAYOR DE SAN ANDRES

FACULTAD DE INGENIERÍA
INGENIERÍA QUÍMICA, AMBIENTAL, ALIMENTOS Y PETROQUIMICA

PROGRAMACION Y ANALISIS NUMERICO (PRQ – 404)

DOCENTE: M. Sc. Ing. Roberto Parra Zeballos


AUXILIAR: Univ. Álvaro Abel Rivera Cárdenas
ESTUDIANTE: Univ. Flores Santos Ayrton Tadeo
GRUPO: A
GESTIÓN: 2022

TAREA No. 8
1.- Dados los datos:

x 1 2 3 5 7 8
f(x) 3 6 19 99 291 444

Calcule f(4) con el uso de polinomios de interpolación de Newton de órdenes 1 a 4. Elija los puntos
base para obtener una buena exactitud. ¿Qué indican los resultados en relación con el orden del
polinomio que se emplea para generar los datos de la tabla?

PSEUDOCÓDIGO DIAGRAMA DE FLUJO


1. INICIO
2. function [C,D] = difdivabs(X,Y)
3. Hacer n=length(X);
4. Hacer D=zeros(n,n);
5. Hacer D(:,1)=Y';
6. Para j=2:n
7. Para k=j:n
8. Hacer D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-
X(k-j+1));
9. Fin Para
10. Fin Para
11. Hacer C=D(n,n);
12. Para k=(n-1):-1:1
13. Hacer C=conv(C,poly(X(k)));
14. Hacer m=length(C);
15. Hacer C(m)=C(m)+D(k,k);
16. Fin Para
17. FIN

PROGRAMA EN MATLAB
function [C,D] = difdivabs(X,Y)
%-------
%Este programa realiza la
interpolación de un conjunto de
puntos (x,y)
%por el metodo de diferencias
divididas hacia abajo INICIO
%--------------
%ENTRADAS
% x : Conjunto de abcisas
% y : Conjunto function [C,D] = difdivabs(X,Y)
%SALIDAS
% C : Coeficientes del
polinomio interpolante de Newton
% D : Coeficientes de la n=length(X)
tabla por el método de diferencias
%--------------------------
n=length(X);
D=zeros(n,n); D=zeros(n,n)
D(:,1)=Y';%todas las filas, pero D(:,1)=Y'
solo la 1ra. columna
%Formula de la tabla de diferencia
divididasd hacia abajo. j=2;j=j+1;j=<n
for j=2:n
for k=j:n
D(k,j)=(D(k,j-1)-D(k-1,j-
1))/(X(k)-X(k-j+1));
end
k=j;k=k+1;k=<n
end
%Determinando los coeficientes de
los polinomios interpolantes de
Newton D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-X(k-j+1))
C=D(n,n);
for k=(n-1):-1:1
C=conv(C,poly(X(k)));
k
m=length(C);
C(m)=C(m)+D(k,k);
end
j

end

RESULTADOS k=(n-1):-1:1
>> X=[1 2 3 5 7 8]

X= C=conv(C,poly(X(k)))
m=length(C)
1 2 3 5 7 8 C(m)=C(m)+D(k,k)

>> Y=[3 6 19 99 291 444]


k

Y=
C
3 6 19 99 291 444

>> [C,D] = difdivabs(X,Y)


FIN
C=
0 0 1 -1 -1 4

D=

3 0 0 0 0 0
6 3 0 0 0 0
19 13 5 0 0 0
99 40 9 1 0 0
291 96 14 1 0 0
444 153 19 1 0 0

>> P=poly2sym(C)

P=

x^3 - x^2 - x + 4

>> f=inline(P)

f=

Inline function:
f(x) = -x-x.^2+x.^3+4.0

>> f(4)

ans =

48

2.- Determine los coeficientes de la ecuación cúbica que pasa por los primeros cuatro puntos del
problema anterior.

PSEUDOCÓDIGO DIAGRAMA DE FLUJO


1. INICIO
2. function [C,D] = difdivabs(X,Y)
3. Hacer n=length(X);
4. Hacer D=zeros(n,n);
5. Hacer D(:,1)=Y';
6. Para j=2:n
7. Para k=j:n
8. Hacer D(k,j)=(D(k,j-1)-D(k-1,j-
1))/(X(k)-X(k-j+1));
9. Fin Para
10. Fin Para
11. Hacer C=D(n,n);
12. Para k=(n-1):-1:1 INICIO
13. Hacer C=conv(C,poly(X(k)));
14. Hacer m=length(C);
15. Hacer C(m)=C(m)+D(k,k); function [C,D] = difdivabs(X,Y)
16. Fin Para
17. FIN

PROGRAMA EN MATLAB n=length(X)


function [C,D] =
difdivabs(X,Y)
%------- D=zeros(n,n)
%Este programa realiza la D(:,1)=Y'
interpolación de un conjunto
de puntos (x,y)
%por el metodo de
diferencias divididas hacia j=2;j=j+1;j=<n
abajo
%--------------
%ENTRADAS
% x : Conjunto de k=j;k=k+1;k=<n
abcisas
% y : Conjunto
%SALIDAS
% C : Coeficientes D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-X(k-j+1))
del polinomio interpolante
de Newton
% D : Coeficientes de
la tabla por el método de k
diferencias
%--------------------------
n=length(X);
j
D=zeros(n,n);
D(:,1)=Y';%todas las filas,
pero solo la 1ra. columna
%Formula de la tabla de
diferencia divididasd hacia k=(n-1):-1:1
abajo.
for j=2:n
for k=j:n C=conv(C,poly(X(k)))
D(k,j)=(D(k,j-1)-
D(k-1,j-1))/(X(k)-X(k-j+1));
m=length(C)
end C(m)=C(m)+D(k,k)
end
%Determinando los
coeficientes de los k
polinomios interpolantes de
Newton
C=D(n,n); C
for k=(n-1):-1:1
C=conv(C,poly(X(k)));
m=length(C);
C(m)=C(m)+D(k,k);
end FIN
end

RESULTADOS
>> X=[1 2 3 5 7 8]

X=

1 2 3 5 7 8

>> Y=[3 6 19 99 291 444]

Y=

3 6 19 99 291 444

>> [C,D] = difdivabs(X,Y)

C=

0 0 1 -1 -1 4

D=

3 0 0 0 0 0
6 3 0 0 0 0
19 13 5 0 0 0
99 40 9 1 0 0
291 96 14 1 0 0
444 153 19 1 0 0

>> P=poly2sym(C)

P=

x^3 - x^2 - x + 4

3.- La velocidad de sedimentación de una suspensión, se relaciona con la concentración


volumétrica del sedimento. Los datos experimentales para la sedimentación de una suspensión de
precipitado de carbonato de calcio se muestran en la tabla adjunta. Se requiere:

a) Encontrar la ecuación del polinomio interpolante que pase por los datos experimentales.
b) Calcular la velocidad de sedimentación para una concentración volumétrica de 2.5%.

Conc. Vol, % 0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00
Vel. Sediment, g/cm2hr 0.00 3.20 4.80 4.25 3.23 2.87 2.75 2.70 2.65

PSEUDOCÓDIGO DIAGRAMA DE FLUJO


1. INICIO
2. function [C,D] = difdivabs(X,Y)
3. Hacer n=length(X);
4. Hacer D=zeros(n,n);
5. Hacer D(:,1)=Y';
6. Para j=2:n
7. Para k=j:n
8. Hacer D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-X(k-
j+1));
9. Fin Para
10. Fin Para
11. Hacer C=D(n,n);
12. Para k=(n-1):-1:1
13. Hacer C=conv(C,poly(X(k)));
14. Hacer m=length(C);
15. Hacer C(m)=C(m)+D(k,k);
16. Fin Para
17. FIN

PROGRAMA EN MATLAB
function [C,D] = difdivabs(X,Y)
%-------
%Este programa realiza la interpolación
de un conjunto de puntos (x,y)
%por el metodo de diferencias divididas
hacia abajo
%--------------
%ENTRADAS
% x : Conjunto de abcisas
% y : Conjunto
%SALIDAS
% C : Coeficientes del polinomio
interpolante de Newton
% D : Coeficientes de la tabla
por el método de diferencias
%--------------------------
n=length(X);
D=zeros(n,n);
D(:,1)=Y';%todas las filas, pero solo
la 1ra. columna
%Formula de la tabla de diferencia
divididasd hacia abajo.
for j=2:n
for k=j:n
D(k,j)=(D(k,j-1)-D(k-1,j-
1))/(X(k)-X(k-j+1));
end
end
%Determinando los coeficientes de los INICIO
polinomios interpolantes de Newton
C=D(n,n);
for k=(n-1):-1:1
C=conv(C,poly(X(k))); function [C,D] = difdivabs(X,Y)
m=length(C);
C(m)=C(m)+D(k,k);
end
end n=length(X)
RESULTADOS
>> X=[0 1 2 3 4 5 6 7 8] D=zeros(n,n)
D(:,1)=Y'
X=

Columns 1 through 8 j=2;j=j+1;j=<n

0 1 2 3 4 5 6 7

Column 9
k=j;k=k+1;k=<n

8
D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-X(k-j+1))
>> Y=[0 3.20 4.80 4.25 3.23 2.87 2.75 2.70 2.65]

Y= k

Columns 1 through 4
j
0 3.2000 4.8000 4.2500

Columns 5 through 8
k=(n-1):-1:1
3.2300 2.8700 2.7500 2.7000

Column 9 C=conv(C,poly(X(k)))
m=length(C)
2.6500 C(m)=C(m)+D(k,k)

>> [C,D] = difdivabs(X,Y)


k
C=
C
Columns 1 through 4

-0.0001 0.0042 -0.0479 0.2557


FIN
Columns 5 through 8
-0.5827 0.1917 0.1057 3.2735

Column 9

D=

Columns 1 through 4

0 0 0 0
3.2000 3.2000 0 0
4.8000 1.6000 -0.8000 0
4.2500 -0.5500 -1.0750 -0.0917
3.2300 -1.0200 -0.2350 0.2800
2.8700 -0.3600 0.3300 0.1883
2.7500 -0.1200 0.1200 -0.0700
2.7000 -0.0500 0.0350 -0.0283
2.6500 -0.0500 -0.0000 -0.0117

Columns 5 through 8

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0.0929 0 0 0
-0.0229 -0.0232 0 0
-0.0646 -0.0083 0.0025 0
0.0104 0.0150 0.0039 0.0002
0.0042 -0.0013 -0.0027 -0.0009

Column 9

0
0
0
0
0
0
0
0
-0.0001

>> V=poly2sym(C)
V=

-
(2639824238722827*x^8)/18446744073709551616
+ (4853021769887763*x^7)/1152921504606846976
- (3448506314669319*x^6)/72057594037927936 +
(18407*x^5)/72000 -
(2624277214116349*x^4)/4503599627370496 +
(6905769628614417*x^3)/36028797018963968 +
(3808508342025039*x^2)/36028797018963968 +
(91657*x)/28000

>> V=inline(V)

V=

Inline function:
V(x) =
x.*3.273464285714286+x.^2.*1.057073412698295e-
1+x.^3.*1.916736111111211e-1-
x.^4.*5.827065972222265e-
1+x.^5.*2.556527777777778e-1-
x.^6.*4.785763888888904e-
2+x.^7.*4.209325396825408e-3-
x.^8.*1.431051587301591e-4

>> V(2.5)

ans =

4.7102

4.- La potencia generada por un molino de viento varía con la velocidad del viento. En un
experimento, se obtuvieron las cinco mediciones siguientes:

velocidad, km/h 22.53 35.41 48.28 61.15 74.03


Potencia, W 320 490 540 500 480

Determine el polinomio de Lagrange de 4to. orden que pase por los cinco puntos. Usando este
polinomio calcular la potencia a una velocidad de viento de 42 km/hr.

PSEUDOCÓDIGO DIAGRAMA DE FLUJO


1. INICIO
2. function [C] = lagran(X,Y)
3. Hacer n1=length(X);
4. Hacer n=n1-1;
5. Hacer L=zeros(n1,n1);
INICIO
6. Para k=1:n+1,
7. Hacer V=1;
8. Para j=1:n+1,
9. Si k~=j function [C] = lagran(X,Y)
10. Hacer V=conv(V,poly(X(j)))/(X(k)-X(j));
11. Fin si n1=length(X);
12. Fin Para n=n1-1;
13. Hacer L(k,:)=V; L=zeros(n1,n1)
14. Fin Para
15. Hacer C=Y*L;
16. FIN k=1;k=k+1;k<n+1

PROGRAMA EN MATLAB
function [C] = lagran(X,Y)
%------------------------------- V=1
%Este programa realiza la interpolación
de Lagrange a un conjunto de
% puntos (x,y) y muestra la lista de
coeficientes del polinomio j=1; j=j+1; j<n+1
% interpolante
% ENTRADAS
NO
% X : Vector de las abcisas
% Y : Vector de las ordenadas
% SALIDAS k~=j
% C : Lista de coeficientes del
polinomio de Lagrange SI
%-----------------------------------
n1=length(X);
n=n1-1; V=conv(V,poly(X(j)))/(X(k)-X(j))
L=zeros(n1,n1);
for k=1:n+1,
V=1;
j
for j=1:n+1,
if k~=j
V=conv(V,poly(X(j)))/(X(k)-
X(j));
L(k,:)=V
end
end
L(k,:)=V;
end k
C=Y*L;
end

RESULTADOS C=Y*L
>> X=[22.53 35.41 48.28 61.15 74.03]

X= C

22.5300 35.4100 48.2800 61.1500 74.0300


FIN
>> Y=[320 490 540 500 480]
Y=

320 490 540 500 480

>> [C] = lagran(X,Y)

C=

0.0001 -0.0180 0.6187 11.0931 -69.0629

>> P=poly2sym(C)

P=

(140311507112827*x^4)/1152921504606846976 -
(20309136268297*x^3)/1125899906842624 +
(1360600532165*x^2)/2199023255552 +
(97575570550203*x)/8796093022208 -
75935472333177/1099511627776

>> P=inline(P)

P=

Inline function:
P(x) =
x.*1.109305805473502e+1+x.^2.*6.1872948761674
71e-1-x.^3.*1.803813655625053e-
2+x.^4.*1.217008326691539e-4-
6.906290976364926e+1

>> P(42)

ans =

530.5709

6.- Emplee la porción de la tabla de vapor que se da para el H2O supercalentada a 200 MPa, para:
a) encontrar la entropía correspondiente S para un volumen específico v de 0.108 m3 /kg con
interpolación lineal, b) encontrar la misma entropía correspondiente con el uso de interpolación
cuadrática, y c) hallar el volumen correspondiente a una entropía de 6.6 con el empleo de
interpolación inversa.

v (m3/kg) 0.10377 0.11144 0.1254


S (kJ/kg · K) 6.4147 6.5453 6.7664
PSEUDOCÓDIGO DIAGRAMA DE FLUJO
1. INICIO
2. function [C] = lagran(X,Y)
3. Hacer n1=length(X);
4. Hacer n=n1-1;
5. Hacer L=zeros(n1,n1);
6. Para k=1:n+1,
7. Hacer V=1;
8. Para j=1:n+1,
9. Si k~=j
10. Hacer V=conv(V,poly(X(j)))/(X(k)-X(j));
11. Fin si
12. Fin Para
13. Hacer L(k,:)=V;
14. Fin Para
15. Hacer C=Y*L;
16. FIN

PROGRAMA EN MATLAB
%P8-E6
clc
clear all
X=input('lea el conjunto de
abcisas\n');
Y=input('lea el conjunto de
ordenadas\n');
[C,P]=Lagrange(X,Y)
fprintf('¿Quiere evaluar la
funcion en algun punto?\n')
l=input('ingrese 1 si quiere
evaluar la funcion\n');
if l==1
EV=inline(P);
r=input('ingrese el punto a
evaluar\n');
q=EV(r);
fprintf('la funcion evaluada es:
%4.3f \n',q)
end
PROGRAMA FUNCTION EN MATLAB
function [C] = lagran(X,Y)
%-------------------------------
%Este programa realiza la
interpolación de Lagrange a un
conjunto de
% puntos (x,y) y muestra la lista
de coeficientes del polinomio
% interpolante
% ENTRADAS
% X : Vector de las abcisas
% Y : Vector de las ordenadas
% SALIDAS
% C : Lista de coeficientes del INICIO
polinomio de Lagrange
%---------------------------------
--
function [C] = lagran(X,Y)
n1=length(X);
n=n1-1;
L=zeros(n1,n1); n1=length(X);
for k=1:n+1,
V=1; n=n1-1;
for j=1:n+1, L=zeros(n1,n1)
if k~=j

V=conv(V,poly(X(j)))/(X(k)-X(j));
k=1;k=k+1;k<n+1
end
end
L(k,:)=V;
end
V=1
C=Y*L;
end

j=1; j=j+1; j<n+1

NO

k~=j

SI

V=conv(V,poly(X(j)))/(X(k)-X(j))

L(k,:)=V

C=Y*L

FIN
7.- Desarrolle, depure y pruebe un sub-programa (function) en MATLAB, para encontrar un
polinomio interpolante de grado n y el valor de f(x) para cualquier x en el intervalo [x min, xmax].
Formule un Programa interactivo en GUIDE. Pruebe el programa con los datos del ejercicio 4. a)
Usando el método de Lagrange, b) Para el método de Newton.

Sugerencia - Argumentos: (x, y, n, xp)

xp es el valor de x para encontrar su valor de yp.

PROGRAMA EN MATLAB
function varargout = P8_E7(varargin)
% P8_E7 MATLAB code for P8_E7.fig
% P8_E7, by itself, creates a new P8_E7 or raises the existing
% singleton*.
%
% H = P8_E7 returns the handle to a new P8_E7 or the handle to
% the existing singleton*.
%
% P8_E7('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in P8_E7.M with the given input arguments.
%
% P8_E7('Property','Value',...) creates a new P8_E7 or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before P8_E7_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to P8_E7_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help P8_E7

% Last Modified by GUIDE v2.5 21-Nov-2021 17:31:46

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @P8_E7_OpeningFcn, ...
'gui_OutputFcn', @P8_E7_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before P8_E7 is made visible.


function P8_E7_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to P8_E7 (see VARARGIN)

% Choose default command line output for P8_E7


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);
set(handles.edit1,'String',' ')
set(handles.edit2,'String',' ')
set(handles.edit5,'String',' ')
set(handles.edit6,'String',' ')
set(handles.edit7,'String',' ')

% UIWAIT makes P8_E7 wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = P8_E7_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)


% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text


% str2double(get(hObject,'String')) returns contents of edit1 as a
double

% --- Executes during object creation, after setting all properties.


function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)


% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text


% str2double(get(hObject,'String')) returns contents of edit2 as a
double

% --- Executes during object creation, after setting all properties.


function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes during object creation, after setting all properties.


function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit4_Callback(hObject, eventdata, handles)


% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text


% str2double(get(hObject,'String')) returns contents of edit4 as a
double

% --- Executes during object creation, after setting all properties.


function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
X=get(handles.edit1,'String');
Y=get(handles.edit2,'String');
[C] = lagran(X,Y)
P=poly2sym(C);
P=inline(P);
x=str2double(get(handles.edit7,'String'));
Ans=P(x)
set(handles.edit5,'String',Ans)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

function edit5_Callback(hObject, eventdata, handles)


% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text


% str2double(get(hObject,'String')) returns contents of edit5 as a
double

% --- Executes during object creation, after setting all properties.


function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit6_Callback(hObject, eventdata, handles)


% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text


% str2double(get(hObject,'String')) returns contents of edit6 as a
double

% --- Executes during object creation, after setting all properties.


function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
X=get(handles.edit1,'String');
Y=get(handles.edit2,'String');
[C,D] = difdivabs(X,Y)
P=poly2sym(C);
P=inline(P);
x=str2double(get(handles.edit7,'String'));
set(handles.edit6,'String',P(x))
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

function edit7_Callback(hObject, eventdata, handles)


% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text


% str2double(get(hObject,'String')) returns contents of edit7 as a
double

% --- Executes during object creation, after setting all properties.


function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

8.- Cual es la diferencia entre ajuste de curvas por mínimos cuadrados (suavisado de curvas) y
interpolación polinómica de Lagrange? Que usos tiene cada uno?

Algunas suposiciones estadísticas, inherentes a los procedimientos lineales por mínimos


cuadrados, son 1. Cada x tiene un valor fijo; no es aleatorio y se conoce sin error.

2. Los valores de y son variables aleatorias independientes y todas tienen la misma varianza.

3. Los valores de y para una x dada deben estar distribuidos normalmente.

Tales suposiciones son relevantes para la obtención adecuada y el uso de la regresión.

Cuando se va a ejecutar sólo una interpolación, las formulaciones de Lagrange y de Newton


requieren un trabajo computacional semejante. No obstante, la versión de Lagrange es un poco
más fácil de programar. Debido a que no requiere del cálculo ni del almacenaje de diferencias
divididas, la forma de Lagrange a menudo se utiliza cuando el grado del polinomio se conoce a
priori.

También podría gustarte