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 python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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