function [t,w]=BackwardEulerfe(N,a,b,alpha,x) %N=number of steps %a=initial time %b=final time %alpha=initial values at t=0 %x=initial guesses of the function %Forward Euler was initailly coded up to provide the initial guesses for %the newton method. But was not later used. % wfe=zeros(1,n); % h=(b-a)/N; % %w=zeros(1,:); % w(1,:)=alpha; % t(1)=a; % n=length(alpha); %take in y_initial for all the different % wfe=zeros(n,1); %FORWARD EULER IS RAN 10 TIMES TO PROVIDE GUESSES FOR BACKWARD EULER % h=(b-a)/10; % wfe(1,:)=alpha; %takes in y_intial % T(1)=a; %take in t_initial % % % for i=1:10 % wfe(i+1,:)=wfe(i,:)+h*(f_ForwardEuler(T(i),wfe(i,:))); % T(i+1)=T(i)+h; % end; % % x=wfe(10,:) n=length(alpha); %take in y_initial for all the different w=zeros(1,n); %makes a zero function h=(b-a)/N; w(1,:)=alpha; %puts in the initial value t(1)=a; %initial value of the time for j=1:N w(j+1,:)=newton(x,w(j,:),h,t(j)); %Backward euler step t(j+1)=t(j)+h; end;