Documente Academic
Documente Profesional
Documente Cultură
g = input('Ingresa la Funcion');
f = inline(g);
x0 = input('Ingresa X0');
h = input('Ingresa el tamaño de paso');
y0 = f(x0)
solution = 0;
if orden == 1
if puntos == 2
if metodo == 1
solution = (f(x0+h)-y0)/h;
else
if metodo == 2
solution = (f(x0+h)-f(x0-h))/(2*h);
else
solution = (y0-f(x0-h))/(h);
end
end
else
if metodo == 1
solution = (-3*y0+4*f(x0+h)-f(x0+2*h))/(2*h);
else
if metodo == 2
solution = (f(x0-2*h)-8*f(x0-h)+8*f(x0+h)-f(x0+2*h))/(12*h);
else
solution = (f(x0-2*h)-4*f(x0-h)+3*y0)/(2*h);
end
end
end
else
if orden == 2
if puntos == 2
if metodo == 1
solution = (y0-2*f(x0+h)+f(x0+2*h))/(h.^2);
else
if metodo == 2
solution = (f(x0-h)-2*y0+f(x0+h))/(h.^2);
else
solution = (f(x0-2*h)-2*f(x0-h)+y0)/(h.^2);
end
end
else
if metodo == 1
solution = (2*y0-5*f(x0+h)+4*f(x0+2*h)-f(x0+3*h))/(h.^2);
else
if metodo == 2
solution = (-f(x0-2*h)+16*f(x0-h)-30*y0+16*f(x0+h)-
f(x0+2*h))/(12*h.^2);
else
solution = (-f(x0-3*h)+4*f(x0-2*h)-5*f(x0-h)+2*y0)/(h.^2);
end
end
end
else
if puntos == 2
if metodo == 1
solution = (-y0+3*f(x0+h)-3*f(x0+2*h)+f(x0+3*h))/(h.^3);
else
if metodo == 2
solution = (-f(x0-2*h)+2*f(x0-h)-2*f(x0+h)+f(x0+2*h))/
(8*h.^3);
else
solution = (-f(x0-3*h)+3*f(x0-2*h)-3*f(x0-h)+y0)/(h.^3);
end
end
else
if metodo == 1
solution = (-5*y0+18*f(x0+h)-24*f(x0+2*h)+14*f(x0+3*h)-
3*f(x0+4*h))/(2*h.^3);
else
if metodo == 2
solution = (f(x0-3*h)-8*f(x0-2*h)+13*f(x0-h)-13*f(x0+h)
+8*f(x0+2*h)-f(x0+3*h))/(8*h.^3);
else
solution = (3*f(x0-4*h)-14*f(x0-3*h)+24*f(x0-2*h)-18*f(x0-
h)+5*y0)/(2*h.^3);
end
end
end
end
end