Fixed Point Iteration technique for nonLinear ODEs

조회 수: 11 (최근 30일)
Ronan Downes
Ronan Downes 2016년 10월 15일
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개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by