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

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 x 1 list above, make a plot of f(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 "f(x)". 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 plt.plot() function and the plt.legend) command to add a legend your plot that identifies each line appropriately. In [ 1: put your python commands here, make sure to include comments in your code using the " sy 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 r) 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.) In [ ]: # put your python commands here , make sure to Include comments in your code using the "#

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

Design an internal skills transfer system through tutoring.

Answered: 1 week ago

Question

LO4 List options for development needs analyses.

Answered: 1 week ago