Calculate x and y using the same initial conditions

Assignment Help Python Programming
Reference no: EM132394127

Assignment

1 Question

The H ´enon map is a pair of equations given by

xn+1 = 1 - ax2n + yn      (1)
yn+1 = bxn                   (2)

These equations can display some interesting behavior when its results are looked at. First, create a function called Henon, which will take 5 input parameters: the initial x and y, the parameters a and b, and the number of iterations n. Inside this function you will iterate the equations the given number of times, and store the results in separate lists. (One for the x values, and one for the y values. Remember to update your values as you go!) It will return both of these lists after its done. Show this code, and show the output lists for x = 1.0, y = 0.25, a = b = 0.25 after 5 iterations.

(Hint: you should get the same values for x and y the whole time.)

2 Question

Use your Henon function to calculate the outputs for x and y after 25 iterations for the values a = b = 0.5, and initial x = 0, y = 1. Use matplotlib to create 2 subplots, with 2 rows and 1 column. The top plot should be a blue line for your x values, and the bottom should be a red line for your y values. Show the code to run the Henon function and create this plot, and the plot itself.

3 Question

Now we can see what happens when we start bouncing between several different values. Use your Henon function again to calculate the outputs for x and y after 100 iterations for the values a = 1.4 and b = 0.3. Your initial conditions should be x = 0.7, and y = 0. Use matplotlib to create 2 subplots, with 2 rows and 1 column same as before. Again, the top plot should be a blue line for your x values, and the bottom should be a red line for your y values. Show the code to run the Henon function and create this plot, and the plot itself.

4 Question

While the previous plots are interesting in that you can see similar bouncing for x and y, but things get really interesting when you plot both of them together. Calculate x and y using the same initial conditions and parameters you did for the previous question, but this time run it for 500 iterations. To plot the data, use a scatter plot. You should also label the x and y axis as ‘x' and ‘y', and title the plot as ‘Henon Data'. Show the code for this plot and the plot itself.

5 Question

The Lotka-Volterra equations, also known as the predator-prey equations, are a pair of equations that describe how a population of predators and a population of prey interact. They can be written as

x(t + 1) = x(t) + [a x(t) - b x(t)y(t)]Δt            (3)

y(t + 1) = y(t) - [c y(t) - d x(t)y(t)]Δt            (4)

where x is the prey, and y is the predator. Create and show your code for a Populations function. This function will take 7 parameters as input: x, y, the parameters a, b, c, d, and the number of iterations n.

You'll set δt inside the function as 0.2. Similar to our previous function, it will calculate the two above equations and return both the x and y results as a list from the calculation. Show this code.

6 Question

After creating your function, you should test it to see that it works. To do so, run the function with the following parameters: a = c = 0.1, b = d = 0. Start with 50 predators and 50 prey, and show the where the populations end up after 100 iterations. (Only show the last elements of the lists, not the lists themselves!)

Check that you get 362.23 for the population of the prey, and 6.63 for the population of the predator. If you don't, go back and look at your function again.

7 Question

Now we can see what happens when the two populations interact. Run your function again, this time with the parameters a = 0.02, b = 0.0005, c = 0.05, and d = 0.0005. Start with 50 prey and 25 predators, and run your simulation for 4000 iterations. Show a plot of the two populations individually with both of them on the same plot. Label the x axis as ‘Iterations' and the y axis as ‘Population Size'. Title it as ‘Predator-Prey Model'. Show the code to generate this plot, and the resulting plot.

8 Question

We can make a population go extinct if we have the correct parameters. Run your function for a third time, this time with the parameters a = 0.01, b = 0.01, c = 0.2, and d = 0.02. Start with 50 prey and 25 predators again, and run your simulation for 200 iterations. Same as before, show a plot of the two populations with both of them on the same plot. Label the x axis as ‘Iterations' and the y axis as ‘Population Size'. Title it as ‘Population Extinction'. Show the code to generate this plot, and the resulting plot.

Reference no: EM132394127

Questions Cloud

Implications of having fiber-optic cable to everyone home : What are the implications of having fiber-optic cable to everyone's home? How do you feel about the net neutrality issue?
Compute the value of the test statistic : Compute the value of the test statistic. (Round your answer to 2 decimal places)
Find the probability that a single randomly selected : A population of values has a normal distribution with µ=247 and s= 62.2. You intend to draw a random sample of size n=16.
Probability that you will succeed in completing a flush : Calculate the probability that you will succeed in completing a "flush".
Calculate x and y using the same initial conditions : Calculate x and y using the same initial conditions and parameters you did for the previous question, but this time run it for 500 iterations.
Which depositor creates donuts with a more consistent weight : Which depositor creates donuts with a more consistent weight? Explain your answer using a complete sentence.
Find the percentage and the probability : A psychologist has devised a stress test for dental patients sitting in the waiting rooms. According to this test, the stress scores (on a scale of 1 to 10)
What financial challenges healthcare leaders would face : What are some of the financial challenges healthcare leaders and managers would face considering today's factors? Consider real-life internal and external.
IT Security govern information technology : Although it is not classified as being such, does not IT Security govern information technology within an organization?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a modularized body mass index program

Write a modularized Body Mass Index (BMI) Program which will calculate the BMI of a team player. The formula to calculate the BMI is as follows: BMI = Weight *703 / Height^2.

  Compare programming with python and programming with scratch

Compare programming with python and programming with scratch. Describe the same program you might create in both programming languages.

  Describes the behaviour of the vending machine system

Assignment – Vending Machine - Foundations of Programming - creating a text-based program for simulating a Vending Machineusing the Python programming language

  Write a python program that prompts for an integer

Write a Python program that prompts for an integer-let's call it X-and then ands the sum of X consecutive integers starting at 1.

  Write program to gather-display results of golf tournament

Write a program to gather, then display the results of the golf tournament played at the end of March. The Club president Mr. Martin has asked you

  Application that will allow user to maintain collections

Build a menu-driven application that will allow a user to maintain their collections. For example, I might have a coin collection, or a record collection, or a collection of all my valuable items.

  Find the distance using any of the pair of co-ordinates

What do you do for example if you want to find the distance using any of the pair of co-ordinates using the formulae L=sqrt.

  Find the time when the concentration will return back

Suppose a reactor normally contains 12 units of dissolved oxygen in a fixed volume of water. Suppose at t=0(min) a quantity of organic waste is introduced.

  What do we do to keep the compiler from confusing a float

What is the shortest form of sum = sum + 1; or sum += 1; where 1 is always the increment value? What do we do to keep the compiler from confusing a float.

  Write python program that assigns values to three variables

Write the Python program that assigns values to three variables (x, y and z), and then displays the data types of these three values.

  Implement a program in python that given names of students

Implement a program in Python that, given 500 names of students and 500 integers in the range (0,100) representing the scores of these 500 students, calculates

  Provide a screenshot of your program that contains cyclist

Provide a screenshot of your program that contains at least two cyclist entries that you added to the list. P.rovide the code from your .pyw file that you used

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd