Menu

[Solved]Activity 1 Plotting Curves Derivatives Done Team Team Develop Program Ask User Polynomial Q37212263

Activity #1: Plotting Curves and Derivatives – to be done as ateam As a team, you are to develop a program that will ask a userfor a polynomial (of arbitrary degree) and then will generate aplot of the curve, its derivative curve, and its second derivativecurve. All three should be plotted on the same axes so that it iseasy to see how the first and second derivatives affect the shapeof the curve. You are also to highlight local maxima and minima bydrawing points on the plots showing where these occur. You may usecode developed in prior weeks if it is helpful (but it willprobably be as easy, at this point, to write new code). • The usershould be able to enter the polynomial as a set of coefficients.You will need to be sure to clearly tell the user the format toenter these coefficients in. • You should determine the derivativesanalytically. That is, if you have a list of the coefficients ofthe original polynomial, you should be able to generate the firstand second derivatives exactly. • The plots can be over apredetermined range of x and y values, but should be sufficientlylarge that someone entering a polynomial would easily be able togenerate polynomials passing through the area covered by the plots.Your plots can be generated by sampling many points on the curvesand plotting a line connecting those points. • You should identifythe local maxima and minima in the range you are plotting. You cando this by looking through the points generated for your plot, andfinding ones that are local maxima (a point is greater than thosejust before and after) and local minima (a point is smaller thanthose just before and after). These points should be plotted on topof the plots of the curves. • Your plots for the three curves andthe maxima/minima should be sufficiently varied (in color/shape)that it is easy to distinguish one from another. Follow thefollowing process: Complete parts a and b before writing any code!a) First, you will practice generating a bottom-up design: a. As ateam, brainstorm what functionality you are likely to need in thisprogram. For each basic task your team comes up with, where all thepieces needed are already known, write down a short functiondescription, along with any input arguments needed, and what returnvalue there will be, if any (i.e. construct a document, which willalso be used for the subsequent design descriptions). b. Only dothis for basic functions for which the steps you will need tofollow are wellknown or obvious. You can consider functions thatwill call other functions, as long as you have first designed theother function. c. Your goal in this part is not to generate acomplete code design, but rather to identify functions to implementthat are likely to be helpful in your program. b) Next, create atop-down design of the program. a. Put together a document (can beadded to the one from part (a) ) outlining the topdown design thatyour team comes up with. b. You should make use of the functionscreated in the bottom-up “phase”, above, to whatever extent seemshelpful. c) Next, code up your solution. a. You should createseparate functions for each of the “nodes” in the top-downhierarchy that you created. b. You should also create separatefunctions for the features you identified in the bottomup phase(a), above. c. Note that you might want to split up the codingresponsibilities for the different functions among different teammembers. If you did a good job with design, the individualfunctions should be able to be coded up independently of oneanother. d. As a team, you will need to decide what variables youwill use in the main program e. Be sure to include docstrings forall the functions you create.

Activity #2: Integrating a function – to be done as a team Thisactivity is meant to familiarize you with the process ofintegration by computing area under a curve. As you may havelearned by now in calculus, to integrate a function over a range ofvalues, we can compute the area under the curve, when plotted in agraph. To do this, we essentially divide up the area under thecurve into a number of simple shapes (like rectangles) and sum upthe area of those shapes; as we use more and more of the shapes, weget a more and more accurate estimate of the area. For thisexample, we will use rectangles and trapezoids. You are to write aprogram that computes the area under a function from one value toanother. You should allow this to be an arbitrary function. • Beginby outlining your program. Similar to part 1, you should identifyany functions that you want to include (this program should besimpler than the one in activity #1). Put together a documentlisting the functions you will use in your program. • You shouldtake in as input a starting and ending value of the range that youwant to integrate over. o You may, optionally, take in input forthe function itself that you want to integrate. (If you choose todo this, see the note on “eval” in Activity #3.) • You shouldintegrate the function by dividing it into a number of elements,computing the area for each of those elements, and summing up thoseareas. • Your program should begin by dividing the range into 10elements, and then repeatedly increasing the number of elementsuntil the area converges. o You may assume convergence ifconsecutive area calculations differ by less than 10-6 . • For eachof the shapes, your program should report both the area computed,and how many iterations it took to achieve convergence. • Youshould compute area using 4 different shapes/methods: o A rectanglewhose height is the value of the function at the beginning of theinterval o A rectangle whose height is the value of the function atthe end of the interval o A rectangle whose height is the value ofthe function at the midpoint of the interval o A trapezoid with oneparallel edge being the value of the function at the beginning ofthe interval, and another being the value of the function at theend of the interval. For each of these, calculate the area for aparticular subinterval –for the rectangles, the width will be theinterval width, for the trapezpoid, that will be the “height” ofthe trapezoid.

Working in Python 3.7

Expert Answer


Answer to Activity #1: Plotting Curves and Derivatives – to be done as a team As a team, you are to develop a program that will … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *