%Aufgabe 3.2, Picard Iteration zu Lehrzwecken im Beispiel
%Copyright (C) 2019  Sascha Eichmann
%
%    This program is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with this program.  If not, see <https://www.gnu.org/licenses/>

clear;
%Rechte Seite der Differentialgleichung
f= @(t,x) (x).*exp(-t);
%Startwert
x_0=1;
%Startzeit
t_0=0;
%Endzeit
T= 5;
%Diskretisierung des Zeitintervalls
t=[t_0:0.01:T];
help=x_0*ones(1,length(t));
%Zwischenschritte
x_iter=help;

anz_Iteration=10;
%Picard-Iteration
for i=[1:anz_Iteration]
  x_iter=help + cumtrapz(t,f(t,x_iter));
end

plot(t,x_iter);
%Vergleich mit analytischer Loesung
%test=x_0.*exp(-exp(-t)+1);
%plot(t,x_iter, t, test);