Question

3. (25 points) Given a series of ODES: dy = 6e– y2 +224/7 = 62 + 3y Given initial conditions y(0)=0, 2(0)=1, and I = 1; dra d
0 0
Add a comment Improve this question Transcribed image text
Answer #1


first on der ode- 2 equ o into We have to op - Gempl3x) -y +22 -0 dz - 627 3y - speit Let yoy, de la 292 6 eup (33) -4% +2 Z %%Matlab code for solving ode clear all close all %Initial conditions for ode u0=[0;1;1]; h=1; % Solution for equation usingfunction dydt = odel_equation(x,y) eql = y(2); eq2 = 6. *exp(3.*x)-(y(1)).^2+2.*y(3); eq3 = 6.*(y(3)).^2+3.*y(1); %Evaluate t10763 Solution plot using RK2 12 (x)Z O 0.5 1 1.5 2.5 3 3.5 4 2 y(x) *100 10163 Solution plot using RK2 x vs. y(x) 12 y(x) 0Solution plot using RK2 x vs. dy(x)/dx 9x1087 хрохир о 0.5 1 15 2 25 3 3.5 4 10 103 Solution plot using RK2 x vs. z(x) 12 2(x

%%Matlab code for solving ode
clear all
close all

%Initial conditions for ode
    u0=[0;1;1];
    h=1;
%Solution for equation using ode45
        %minimum and maximum time span
        tspan=[0 5];
        %Solution of ODEs using ode45 matlab function
        [x,s]= RK2System(@(t,y) odel_equation(t,y), tspan, u0,h);
        fprintf('Solution using RK2 method for h=1\n')
        for i=1:length(s)
            fprintf('At x=%2.2f y(%2.2f)=%2.2e,\n\t dy(%2.2f)/dx=%2.2e\n\t z(%2.2f)=%2.2e\n',...
                x(i),x(i),s(1,i),x(i),s(2,i),x(i),s(3,i))
        end
        figure(1)
        plot3(s(1,:),s(2,:),s(3,:),'b','linewidth',2)
        xlabel('y(x)')
        ylabel('dy(x)/dt')
        zlabel('z(x)')
        title('Solution plot using RK2')
        box on
        grid on
        view([0 0]);
        figure(2)
        plot(x,s(1,:),'b','linewidth',2)
        ylabel('y(x)')
        xlabel('x')
        title('Solution plot using RK2 x vs. y(x)')
        box on
        grid on
        figure(3)
        plot(x,s(2,:),'b','linewidth',2)
        ylabel('dy(x)/dx')
        xlabel('x')
        title('Solution plot using RK2 x vs. dy(x)/dx')
        box on
        grid on
        figure(4)
        plot(x,s(3,:),'b','linewidth',2)
        ylabel('z(x)')
        xlabel('x')
        title('Solution plot using RK2 x vs. z(x)')
        box on
        grid on

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Function for evaluating the ODE
function dydt = odel_equation(x,y)

    eq1 = y(2);
    eq2 = 6.*exp(3.*x)-(y(1)).^2+2.*y(3);
    eq3 = 6.*(y(3)).^2+3.*y(1);

    %Evaluate the ODE for our present problem
    dydt = [eq1;eq2;eq3];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%RK4 system for multidimentional problem
function [t,y]=RK2System(Func,Tspan,Y0,h)

    %initialization
    t0= Tspan(1);
    tf= Tspan(2);
    N=(tf-t0)/h ;
    t=t0:h:tf;
    y=zeros(length(Y0),N+1);
    y(:,1) = Y0;
  
    for i=1:N
        k1=h*Func(t(i),y(:,i));
        k2=h*Func(t(i)+h/2,y(:,i)+k1/2);
        y(:,i+1)=y(:,i)+k2;
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
3. (25 points) Given a series of ODES: dy = 6e– y2 +224/7 = 62 +...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT