Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Quiz 6&7 -Math 308 Group (of 5-6 students) Assignment (Due April 1) 20 pts Name:

ID: 3281795 • Letter: Q

Question

Quiz 6&7 -Math 308 Group (of 5-6 students) Assignment (Due April 1) 20 pts Name: Name: ANSWERS NEED TO BE LISTED ON THE BACK OF THIS PAPER, AND COMPUTER PROGRAMS&OUTPU; NEED TO BE ATTACHED A mass of weight 4 pounds stretches a NONLINEAR spring . The mass moves in a fluid which exerts a viscous force of 2 pounds when its speed is 4 feet /second. The mass is set to move from equilibrium with an initial velocity 2 feet/ second downward under external force F()-sin(21). Hook's Law for this Nonlinear Spring has the form: F-kx+kr, where x is the amount of the stretch in the spring and k^ & k, are spring constants determined by expeiements The initial value problem (IVP) that describes the position y(t) of the mass for t20is determined as Name: Name: Name: Name: y(0)-0& y (0) 2 NOTE: In Quiz 5 we solved IVP(*) analytically for a linear spring with k, 24 &k2; 0 (A) Solve IVP(*) numerically using Matlab for the case when k 24&k2; 0 and compare with the EXACT Solution obtained in Quiz 5 by plotting both the solutions on the interval [0,10] (use different colors). (3 pts) (B) Solve IVP(*) numerically using Matlab for the case when k 24& k2 -0.25 and compare with the solution when k 24&k;, -0 by plotting both the solutions on the interval 0,10 (use different colors). (7 pts) (C) Solve IVP(*) numerically using Matlab for the case when k,-24& k2 0.5 and compare with the solutions when k,-24 & k2-0 andk, = 24 & k. = 0.25 by plotting the three solutions on the interval [0, IO] (use different colors). (7 pts) (D) From the results obtained above, what are the effects of the nonlinearity of the spring on the vibration? (3 pts)

Explanation / Answer

You can use this script to solve the parts (A), (B), (C). The graphs are so overlapping that you may feel problem to see all of them at the same time. If you have any doubt please comment.

===================================================================

%This code was written on MATLAB R2014a
%% Clear Interface
clc();
clear('all');
close('all');
%% Define Variables
tspan = [0 10];
y0 = [0 2];
k1 = 24;
k2 = 0;
syms y(t)
ode = diff(y,2) + 4*diff(y,1) + 8*k1*y + 8*k2*y^3 == 8*sin(2*t);

%To find exact solution
Dy = diff(y);
cond1 = y(0) == 0;
cond2 = Dy(0) == 2;
conds = [cond1 cond2];
yExact(t) = dsolve(ode,conds);
yExact = simplify(yExact);

%% Part (A)
V = odeToVectorField(ode);
f = matlabFunction(V,'vars', {'t','Y'});
[T, Y] = ode45(f, tspan, y0);
yNumeric = Y(:,1);
hold('on');
plot(T, double(yExact(T)),'r-+')
plot(T, yNumeric, 'b-x');
legend('Exact', 'Approximate');

%% Part (B)

T1 = T;
yNumeric1 = yNumeric;
k1 = 24;
k2 = 0.25;
ode = diff(y,2) + 4*diff(y,1) + 8*k1*y + 8*k2*y^3 == 8*sin(2*t);
V = odeToVectorField(ode);
f = matlabFunction(V,'vars', {'t','Y'});
[T, Y] = ode45(f, tspan, y0);
yNumeric = Y(:,1);
figure();
hold('on');
plot(T1, yNumeric1,'r-+')
plot(T, yNumeric, 'b-x');
legend('k2 = 0', 'k2 = 0.25');

%% Part (C)

T2 = T;
yNumeric2 = yNumeric;
k1 = 24;
k2 = 0.5;
ode = diff(y,2) + 4*diff(y,1) + 8*k1*y + 8*k2*y^3 == 8*sin(2*t);
V = odeToVectorField(ode);
f = matlabFunction(V,'vars', {'t','Y'});
[T, Y] = ode45(f, tspan, y0);
yNumeric = Y(:,1);
figure();
hold('on');
plot(T1, yNumeric1,'r-+')
plot(T2, yNumeric2,'b-x')
plot(T, yNumeric, 'g-*');
legend('k2 = 0', 'k2 = 0.25','k2 = 0.5');