Download (right-click, save target as ...) this page as a jupyterlab notebook from: Lab6-HW
LAST NAME, FIRST NAME
R00000000
ENGR 1330 ES6 - Homework
# Preamble script block to identify host, user, and kernel
import sys
! hostname
! whoami
print(sys.executable)
print(sys.version)
print(sys.version_info)
Make a function that cubes its input:
$$ f(x) = x^3 $$and test it for the following values of x:
Generate two lists:
x
ranging from 0 to 9 in steps of 1f(x)
from your function in Exercise 1Use the plotAline()
function (below) to create a plot of
for x raging from 0 to 9 (inclusive) in steps of 1.
Label the plot and the plot axes.
A wrapper script is included below that needs completion to work and draw the plot.
def plotAline(list1,list2,strx,stry,strtitle): # plot list1 on x, list2 on y, xlabel, ylabel, title
import matplotlib.pyplot # import the plotting library from matplotlib.pyplot
matplotlib.pyplot.plot( list1, list2, color ='green', marker ='o', linestyle ='solid') # create a line chart, years on x-axis, gdp on y-axis
matplotlib.pyplot.title(strtitle)# add a title
matplotlib.pyplot.ylabel(stry)# add a label to the x and y-axes
matplotlib.pyplot.xlabel(strx)
matplotlib.pyplot.show() # display the plot
return #null return
# wrapper script
x = [] # define two lists
y = []
# populate x and y for plotting
# ...
# ...
# then plot
plotAline(x,y,"x"," x^3","Plot of y=x^3")
Modify the wrapper script above to create a plot of the parametric functions x(t) and y(t)
$$ x(t) = 16sin^3(t) $$$$ y(t) = 13cos(t) - 5cos(2t) - 2cos(3t) - cos(4t) $$for t raging from [0,2$\Pi$] (inclusive).
Label the plot and the plot axes.