Question: Task 1: Write a script a6task1.py in which you export a function: def runTask1(): This function must create a figure that draws the following three

Task 1:

Write a script a6task1.py in which you export a function:

def runTask1():

This function must create a figure that draws the following three functions:

  1. y(x) = x sin(x) + 3 cos(x) - x
  2. y(x) = x (sin(x) - x cos(x))/5
  3. y(x) = (x3 - 2x2 + 5x - 25)/40

The curves must span a domain of x values from -6 to 6 and are to be generated from arrays of at least 150 points each. Draw curve 1 as a black line, curve 2 as a blue line and curve 3 as a red line. Label the x axis "x" and the y axis "y(x)". There is to be no title for the figure. The figure is to display a background grid. Resize the figure by including the following lines in your code:

from pylab import rcParams rcParams["figure.figsize"] = 6, 4

Note: you may need to run your script twice before this resizing takes effect.

The figure is to have a legend identifying the three curves by their formulae (given above). This legend is to be placed outside and to the right of the box of the figure. Vertically, the legend should be midway between top and bottom of the graph.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!