Question
ODE
From van der pol’s equation
4. For μ = 1 .5 and the initial conditions x(0) = 0.a and x (0)= 0b , where a and b are before the last and the last digits o
0 0
Add a comment Improve this question Transcribed image text
Answer #1


%%Matlab code for Eulers forward clear all close all mu for Vander pol equation mu-1.5; %function for Euler equation solutiophase potrait plot for x0:0.3 dpja:0.4 2.5 2 1.505 051525 phase potrait plot for x(0)-2 dx(0)/dt 0 2.5 21.5 50515 2 25

%%Matlab code for Euler's forward
clear all
close all
%mu for Vander pol equation
mu=1.5;
%function for Euler equation solution
f1=@(x,y,t) y;
f2=@(x,y,t) mu*(1-x^2)*y-x;
%all step size
h=0.01;
%Initial values change as per student ID of the for 0.a and 0.b
%where a and b are before the last and last digit of Student ID
x0=0.3; %0.a as per student id
y0=0.4; %0.b as per student id
%initial t
t0=0;
%t end values
tend=20;
tn=t0:h:tend;

% Euler steps
x1_result(1)=x0;
x2_result(1)=y0;
t_result(1)=t0;

%loop for Euler step for finding the solution
for i=1:length(tn)-1
t_result(i+1)= t_result(i)+h;
x1_result(i+1)=x1_result(i)+h*double(f1(x1_result(i),x2_result(i),t_result(i)));
x2_result(i+1)=x2_result(i)+h*double(f2(x1_result(i),x2_result(i),t_result(i)));
end

%printing the result for solving Vander pol equation
fprintf('printing the result for solving Vander pol equation for x0=0.3 dx(0)/dt=0.4\n')
fprintf('\ttime\tx(t)\tdx(t)/dt\n')
for i=1:100:length(x1_result)
    fprintf('\t%.2f\t%.4f\t%0.4f\n',t_result(i),x1_result(i),x2_result(i))
end

%Plotting exact solution and numerical solution
figure(1)
plot(x1_result,x2_result)
xlabel('x')
ylabel('dx/dt')
title('phase potrait plot for x(0)=0.3 dx(0)/dt=0.4')

%all step size
h=0.01;
%Phase potrait plot for initial condition x0=0 and y0=0
x0=2;
y0=0;
%initial t
t0=0;
%t end values
tend=20;
tn=t0:h:tend;

% Euler steps
x1_result(1)=x0;
x2_result(1)=y0;
t_result(1)=t0;

%loop for Euler step for finding the solution
for i=1:length(tn)-1
t_result(i+1)= t_result(i)+h;
x1_result(i+1)=x1_result(i)+h*double(f1(x1_result(i),x2_result(i),t_result(i)));
x2_result(i+1)=x2_result(i)+h*double(f2(x1_result(i),x2_result(i),t_result(i)));
end

%printing the result for solving Vander pol equation
fprintf('\nprinting the result for solving Vander pol equation for x0=2 dx(0)/dt=0\n')
fprintf('\ttime\tx(t)\tdx(t)/dt\n')
for i=1:100:length(x1_result)
    fprintf('\t%.2f\t%.4f\t%0.4f\n',t_result(i),x1_result(i),x2_result(i))
end

%Plotting exact solution and numerical solution
figure(2)
plot(x1_result,x2_result)
xlabel('x')
ylabel('dx/dt')
title('phase potrait plot for x(0)=2 dx(0)/dt=0')

%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
ODE From van der pol’s equation 4. For μ = 1 .5 and the initial conditions...
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