secant method in nonlinear ode

by

 

this will find the solution of U''=k*U*U' by using taylor series 3rd order and secant method

secant.m
%% u''=2*u*u' , u(0)=1/2, u(1)=1, h=1/4 s_0=0.05, s_1=.2

u=zeros(4,1);
p=zeros(4,1);
u(1,1)=1/2;
n=3;
phi=zeros(100,1);
s=zeros(100,1);
m=input('mention the tolerance');

for k=1:2
s(k,1)=input('enter the  guess value of slope');
p(1,1)=s(k,1);
h=1/4;
phi(k,1)=math1(u(1,1),p(1,1));
end
phi(1:k,1)
s(1:2,1)
s(3,1)=s(2,1)-((s(2,1)-s(1,1))*phi(2,1)/(phi(2,1)-phi(1,1)));
phi(3,1)=math1(u(1,1),s(3,1));
phi(3,1)
while abs(phi(n,1))>=m
     s(n+1,1)=s(n,1)-((s(n,1)-s(n-1,1))*phi(n,1)/(phi(n,1)-phi(n-1,1)));
     phi(n+1,1)=math1(u(1,1),s(n+1,1));
     s(n+1,1)      
     phi(n+1,1)
     n=n+1;
end
fprintf('the final output is : ''%f', (1+phi(n,1)))
 g=vpa(1+phi(n,1))
 
     

    





    

Contact us