Question
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()
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)
2. change the scale to 20, then rerun. What differences do you see in the generated functions compared with the first two above?
3. change the scale to 3, then rerun. What differences do you see in the generated functions compared with the ones above?
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 functionsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started