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:
- y(x) = x sin(x) + 3 cos(x) - x
- y(x) = x (sin(x) - x cos(x))/5
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started