Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Look at the code in the next two cells. It imports matplotlib and numpy in the first, then generates a plot of four different functions

Look at the code in the next two cells. It imports matplotlib and numpy in the first, then generates a plot of four different functions in the second. The scale of the plot is specified on the first line as 0 to 10 with 100 random points generated. The scale can be adjusted above 10 for a wider/larger scale, or less than 10 for a smaller scale.

import matplotlib.pyplot as plt import numpy as np n = np.linspace(0, 10, 100) # generate 100 sample points in range 1 to 10 - change the 10 to a different scale # Generate lines on the graph plt.plot(n, 8*n, label = '8n: linear') # graph a linear function plt.plot(n, 2*n**2, label = '2n**2: quadratic') # graph a quadratic function plt.plot(n, n**3, label = 'n**3: cubic') # graph a cubic function plt.plot(n, 2**n, label = '2**n: exponential') # graph an exponential function # Labels plt.title('textrbook: R3.1 - comparison plot of various growth functions') plt.legend() # Do it! plt.show()

image text in transcribed

1. What differences do you see in the generated functions compared with the first one whose scale only went to 10? (graph for scale 10)

image text in transcribed

2. change the scale to 20, then rerun. What differences do you see in the generated functions compared with the first two above?

image text in transcribed

3. change the scale to 3, then rerun. What differences do you see in the generated functions compared with the ones above?

image text in transcribed

tentrknnlon n T toythnok- R 1 - romnaricon nlnt of varinuc arnuth functinne aph showing smaller scale/lower volume texthnnk-R? 1 - romnaricon nlnt of varins aromth fnctinne textbook: R3.1 - comnarison vlot of various arowth functions

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions