Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

======================================================================================================= Problem 3: Using matplotlib to create a graph Look at the code in the next two cells. It imports matplotlib and numpy in the

=======================================================================================================

Problem 3: Using matplotlib to create a graph

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.

Run the code in both cells to view the graph. Then follow the instructions in subsequent cells. If you have trouble importing the libraries or cannot otherwise run the code to generate the graphs, open the HW#1 Emergency notebook to view them. Then return to this one to answer the questions below.

import matplotlib.pyplot as plt import numpy as np

# Code to generate a graph of various functions using matplotlib and numpy

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()

Q1. copy and paste the graphing code from above, change the scale to 12, then rerun. What differences do you see in the generated functions compared with the first one whose scale only went to 10?

Q2. copy and paste the graphing code, change the scale to 20, then rerun. What differences do you see in the generated functions compared with the first two above?

Q3. copy and paste the graphing code, 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

tavtrhnnk- QY 1 - romnarienn nlnt of warinue arnuth functinne

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

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions