In: Advanced Math
Consider the following nonlinear differential equation, which models the unforced, undamped motion of a "soft" spring that does not obey Hooke's Law. (Here x denotes the position of a block attached to the spring, and the primes denote derivatives with respect to time t.) Note: x3 means x cubed not
x''' x′′ - x + x^3 = 0
a. Transform the second-order d.e. above into an equivalent system of first-order d.e.’s.
b. Use MATLAB’s ode45 solver to generate a numerical solution of this system over the interval 0 ≤ t ≤ 6π for the following two sets of initial conditions.
i. x(0)=2,x′(0)=−3
ii. x(0) = 2, x′(0) = 0
c. Graph the two solutions on the same set of axes. Graph only x vs. t for each IVP; do not graph x′. Be sure to label the axes and the curves. Include a title that contains your name and describes the graph, something like “Numerical Solutions of x′′ +x− x3 = 0 by I. M. Smart.” (obviously your name!). Make sure to include a date/time stamp on the graph, Note: To get x′′ to appear in your title you will have to type x′′′′ in your MATLAB title command.
d. Based on your graph, which solution appears to have the longer period? Explain clearly how you arrived at your answer
MATLAB Script (run it as a script, NOT from command window):
close all
clear
clc
% Letting x' = u
% u' = x'' = x - x^3
ic1 = [2; -3];
[t1, y1] = ode45(@vdp1, [0 6*pi], ic1);
ic2 = [2; 0];
[t2, y2] = ode45(@vdp1, [0 6*pi], ic2);
% Plotting
figure, plot(t1, y1(:,1), t2, y2(:,1))
name = 'NAME'; % change this to your name
xlabel('t'), ylabel('x(t)'), title(sprintf('Numerical Solution to
x'''' - x + x^3 = 0 by %s', name))
legend('Conditions (i)', 'Conditions (ii)')
fprintf('Based on the graph, (ii) seems to have 4 periods in the
given time span, while (i) seems to have 5 periods.\n')
fprintf('Hence, (ii) has longer time period.\n')
function dydt = vdp1(~,y)
dydt = [y(2); y(1) - y(1)^3]; % y(1) => x and y(2) => u or
x'
end
Plot:
Output:
Based on the graph, (ii) seems to have 4 periods in the given
time span, while (i) seems to have 5 periods.
Hence, (ii) has longer time period.