-30*y+30*x+2*x this is stiff ODEs, solve by runge kutta method with 50 iteration step size is 0.05. can you defined how to identify interval B/C i don't know what is interval please help me and i also need Actual solution exact values.

1 view (last 30 days)
function yp=f(x,y)
yp=-30*y+30*x^2+2*x; %yp=y'
x0=0; y0=1; xf=1;
n=10;
h=(xf-x0)/n;
x=x0; y=y0;
X=x; Y=y;
for i=1:n %fori=1 to n do
k1=f(x,y); %left_hand slope
k2=f(x+h/2,y+h*k1/2); %1st midpoint slope
k3=f(x+h/2,y+h*k2/2); %2nd midpoint slope
k4=f(x+h,y+h*k3); %the right_hand slope
k=(k1+2*k2+2*k3+k4); % average slope
y=y+h*k; %R-K step to update y
x=x+h; % updatex
X=[X;x]; %adjoin new x-value
Y=[Y;y]; %adjoin new y_value
end
format long
[x,y];

Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!