Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi please help me fix my code. I get some errors. I want to print 3 separate graphs. One graph that prints the number of

Hi please help me fix my code. I get some errors. I want to print 3 separate graphs. One graph that prints the number of Susceptible individuals vs time, 2nd graph prints number of Infected individuals vs time, and 3rd graph prints number of Recovered individuals vs time.

import scipy.integrate import matplotlib.pyplot as plt import numpy as np

def f(t, y): gamma = .07 beta = .9 N = 10000 dsdt = -beta * y[0] * y[1] / N didt = beta * y[0] * y[1] / N - gamma * y[1] drdt = gamma * y[1] return [dsdt,didt,drdt]

t0 = 0 t_bound = 200 y0 = np.array([9000, 1000, 0]) sol = scipy.integrate.RK45(f, t0, y0, t_bound) t = [] y = [] while sol.status == "running": t.append(sol.t) y.append(sol.y) sol.step()

plt.plot(t,sol[:,0]) plt.plot(t,sol[:,1]) plt.plot(t,sol[:,2]) plt.legend(("Susceptible", "Infected", "Recovered")) plt.xlabel("time") plt.ylabel("cases") plt.show()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

1. Explain how technology has changed the learning environment.

Answered: 1 week ago