Fixed Point Iteration technique for nonLinear ODEs
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to solve u''=(u-4)./(5-u)-exp(3*x)
Is this code correct
%% Housekeeping clc clear all format compact n = 100; tol = 10^-4; x = linspace(0,1,n)'; a = linspace(0.1,1,10)'; b = ones(10,1)'; S=(n-1)^-1*(gallery('tridiag',n,-1,2,-1)); %One Line Generation of Sparse Matrix A.
%% Anonymous Functions kappa=10^-4 ;
A=@(x,u) (u-4)./(5-u)-exp(3*x) ; B=@(x,u) -(u+kappa).^-1.5-x.*exp(4*x); C=@(x,u) -(u+kappa).^-7-x.*exp(4*x); %% The Fixed Point Method A format compact d = 1; i = 0; u = zeros(n,1);
while d>tol && i<2 unew = -(S\((A(x,u)))); d1=max(abs(u-unew)); d2=(abs(S*unew+A(x,unew))); d=max(abs(d1-d2)); u=unew; i=i+1; end fpAi=i fpAd=d
figure; % plot (x,u,'-r*'); plot (x,u); title('Fixed point method for Equation A') xlabel('X axis'); ylabel('u(x)');
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!