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:
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/64faf3d7a09bd_1694168022756.jpg)
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/64faf3e6bf888_1694168038928.jpg)
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/64faf3f779849_1694168055552.jpg)
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/64faf409376a9_1694168073323.jpg)
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,...
-
Suppose a competitive industry faces an increase in demand (i.e., the demand curve shifts upward). What are the steps by which a competitive market insures increased output? Will your answer change...
-
Investigate commercial uses of GPS. Start with www.neigps.com . Can some of the consumer-oriented products be used in industry? Prepare a report on your findings.
-
3. Suppose the firm issues a single zero-coupon bond with time to maturity 3 years and maturity value $110. a. Compute the price, yield to maturity, default probability, and expected recovery (E[BT...
-
Discuss some of the basic features of an ERP. How do these features distinguish an ERP from an integrated accounting software program?
-
6-34 6-34 (OBJECTIVE 6-10) The following (1 through 16) are the balance-related and transaction- related audit objectives. Balance-Related Audit Objectives Transaction-Related Audit Objectives 1....
-
You have been asked by management to explain the variances in costs under your inpatient capitates contract. The following data is provided. Requirements: 1: What dollar amount of the total variance...
-
Your friend Harold is trying to decide whether to buy or lease his next vehicle. He has gathered information about each option but is not sure how to compare the alternatives. Purchasing a new...
-
The amounts of caffeine in a sample of five-ounce servings of brewed coffee are shown in the histogram. Number of 5-ounce servings S 25- 20 15 10 25 12 10 1 2 70.5 92.5 114.5 136.5 158.5 Caffeine (in...
-
Tom, David, Dale, and Murdock are four business students who want to rent a four- bedroom apartment together for the fall semester. They have identified the three factors important to them in...
-
Listed below, out of order, are the steps in an accounting cycle. 1. Prepare the unadjusted trial balance. 2. Post journal entries to general ledger accounts. 3. Analyze transactions from source...
-
Consider Quick Start QFD Matrix 2 above. Which two technical specifications are strongly correlated with each other? Quick Start QFD Matrix 2 Strong positive correlation Some positive correlation ==...
-
A cylindrical solenoid of length \(\ell\) and radius \(R\) has \(n\) windings per unit length and carries a current \(I\). (a) Use the inductance expression \(L=\left(\mu_{0} N^{2} A ight) / \ell\)...
-
https:/ewconnect.mhe... - AC H HelloJetBlue REQUIRY: Homework Cha... X QUIRED: Homework Chapter 30 Saved Help Save & Exit Submit Below are the restated amounts of net income and retained earnings for...
-
The following information is available for Partin Company: Sales $598,000 Sales Returns and Allowances 20,000 Cost of Goods Sold 398,000 Selling Expense 69,000 Administrative Expense 25,000 Interest...
-
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)...
-
Unincorporated joint operation managed by one of the operators LO4 During 2018, discussions took place between Broken Bay Ltd, a company concerned with the design of specialised tools and...
-
ACCOUNTING FOR AN ASSET USED BY A NUMBER OF COMPANIES Raby Ltd and Bay Ltd are companies that have newly discovered oil wells in a MiddleEastern country. There is some distance to the nearest port...
-
Contribution of plant LO3, 4 On 1 July 2019, Tully Ltd and Cooktown Ltd signed a contractual agreement to form a joint operation for the manufacture of kitchen products. The agreement provided that...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App