Question

In: Computer Science

USE PYTHON TO SOLVE THIS PROBLEM A bacteria culture grows exponentially. After 2 hours, the bacteria...

USE PYTHON TO SOLVE THIS PROBLEM

A bacteria culture grows exponentially. After 2 hours, the bacteria count was 400 cells and after 6 hours, the bacteria count was 20,000 cells.

a) Solve a system of equations to find (approximately) k and y0 (HINT: If will help to assume K is real in the symbols command)

b) Use this to determine when the bacteria count reaches 2,000,000 (exact and approximate).

c) Suppose 400 was the “initial” amount and 20,000 the count after 4 hours. Find k and the approximate amount of bacteria 2 hour BEFORE the “initial” time. In a print statement, explain what you notice when comparing these answers to part a)

Solutions

Expert Solution

Here's the Python Code for the same:

import numpy as np
from scipy.optimize import fsolve

# bacterial growth eqn is of the form y0 * (e^(k * t)) = n

t1, n1, t2, n2 = 0, 0, 0, 0

# f(x) returns the functions for using in fsolve
def f(x):
    y0 = x[0]
    k = x[1]

    f1 =  y0 * np.exp(k * t1) - n1
    f2 = y0 * np.exp(k * t2) - n2

    return np.array([f1, f2])

# function to find t for given n, y0 & k
def findT(n, y0, k):
    return (np.log(n / y0) / k)

# function to find n for given t, y0 & k
def findN(t, y0, k):
    return (y0 * np.exp(k * t))

# driver code
if __name__ == '__main__':

    # for part a)
    t1, n1, t2, n2 = 2, 400, 6, 20000
    # guessed solution
    xGuess = np.array([1, 2])
    # calculating actual soln using xGuess
    sol = fsolve(f, xGuess)
    print("Part a)\ny0 = {}, k = {}\n".format(sol[0], sol[1]))

    # for part b)
    # finding time for bacteria count to reach 2 mn using above sol
    t = findT(2000000, sol[0], sol[1])
    print("Part b)\nTime required =", t, "hours\n")

    # for part c)
    # setting the given values
    t1, n1, t2, n2 = 0, 400, 4, 20000
    xGuess = np.array([1, 2])
    # solving the equations for new y0 & k using xGuess
    sol = fsolve(f, xGuess)
    # finding n for newly gotten y0 & k
    n = findN(-2, sol[0], sol[1])
    print("Part c)\nBacteria count 2 hours prior initial = ", n)
    print("For comparison to Part a)\ny0 = {}, k = {}".format(sol[0], sol[1]))

Code Screenshot (for indentation lookup in case any issue while running the pgm):

Output Screenshot:

Added comments in the code for better understanding, do refer them. Also, for any doubt, feel free to reach back.

Hope it helps, consider hitting a like if it did :)

Cheers!


Related Solutions

USE PYTHON TO SOLVE THIS PROBLEM A bacteria culture grows exponentially. After 2 hours, the bacteria...
USE PYTHON TO SOLVE THIS PROBLEM A bacteria culture grows exponentially. After 2 hours, the bacteria count was 400 cells and after 6 hours, the bacteria count was 10,000 cells. a) Solve a system of equations to find (approximately) k and y0 (HINT: If will help to assume K is real in the symbols command) b) Use this to determine when the bacteria count reaches 1,000,000 (exact and approximate). c) Suppose 400 was the “initial” amount and 10,000 the count...
(1 point) A bacteria culture starts with 560 bacteria and grows at a rate proportional to...
(1 point) A bacteria culture starts with 560 bacteria and grows at a rate proportional to its size. After 3 hours there will be 1680 bacteria. (a) Express the population after t hours as a function of t population:  (function of t) (b) What will be the population after 2 hours? (c) How long will it take for the population to reach 1250 ?
The population of bacteria​ (in millions) in a certain culture x hours after an experimental nutrient...
The population of bacteria​ (in millions) in a certain culture x hours after an experimental nutrient is introduced into the culture is ​P(x)=25x/6+x^2. Use the differential to approximate the changes in population for the following changes in x.a. 2 to 2.5                                                                                                                                b. 3 to 3.25
The initial size of a culture of bacteria is 1500. After one hour the bacteria count...
The initial size of a culture of bacteria is 1500. After one hour the bacteria count is 6000. A.) Find a function n(t) = n0ert that models the population after t hours (round your r value to five decimal places.) n(t)= B.) Find the population after 1.5 hours. (round answer to nearest whole number.) n(1.5)= C.) After how many hours will the number of bacteria reach 10,000? (round your answer to one decimal place.)
The number of bacteria after ? hours in a controlled laboratory experiment is ? = ?(?)....
The number of bacteria after ? hours in a controlled laboratory experiment is ? = ?(?). a. Describe the meaning of ?′(4) and include right units. b. If the supply of nutrients is limited, which value do you think is larger ?′(4) or ?′(15)?
The population of a culture of bacteria is calculated and recorded after each hour, for a...
The population of a culture of bacteria is calculated and recorded after each hour, for a six-hour period. 0 98 1 206 2 405 3 783 4 1550 5 2520 6 5630 Sketch a graph to illustrate these data. Compare linear, quadratic, and exponential regression models. List the equations and correlation coefficients for each type of function. Provide a graph and include the regression lines. Use each model to determine the initial number of bacteria at the beginning of the...
(1 point) The count in a bacteria culture was 200 after 15 minutes and 557 after...
(1 point) The count in a bacteria culture was 200 after 15 minutes and 557 after 25 minutes. Assume the growth can be modelled exponentially by a function of the form Q(t)=A e rt Q(t)=Aert , where t t is in minutes. (a) Find the relative growth rate, with at least the first 5 digits after the decimal point entered correctly: r= r= equation editor Equation Editor (b) What was the initial size of the culture? Round your answer to...
(1 point) The count in a bacteria culture was 600 after 10 minutes and 11613 after...
(1 point) The count in a bacteria culture was 600 after 10 minutes and 11613 after 20 minutes. Assume the growth can be modelled exponentially by a function of the form Q(t)=AertQ(t)=Aert, where tt is in minutes. (a) Find the relative growth rate, with at least the first 5 digits after the decimal point entered correctly: r=r= equation editor Equation Editor (b) What was the initial size of the culture? Round your answer to the closest integer. equation editor Equation...
point) The count in a bacteria culture was 500 after 10 minutes and 32518 after 30...
point) The count in a bacteria culture was 500 after 10 minutes and 32518 after 30 minutes. Assume the growth can be modelled exponentially by a function of the form Q(t)=A e rt Q(t)=Aert , where t t is in minutes. (a) Find the relative growth rate, with at least the first 5 digits after the decimal point entered correctly: r= r= equation editor Equation Editor (b) What was the initial size of the culture? Round your answer to the...
The count in a bacteria culture was 800 after 20 minutes and 1100 after 30 minutes....
The count in a bacteria culture was 800 after 20 minutes and 1100 after 30 minutes. Assuming the count grows exponentially, What was the initial size of the culture? Find the doubling period. Find the population after 70 minutes. When will the population reach 10000. You may enter the exact value or round to 2 decimal places.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT