Write a function plot_comparison(t, x, xharmonic, ylabel) that takes as input t: a numpy array to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function plot_comparison(t, x, xharmonic, ylabel) that takes as input t: a numpy array to times; • x: a numpy array of observables for the non-linear pendulum. The parameter x can be set to either an array of angles or angular velocities; • xharmonic: a numpy array of observables for the harmonic pendulum (see x) • ylabel: a string that is used to label the y-axis, should be either "theta" or "Omega", depending on what was chosen for x and xharmonic. It should plot the non-linear and the harmonic timeseries in the same axes, • create legends "non-linear" and "harmonic" for the graphs, add the label "time" to the x-axis, add the ylabel to the y-axis. As an example, it should be possible to generate the example plot below with the commands plt.subplot (2, 1, 1) plot_comparison (t, theta, theta_h, "theta") plt.subplot (2, 1, 2) plot_comparison (t, Omega, Omega_h, "Omega") plt.legend (loc="best") plt.suptitle (r"pendulum with $\theta_0=\pi/4$") plt.figsave ("pendulum-comparison.png") where the array t contained the times, theta and theta_h the angles, Omega and Omega_h the angular velocities. pendulum with 0o = 1/4 ww 15 theta 0.5- 0.0 -0.5- 0.5- 10 25 30 non-linear #MMA # harmonic 10 0.0- -0.5 0 5 ś 20 15 time 20 25 Exploration The template code will generate a single figure for 00 = 0.997. The tests will test your functions with various parameters. You should run your code outside the zyLab in a Jupyter notebook and generate plots for different initial angles 00 = {0.1, 0.5, 0.9, 0.99}. Try to answer the following questions for yourself: • Do you see a difference between non-linear and harmonic (linear) for small angles 0 ≤ 0.1? • Is the non-linearity increasing or decreasing the period of the oscillations? • How do the non-linear trajectories for large angles differ from the ones for small angles? At which angles is the difference the most apparent and why? (Also look at the velocity: Why is the velocity very small at large angles?) • What happens the closer you get to it? What situation is described by 0 = π? • Hypothetical question: What could happen if we allowed initial angular velocities >0? • How does energy conservation prevent the pendulum from going over the top with the parameters that we have been exploring? Write a function plot_comparison(t, x, xharmonic, ylabel) that takes as input t: a numpy array to times; • x: a numpy array of observables for the non-linear pendulum. The parameter x can be set to either an array of angles or angular velocities; • xharmonic: a numpy array of observables for the harmonic pendulum (see x) • ylabel: a string that is used to label the y-axis, should be either "theta" or "Omega", depending on what was chosen for x and xharmonic. It should plot the non-linear and the harmonic timeseries in the same axes, • create legends "non-linear" and "harmonic" for the graphs, add the label "time" to the x-axis, add the ylabel to the y-axis. As an example, it should be possible to generate the example plot below with the commands plt.subplot (2, 1, 1) plot_comparison (t, theta, theta_h, "theta") plt.subplot (2, 1, 2) plot_comparison (t, Omega, Omega_h, "Omega") plt.legend (loc="best") plt.suptitle (r"pendulum with $\theta_0=\pi/4$") plt.figsave ("pendulum-comparison.png") where the array t contained the times, theta and theta_h the angles, Omega and Omega_h the angular velocities. pendulum with 0o = 1/4 ww 15 theta 0.5- 0.0 -0.5- 0.5- 10 25 30 non-linear #MMA # harmonic 10 0.0- -0.5 0 5 ś 20 15 time 20 25 Exploration The template code will generate a single figure for 00 = 0.997. The tests will test your functions with various parameters. You should run your code outside the zyLab in a Jupyter notebook and generate plots for different initial angles 00 = {0.1, 0.5, 0.9, 0.99}. Try to answer the following questions for yourself: • Do you see a difference between non-linear and harmonic (linear) for small angles 0 ≤ 0.1? • Is the non-linearity increasing or decreasing the period of the oscillations? • How do the non-linear trajectories for large angles differ from the ones for small angles? At which angles is the difference the most apparent and why? (Also look at the velocity: Why is the velocity very small at large angles?) • What happens the closer you get to it? What situation is described by 0 = π? • Hypothetical question: What could happen if we allowed initial angular velocities >0? • How does energy conservation prevent the pendulum from going over the top with the parameters that we have been exploring?
Expert Answer:
Answer rating: 100% (QA)
Answer import matplotlibpyplot as plt import numpy as np De... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Billingsly Products uses the conventional retail method to estimate its ending inventories. The following data has been summarized for the year 2024: Inventory, January 1 Purchases Net markups =6 Net...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
An electron moves through a uniform magnetic field given by B = Bxi+(2.12 B). At a particular instant, the electron has velocity (1.891+4.70) m/s and the magnetic force acting on it is (3.82 x 10-1)...
-
To build each unit of a certain product Z , a firm needs one unit of component W and two units of component Y . Each unit of Yin turn requires one unit of component X and three units of W . Finally,...
-
Figure 34.57 shows an object and its image formed by a thin lens.(a) What is the focal length of the lens, and what type of lens (converging or diverging) is it?(b) What is the height of the image?...
-
The region of experimentation for two factors are temperature (100 T 300F) and catalyst feed rate (10 C 30 lb/in). A first-order model in the usual 1 coded variables has been fit to a molecular...
-
Jessica Pothier opened FunFlatables on June 1, 2010. The company rents out moon walks and inflatable slides for parties and corporate events. The company also has obtained the use of an abandoned ice...
-
Townsend Industries Inc. manufactures recreational vehicles. Townsend uses a job order cost system. The time tickets from November jobs are summarized as follows: Job...
-
TranscribedText: Problem 2. [25pts] For each of the following vector fields F find the curl. 1. (5pts) F : R3 -> R3 such that F I2 = I3 2TIT213 V X F(x) = 2. (5pts) F : R3 -> R3 such that F I2 = T2 +...
-
Darden Restaurants, Inc. (DRI) is the largest full-service restaurant company in the world. It operates over 2,200 restaurants under a variety of brand names, including Olive Garden, Bahama Breeze,...
-
given by The three components of velocity in a flow field are u = x + y + z v = xy + yz + z W = -3xz - 2/2 + 4 (a) Determine the volumetric dilatation rate and interpret the re- sults. (b) Determine...
-
Valuation simplifies considerably if we drop the notion of intrinsic price and try to establish only relative pricing valuations.' Explain why intrinsic valuation is so difficult?
-
While high dividends are preferred by investors, this is not necessarily a good thing. Explain the situation what is the high dividends should not be considered?
-
If Raymond has an investment offer to invest a lump sum of money now and then receive $3,500 every 6 months. What is such investment has to be made now if interest is 8% compounded quarterly and the...
-
Describe thegreatest module you have learned in this class so far.Why is this the greatest module you have learned?What makes this so compelling?How have you built on this as the course has...
-
Bill Jones, age 30, is currently earning $55,000 per year net of tax. For estate planning purposes, he wants to ensure that his family maintains this level of income until his expected retirement at...
-
An activity-system map is which of the following? Multiple Choice A diagram that shows how a company's strategy is delivered to customers A listing of activities that make up a project A network...
-
Do public and private companies follow the same set of accounting rules? Explain.
-
Upper motor neuron disorder patients can benefit and regain useful function through the use of functional neuro prostheses. The design requires a good understanding of muscle dynamics. In an...
-
A simplified second-order transfer function model for bicycle dynamics is given by The input is (s), the steering angle, and the output is (s), the tilt angle (between the floor and the bicycle...
-
Given the unity feedback system of Figure P6.3 with a. Find the range of K for stability. b. Find the frequency of oscillation when the system is marginally stable. Ks(s + 2) (s2 4s + 8)(s + 3) G(s)...
-
A gene is a segment of DNA that contains the information to produce a functional product. The functional product of most genes is a. DNA. b. mRNA. c. a polypeptide. d. none of the above.
-
Which of the following is not a constituent of a cells proteome? a. An enzyme b. A cytoskeletal protein c. A transport protein in the plasma membrane d. An mRNA
-
The function of the genetic code is to a. promote transcription. b. specify the amino acids within a polypeptide. c. alter the sequence of DNA. d. do none of the above.
Study smarter with the SolutionInn App