In [1]:
pkg load symbolic
In [26]:
syms y(t) t ;
f=@(t,y) t-y ;
egyenlet=diff(y(t),t)==t-y ;
sol=dsolve(egyenlet,y(0)==1) ;
fsol=matlabFunction(rhs(sol)) ;
tb=0:0.5:3;
yb=-1:0.5:5;
[T,Y]=meshgrid(tb,yb);
dY=f(T,Y);
dT=ones(size(dY));
quiver(T,Y,dT,dY);
hold on;
xx=linspace(tb(1),tb(end));
plot(xx,fsol(xx));
axis([tb(1),tb(end),yb(1),yb(end)])
warning: worked around octave bug #42735
warning: called from
    minus at line 42 column 5

fixpont-iteráció

y=f(t,y)  y(a)=b
y(t)=b+atf(s,y(s))ds
yT(y), ahol  T(y)(t)=b+atf(s,y(s))ds
ynyn+1=T(yn), ahol  T(yn)(t)=b+atf(s,yn(s))ds
f(t,y)=ty,  y0(t)=1
y1(t)=1+0t(s1)ds=1t+t22

y2(t)=1+0t(s1s22+s)ds=1t+t2t36
y3(t)=1+0t(s1+ss2+s36)ds=1t+t2t33+t424
y4(t)=1+0t(s1+ss2+s33t424)ds=1t+t2t33+t412t5120

In [29]:
quiver(T,Y,dT,dY);
hold on;
xx=linspace(tb(1),tb(end));
plot(xx,fsol(xx),'.-');
plot([tb(1),tb(end)],[1,1]);
uj=@(t) 1-t+1/2*t.^2;
plot(xx,uj(xx),';1;');
uj=@(t) 1-t+t.^2-1/6*t.^3;
plot(xx,uj(xx),';2;');
uj=@(t) 1-t+t.^2-1/3*t.^3+1/24*t.^4;
plot(xx,uj(xx),';3;');
uj=@(t) 1-t+t.^2-1/3*t.^3+1/12*t.^4-1/120*t.^5;
plot(xx,uj(xx),';4;');

axis([tb(1),tb(end),yb(1),yb(end)])