Question: Please write the code in PYTHON and show the full code. Thanks! In this exercise we will compare numpys computing time to make an array
Please write the code in PYTHON and show the full code. Thanks! In this exercise we will compare numpys computing time to make an array (list) to Pythons computing time using list comprehension whilst plotting some function. Show two plots next to each other.
a) On the left use numpys linspace function to set up the x-ticks. Plot f(x) = e^( x ) cos(20x) from x = 6 to x = 2 The title should contain the number of points N that was used to make the plot and do this for N [10, 50, 500, 1500, 5000, 15000]. Depict the graphs for each N under each other, going up in N.
b) On the right use list comprehension to set up the x-ticks. Plot g(x) = e^( x ) cos(20x) from x = 6 to x = 2 (notice the sign change in the exponential) The title should contain the number of points N that was used to make the plot and do this for N [10, 50, 500, 1500, 5000, 15000]. Depict the graphs for each N under each other, going up in N.
b) Below the 12 figures, graphically depict how much time it took for each method to produce the array or list described above. This plot should have the y-label computation time, the x-label points. Add an appropriate title and a legend.
c) Plot f(x) and g(x) in red, the computation time in green for numpy and use blue for the list comprehension method.
d) Mark the point where one method becomes faster than the other with an arrow with accompanying text.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
