Write a function plot_comparison(t, x, xharmonic, ylabel) that takes as input t: a numpy array to...
Fantastic news! We've located 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 nonlinear 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 yaxis, should be either "theta" or "Omega", depending on what was chosen for x and xharmonic. It should plot the nonlinear and the harmonic timeseries in the same axes, • create legends "nonlinear" and "harmonic" for the graphs, add the label "time" to the xaxis, add the ylabel to the yaxis. 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 ("pendulumcomparison.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 nonlinear #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 nonlinear and harmonic (linear) for small angles 0 ≤ 0.1? • Is the nonlinearity increasing or decreasing the period of the oscillations? • How do the nonlinear 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 matplotlib pyplot as plt import numpy as np Define View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions

This assignment reviews objectoriented 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 101)...

A chilled water cooling coil receives 2.5 m3/s of air at 25 C db, 20 C wb. It is necessary for the air to leave the coil at 13 C db, 12 C wb. Assume sea level pressure. (a) Determine the SHF and the...

CollegePak Company produced and sold 60,000 backpacks during the year just ended at an average price of $20 per unit. Variable manufacturing costs were $8 per unit, and variable marketing costs were...

a. If all else stayed the same, but the labor force participation rate declined, what would happen to the unemployment rate? b. What is the Goldilocks scenario with regard to economic conditions?

At what point is final payment made to the contractor?

Congratulations! You have just won the State Lottery. The lottery prize was advertised as an annuitized $105 million paid out in 30 equal annual payments beginning immediately. The annual payment is...

What are two things arithmetic (uniform) gradient series have in common with geometric gradient series?

The trial balance of Pacilio Security Services Inc. as of January 1, 2020, had the following normal balances: Cash ..................$122,475 Petty cash ................ 100 Accounts receivable...

Here is the ledger for Sunland Company. Oct. 6 Oct. 1 8,200 Oct. 4 Oct. 10 2,180 Oct. 12 Oct. 10 9,200 Oct. 15 Oct. 20 880 Oct. 30 Oct. 25 3,200 Oct. 31, Accounts Receivable Oct.4 Cash Oct. 20 1,100...

Does the case of Mt. St. Helens invalidate the theory of communitysuccession? Explain.

In Problems 916, find the indicated firstorder partial derivative for each function z = f(x, y). fy(x, y) if f(x, y) = x 3xy + 2y 

What are some of the major environmental impacts of animals? Are their impacts similar, or different to those made by humans? Explain. What factors make soil a key determinant in the principal...

If there was a poleward or equatorward shift in a biome, what event(s) could possibly have initiated such a geographic change? What landscape features can also induce a biome to shift location?

Pentane is a liquid with a vapor pressure of 512 Torr at 25C; at the same temperature, the vapor pressure of hexane is only 151 Torr. What composition must the liquid phase have if the gasphase...

Below attached is the microstructure of the sample after cold working and after recrystallization. Identify from C10200, C11000, C17200, C21000, C26000, C36000, C46400. The alloys differ in color...

x/2 x/4 If A = x/2 and A1 =6 then x equals

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 secondorder 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)...

Pass necessary journal entries in the journal for the following transactions: Date April 1 April 2 April 3 April 6 April 7 April 8 April 9 April 10 April 11 April 15 April 18 April 22 April 26 April...

Pass necessary journal entries in the journal for the following transactions: Date 2010 Transaction Deepak started business with cash 4,50,000 and machinery worth * 3,50,000 Deposited cash into bank...

Capital structure of a company includes the following: (i) Equity share capital: 60,000 shares of face value 100 each (ii) Preference shares capital: 10,000, 10% shares of face value 100 each (iii)...
Question Categories