We begin this lab by developing some graphical tool to better visualise to solutions to dif-...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
We begin this lab by developing some graphical tool to better visualise to solutions to dif- ferential equations. We begin with Quiver plots: A quiver plot is used to display a two di- mensional vector field. It is called in python with plt.quiver. This function requires four arguments, all of which must be arrays of the same size. The first two arguments define a grid of (x, y) points. The grid can be created using the meshgrid function in numpy: |X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, 2)) This creates a 2-dimensional grid of points in the range 0 to 2 in the x and y directions. The next arguments specify the components of a 2-dimensional vector, V(x, y) = (Vx(x, y), Vy(x, y)), at the corresponding grid points. Python will draw an arrow at each grid point to represent the vector field V(x, y). As an example; define the vector field, V(Vx, Vy), as: Vx = np.cos (X) Vy = np. sin (Y) Implement and run the following code illustrating how to make a quiver plot, as well as affect figure size, geometry and labelling: import matplotlib.pyplot as plt import numpy as np np.meshgrid(np. arange (0, 2 np.pi, .2), np.arange (0, 2* np.pi, .2)) plt.close() X, Y = Vx = np.cos(X) Vy np.sin(Y) = plt.figure (figsize=(6,6)) plt.gca ().set_aspect ('equal', adjustable='box') #Make plot box square plt.xlabel('x') plt.ylabel('y') plt.title('Example of a quiver plot') plt.quiver (X, Y, Vx, Vy, pivot='mid', label='$V_x$ plt.legend () plt.show() = cos ($x$), $V_y$ = sin ($y$)') 6 5 4 31 2 1 Example of a quiver plot | V₁ = cos(x), V, = sin(y) > 3 0- Quiver plot with reduced density V = cos(x), Vy= sin(y) 4 (a) (b) Figure 1: Examples of quiver plots for the vector field defined by (cos(x), sin(y)) for different grid densities and plot options The code should produce a plot as shown in Fig. 1(a) Note that at each gridpoint the arrow is proportional to the magnitude and direction of the vector V at that point. Vary the grid density and explain what you are observing: It is possible to add a legend for the arrow lengths on to the quiver plot as follows: Q-plt.quiver (X, Y, U, V, pivot='mid', label='$V_x$ = cos($x$), $V_y$ = sin($y$)') plt.quiverkey (Q, 0.9, 0.9, 2, r'$2\frac{m} {s}$', labelpos='E', coordinates='figure') One can produces a less dense quiver plot without redefining the original array by omit- ting points in the original array. On can use an addition of a scatter plot to add a red dot at the grid points. The result of these modifications is shown in Fig. 1(b). Q-plt.quiver (X[::3, ::3], Y[::3, ::3], Vx[::3, 1:3], Vy[::3, ::3], pivot='mid', label='$V_x$ = cos ($x$), $V_y$ = sin($y$)') plt.quiverkey (Q, 0.9, 0.9, 2, r'$2\frac{m} {s}$', labelpos='E', coordinates='figure') plt.scatter (X[::3, ::3], Y[::3, ::3], color='r', s=10) A detailed description of the quiver command can be found with the help command help (plt.quiver), or online. We begin this lab by developing some graphical tool to better visualise to solutions to dif- ferential equations. We begin with Quiver plots: A quiver plot is used to display a two di- mensional vector field. It is called in python with plt.quiver. This function requires four arguments, all of which must be arrays of the same size. The first two arguments define a grid of (x, y) points. The grid can be created using the meshgrid function in numpy: |X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, 2)) This creates a 2-dimensional grid of points in the range 0 to 2 in the x and y directions. The next arguments specify the components of a 2-dimensional vector, V(x, y) = (Vx(x, y), Vy(x, y)), at the corresponding grid points. Python will draw an arrow at each grid point to represent the vector field V(x, y). As an example; define the vector field, V(Vx, Vy), as: Vx = np.cos (X) Vy = np. sin (Y) Implement and run the following code illustrating how to make a quiver plot, as well as affect figure size, geometry and labelling: import matplotlib.pyplot as plt import numpy as np np.meshgrid(np. arange (0, 2 np.pi, .2), np.arange (0, 2* np.pi, .2)) plt.close() X, Y = Vx = np.cos(X) Vy np.sin(Y) = plt.figure (figsize=(6,6)) plt.gca ().set_aspect ('equal', adjustable='box') #Make plot box square plt.xlabel('x') plt.ylabel('y') plt.title('Example of a quiver plot') plt.quiver (X, Y, Vx, Vy, pivot='mid', label='$V_x$ plt.legend () plt.show() = cos ($x$), $V_y$ = sin ($y$)') 6 5 4 31 2 1 Example of a quiver plot | V₁ = cos(x), V, = sin(y) > 3 0- Quiver plot with reduced density V = cos(x), Vy= sin(y) 4 (a) (b) Figure 1: Examples of quiver plots for the vector field defined by (cos(x), sin(y)) for different grid densities and plot options The code should produce a plot as shown in Fig. 1(a) Note that at each gridpoint the arrow is proportional to the magnitude and direction of the vector V at that point. Vary the grid density and explain what you are observing: It is possible to add a legend for the arrow lengths on to the quiver plot as follows: Q-plt.quiver (X, Y, U, V, pivot='mid', label='$V_x$ = cos($x$), $V_y$ = sin($y$)') plt.quiverkey (Q, 0.9, 0.9, 2, r'$2\frac{m} {s}$', labelpos='E', coordinates='figure') One can produces a less dense quiver plot without redefining the original array by omit- ting points in the original array. On can use an addition of a scatter plot to add a red dot at the grid points. The result of these modifications is shown in Fig. 1(b). Q-plt.quiver (X[::3, ::3], Y[::3, ::3], Vx[::3, 1:3], Vy[::3, ::3], pivot='mid', label='$V_x$ = cos ($x$), $V_y$ = sin($y$)') plt.quiverkey (Q, 0.9, 0.9, 2, r'$2\frac{m} {s}$', labelpos='E', coordinates='figure') plt.scatter (X[::3, ::3], Y[::3, ::3], color='r', s=10) A detailed description of the quiver command can be found with the help command help (plt.quiver), or online.
Expert Answer:
Answer rating: 100% (QA)
To vary the grid density in the quiver plot and observe the differences you can adjust the slicing i... View the full answer
Related Book For
An Introduction to Statistical Methods and Data Analysis
ISBN: 978-1305269477
7th edition
Authors: R. Lyman Ott, Micheal T. Longnecker
Posted Date:
Students also viewed these programming questions
-
Define the N- dimensional characteristic function for a random vector, X = [X1, X2,..XN] T , according to X () = E[ejTX] where = [1, 2, N] T. Show that the - dimensional characteristic function for...
-
To plot y = sin(x), we must define vectors of x and y values and then use the plot command. This can be done as follows: x = 0:0.1:6.3; y = sin(x); plot(x, y) (a) Let us define a rotation matrix and...
-
NumPy package of Python can be used to calculate the mean measure. A) True B) False
-
Calculate the heat released as 35.5 g of copper (0.0920 cal/g x C) cools from 50.0 C to 25.0 C.
-
A CPA firm is engaged in the examination of the financial statements of Zeitlow Corporation for the year ended December 31, 2007. Zeitlow Corporations financial statements and records have never been...
-
Common stock issues in this market with average systematic risk are most likely to have required rates of return A. Between 2 percent and 7 percent. B. Between 7 and 9 percent. C. At 9 percent or...
-
A chemical reaction was run 48 times. In each run, different values were chosen for the temperature in degrees Celsius (x1), the concentration of the primary reactant (x2), and the number of hours...
-
During 2015, Walnut Company completed the following two transactions. The annual accounting period ends December 31. a. Paid and recorded wages of $130,000 during 2015; however, at the end of...
-
Anna and Makenzie formed an LLC called " A&M Company, LLC \" . Anna and Makenzie did not make any elections regarding the tax classification of the entity. Anna contributed equipment worth $ 1 0 0...
-
Assume the following data for Animal Transport Company REFERENCE REVENUE BUDGET Requirement Prepare a cash budget for April for Animal Transport. Begin the cash budget by calculating the cash...
-
Provide a detailed descriptions of: Diversity, Equity, and Inclusion. Cleary provide the positives and Negatives impacts of Diversity, Equity, and Inclusion. Highlights the relationships of...
-
2. Consider the following Industry Demand and Total Cost Curves for an industry characterized by monopoly: Total Cost 650,000 + 8Q Demand: P = 1,084,000 - 152Q a) What are the marginal cost, average...
-
These two compression utilities compress files and are similar in their functions and operations. The main difference is that compression than , but the latter is much more widely used offers...
-
Your firm has been appointed as company auditor for Bernard Berhad since year 2018. The audit fieldwork for financial year ended 31 December 2020 was completed on 31 March 2021. The audited financial...
-
Fluffy Towel Company manufactures two products, Mini A and Maxi B. Fluffy's overhead costs consist of setting up machines- $800,000; machining- $2,000,000; and inspecting- $600,000. Information on...
-
McCullough Hospital uses a job-order costing system to assign costs to its patients. Its direct materials include a variety of items such as pharmaceutical drugs, heart valves, artificial hips, and...
-
Which hot-held food is in the temperature danger zone? O Fish held at 126F (52C) O Beans held at 141F (61C) O Soup held at 154F (68C) O Steak held at 160F (71C)
-
Use the graphs of f and g to graph h(x) = (f + g) (x). To print an enlarged copy of the graph, go to MathGraphs.com. 1. 2. y 24 8. 2. -2 -2 4 6
-
Refer to Example 8.6. The political action group was interested in determining regional differences in the publics opinion concerning air pollution. Write a contrast in the four population means to...
-
Mason, Gunst, and Hess (2003) describe the following study. A traffic engineer designs a study to compare the total unused red- light times for five methods of traffic- light signaling (A, B, C, D,...
-
Refer to Exercise 11.65. a. Estimate the mean fuel usage for a 1000- mile flight. Provide a 95% confidence interval for your estimate. b. Predict the fuel usage for a particular 1000- mile flight....
-
Design a piston-cylinder-type viscous damper to achieve a damping constant of \(175 \mathrm{~N}-\mathrm{s} / \mathrm{m}\) using a fluid of viscosity \(35 \times 10^{-3} \mathrm{~N}-\mathrm{s} /...
-
Consider a system of two dampers, with damping constants \(c_{1}\) and \(c_{2}\), arranged in parallel as shown in Fig. 1.104. The rigid bar to which the two dampers are connected remains horizontal...
-
Design a shock absorber (piston-cylinder-type dashpot) to obtain a damping constant of \(1.8 \times 10^{7} \mathrm{~N}\)-s \(/ \mathrm{m}\) using SAE 30 oil at \(21^{\circ} \mathrm{C}\). The diameter...
Study smarter with the SolutionInn App