Lab5_Instructions

pdf

School

Drexel University *

*We aren’t endorsed by this school

Course

232

Subject

Mathematics

Date

Jan 9, 2024

Type

pdf

Pages

8

Uploaded by PrivateStorkPerson124

Report
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 1 In this lab, we study a differential equation with complex roots and force it with a sinusoidal function. This will help you master the Method of Undetermined Coefficients . We will first look at the homogeneous DE, and then add various multiples of the forcing term to illustrate linearity and superposition. Part A: Homogeneous DE Question 1: Consider the initial value problem: Note this 2 nd -order equation is linear and homogeneous. We will add a forcing term in part B. Using pplane8 , create a phase diagram, for this DE. a. Proceed and show the nullclines . In MATLAB, nullclines are Contours . Under Solutions on the pplane8 Display window, select Show nullclines . All solutions that cross a nullcline will do so at a local max or min. There are two nullclines, one for each of the variables ? 1 and ? 2 . The respective nullclines are where the derivative of either variable is zero. Nullcline for ? 1 : 𝑑 𝑑𝑡 ? 1 = ? 2 = 0 So this nullcline is the horizontal axis ? 2 = 0 Nullcline for ? 2 : 𝑑 𝑑𝑡 ? 2 = − ( 17 4 ) ∗ ?1 − ?2 = 0 So this nullcline is the line ? 2 = − ( 17 4 ) ∗ ?1 Make the axes equal so circles look like circles and not ellipses. We decompose this 2 nd ODE into two 1 st ODE to use with pplane8. These two equations are: ? 1 = ? 2 ? 2 = −(17/ 4) ∗ ? 1 − ? 2
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 2 So far, your phase plane should look like this. b. Next let's add some solution curves. First, use Options and set the Solution direction to Forward only. Next, using Keyboard input , find the solutions for each of the initial points below. Show the first in magenta and second in blue . Increase their LineWidth to 3. IC: (𝟒, 𝟎), (−𝟒, 𝟎) Q1: Paste your completed phase plot into the answer template. Be sure the solution for (4,0) is in magenta and that for ( 4,0) is in blue . Be sure the nullclines are visible. Replace this sample graph, which has some of the graph hidden with an unrelated image of panther cubs. Sample x1 ' = x2 x2 ' = - (17/4) x1 - x2 -5 0 5 x1 -5 -4 -3 -2 -1 0 1 2 3 4 5 x2
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 3 Question 2: Find the exact solution to this same initial value problem using dsolve . Tips: Declare y(t) as symbolic first using syms . Then within dsolve , use == to denote equality in equations. Q2: Copy the exact solution into the answer template including the code used to find it. Question 3: Use the help to review matlabFunction() . Use it to define the functions Y(t) and DY(t), its derivative. These represent the exact solution and its derivative. Hint: If you let sol denote the exact solution from dsolve , sol = dsolve( ... ) % Arguments hidden. then you can make that answer into a function using: Y = matlabFunction(sol) Now define DY using Y , the diff() command and another matlabFunction() . Next evaluate 𝑌(0) and 𝐷𝑌(0) to verify both your functions are working. Of course, we expect 𝑌(0) = 4 and 𝐷𝑌(0) = 0 , since 𝑌(?) is the solution to the IVP. Q3: Now evaluate both functions at time t =1. Paste in your values for Y(1) and DY(1) below. This demonstrates you can evaluate the solution and its derivative anywhere! %% Q2 - Solve the Homogeneous IVP exactly using dsolve. syms y(t) Dy = diff(y,t); D2y = diff(y,t, t); % The exact solution is: ?(?) = ⋯ Alert: High risk for the MATLAB Exam! Q3: Answer >> 𝑌(1) = _ _ _ _ _ >> 𝐷𝑌(1) = _ _ _ _ _
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 4 Q4-5: Using your exact functions Y(t) and DY(t), and subplot commands, create component plots for Y and DY and their phase plot. Do not use ode45 or any other approximate solver. You already have the exact answers! Here is the start of the first of the three plots to get you started. We'll cut the plot into six tiles (instead of 4) to allow more room for the phase plot on the right. We'll draw Y(t) in magenta in tile 1 and its derivative in red in tile 4 . The phase plot on the right will take all four of the tiles 2, 3, 5 and 6. Now add a plot of DY(t) in tile 4 (bottom left) and add the phase plot on the right using both tiles 2, 3, 5 and 6, using [2, 3, 5, 6] in your code. Label the axes, give appropriate titles, set the 'FontSize' to 20 and draw DY in red and the phase curve in black . Mark the starting point (4,0) in the phase plot. Add a legend to the phase plot as shown. Mark the initial point with a blue circle filled in green . Mark the center of the circle point as a blue hexagram filled in yellow . Here's some sample code. >> plot(0, 0, 'bh' , 'MarkerSize' , 14, 'MarkerFaceColor' , 'yellow' ) % Center Point Questions 4-5: Paste your completed component and phase plots into the answer template for credit. Replace this sample graph, which has some of the image hidden by amethyst crystals. figure subplot(2,3,1) % tile 1 time = 0: 0.01 : 10; plot(time, Y(time), 'm' , 'LineWidth' ,3) grid on hold on 4 5 6 1 2 3 Sample
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 5 Part B: Non-Homogeneous DE: Method of Undetermined Coefficients Consider the non-homogeneous initial value problem: Questions 6-7: Complete the table below, to find the unique solution matching the initial conditions and the given forcing function ?(?) which varies in each row. Simply use dsolve() . The homogeneous part is given, so you just need to add on the particular terms right after the trailing + sign. If you do not see the blue terms in the solution returned by dsolve , try simplify() . Forcing function 𝒇(𝒕) Guess for Particular Solution Unique Solution y(t) a. ?(?) = 17 + 289? ?? + ? ?(?) = ? 𝑡 2 ∙ [7 cos 2? − 27 4 sin 2? ] + b. ?(?) = 100 ? −2𝑡 ? ? −2𝑡 ?(?) = ? 𝑡 2 ∙ [4 sin 2? ] + c. ?(?) = 260 cos 2? ? cos 2? + ? sin 2? ?(?) = −? 𝑡 2 ∙ [32 sin 2? ] + d. ?(?) = 16? 𝑡 2 cos 2? + 32 ? 𝑡 2 sin 2? Bump up! ? ? −𝑡/2 [? cos 2? + ? sin2?] ?(?) = ? 𝑡 2 ∙ [4 cos 2? + 2 sin 2? ] + * Grader will randomly pick two to check for correctness. Question 8: Let's focus on part ( c) above. This time, we will not rely on dsolve , but will implement the Method of Undetermined Coefficients from scratch! Based on Lecture 4-5, you should expect a particular solution of the form below, as this would be closed under differentiation. ? 𝑝 (?) = ? ∙ cos(2?) + ? ∙ sin(2?) Since the functions cos(2?) and sin(2?) are not solutions of the homogeneous equation so we will NOT need to bump it up ! Let's verify our solution has the above form: Enter the above DE and find the exact solution by substituting our guess for ? 𝑝 (?) into the original DE, which now includes the forcing term ?( ?) = 260 cos 2? . Let's solve for A and B as follows. See next page.
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 6 This gives: (8*B + A)*cos(2*t) + (B - 8*A)*sin(2*t) == 260*cos(2*t) The coefficients of both terms must match on each side: cos(2t): A + 8B = 260 sin(2t): -8A + B = 0 so ? = 8? Plugging ? = 8? into the first equation we find: ? = 260 65 = 4, ? = 32 Thus, the method of undetermined coefficients leads to the particular solution: ? 𝑝 (?) = 4 ∙ cos(2?) + 32 ∙ sin(2?) Questions 9-10: Graph the Non-Homogeneous Solution Tip: You can clone most of your plotting code from Questions 4-5 to create the plot for this part. Of course, both the functions ?(?) and ?′(?) have changed. You will earn the remaining two points by pasting in your completed graph for these questions. DE: 𝟒? ′′ + 4? + 17? = 𝟐𝟔𝟎 𝐜𝐨𝐬(𝟐𝒕) IC: ?(0) = 4 ? (0) = 0 Create a new figure using: fig3 = figure(3); % Start with a new figure using ***SIX TILES*** in a 2x3 grid subplot(2,3,1) % We'll plot the solution Y(t) in tile #1 in magenta %% QUESTION 8: The Method of Undetermined Coefficients from SCRATCH clc syms A B t syms y(t) a b Dy = diff(y,t); D2y = diff(y,t, t); f = 260 * cos(2*t) DE = 4* D2y + 4*Dy + 17*y - f == 0 % non-homogeneous differential equation Y = A * cos(2*t) + B * sin(2*t) % our guess plug_it_in = subs(DE, y, Y) % Plug our guess into the DE eqn = collect(plug_it_in, [cos(2*t), sin(2*t)]) % arrange by similar terms % MATLAB can find the undetermined coefficients for us equations = coeffs( lhs(eqn), [cos(t), sin(t)] ) variables = [A, B] % find and display the undetermined coefficients [A, B] = solve(equations, variables) Question 8: Now that you have found the particular solution, record its derivative for one point. ? 𝑝 (?) = _ _ _ _ _
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 7 We will use the same 2x3 grid we used earlier in Question 4-5. a . In the first tile, plot the solution ?(?) using your solution from dsolve found earlier. Use magenta and a linewidth of 3. Be sure your forcing function is ?(?) = 260 cos 2? . b . In the fourth tile, plot the solution for its derivative ?′(?) using your solution from dsolve found earlier and the diff command. Use red and a linewidth of 3. c . In the combined tiles [2, 3, 5, 6] , plot the phase plot with ?(?) along the horizontal axis and its derivative ?′(?) along the vertical axis. Use black and a linewidth of 3. d. You can see the phase plot approaches a limiting ellipse as the transitory parts of the solution die out for large values of t . Add hat limiting ellipse now. It is drawn using just the particular solution: ? 𝑝 (?) = 4 ∙ cos(2?) + 32 ∙ sin(2?) and its derivative: ? 𝑝 (?) = −8?𝑖𝑛 + 64 ∙ cos(2?) e. Add legend as shown in the sample. Adjust all the axes to get a good view of your plots using the axis command. Questions: 9-10: Paste your completed multiplot in the answer template. Replace the image below with your completed multiplot. Some info has been obscured in the sample with a dragon's eye! Your submission must not include the dragon eye. Sample
Lab 5: Method of Undetermined Coefficients ENGR-232 Winter 2022 8 Ready to Submit? Be sure all ten questions are answered. When your lab is complete, be sure to submit three files: 1. Your completed Answer Template as a PDF file 2. A copy of your MATLAB Live Script 3. A PDF copy of your MATLAB Live Script (Save- Export to PDF…) The due date is the day after your lab section by 11:59pm to receive full credit. You have one more day, to submit the lab (but with a small penalty), and then the window closes for good and your grade will be zero. Grader will award 2 points as follows. i. All three graphs are correct ii. The red limit cycle and the legend are included in the phase plot.