Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the math module to compute new values and matplotlib to plot them Now we want you to try to use various components of everything

image text in transcribed

image text in transcribed

Using the math module to compute new values and matplotlib to plot them Now we want you to try to use various components of everything you just learned in the video, and things you've learned in class up to this point, to make a new plot. This will require that you use the math module, the pyplot module, and probably loop (or two) Question 2: Using the values from the x1 list above, make a plot of /(x) = sin(x) using a green line and f(x) = cos(x) using an orange line. Label your plot so that the x-axis reads "x", and the y-axis reads"fx)" Hint: The first step will be to figure out a way to calculate the sine and cosine values of x1 and store them. You might want to review how the append function works for lists. Extra challenge: See if you can figure out how to use the label parameter in the pit.plot() function and the plt.legend() command to add a legend your plot that identifies each line appropriately | [ ]: # put your python commands here, make sure to include comments in your code using the "#" symbol x1 -[2,4,6,8,10,12,14,16,18] Question 3: Now that you've been able to plot some functions that look like sine and cosine, we want to make them look more like sine and cosine by calculating more data points for our curves. One way of doing this is to create a list of values that we will pass to the sine or cosine function. We created a list called x1 for you that you used for the plots you made above, but it didn't have enough values to make the curves look very smooth (we fired the person that made that list). Your goal is to create a list called x list of x-values from 0 to 2 you might want to use the math module for obtaining a value for with a spacing of 0.1 between each value. Then plot cosine and sine over this interval with the same axis labels and colors as the plot you made above. Hint: To create your list, consider using a while-loop, that stops once the increment has surpassed 2. The while-loop should append new values to x-list starting at 0 and adding 0.1, appending that to the list, then adding 0.1 to the previous value, appending that value to the list, and so on. We will see other methods of creating lists like this in the future by some other very helpful modules. (Please do not hard code the values of your list by hand. If you get stuck, just ask one of the instructors for help via Slack.) # put your python commands here, make sure to include comments in your code using the "#" symbol

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago