%finishes holdingholdoff;%our guess after looking at our graphinference = 2.66;%uses fzero to find value at the root of our functions including our guess%valueans = fzero(y, inference);%finds our at x position which the projectile lands at using our answer ofthe%fzero functionxPos = x(ans);%prints value at which the position landsfprintf('It lands really, really close to the cannon at %0.4f meters attime %0.4f seconds.\n', xPos, ans);Function Files% Copy and paste your functions here (if any were used). Must be size 10,same as MATLAB font and color.Command Window OutputIt lands really, really close to the cannon at 0.6490 meters at time 2.7547seconds.

Week 5 HomeworkENGR 112Fzero whileProblem 2Find all of the intersections of two functions ofx:F1(x) = 100e-x- 1 andF2(x) =sin(𝜋?)in thedomain2 ≤x≤ 10.a)Plot both functions on the same graph. Draw X’s where the functions intersect.b)Print the x values forallof the intersections found.Use afororwhileloop to automatically find all of the intersections in the given domain (asopposed to estimating them by hand). Before printing your answers,filter outall solutions thatare outside of the domain given in the question.The numerical approximation that you’re using in this problem (fzero) can cause headaches ifyou’re not careful, so be sure to read the hints below.Hint 1: How do you make an anonymous function that takes one variable (x) and returns zerowhen the two functions intersect?Hint 2: You need to call fzero a bunch of times with a reasonable set of guesses, enough to makesure that you actually get all of the intersections.Each time you calculate a new intersection, compare itto ALL of the intersections that you have already calculated. If the difference between the newintersection and any of the old ones is very small(<0.00006), do not add it to your list and just move onto calculating the next one. Don’t forget to check that the intersection is in the given domain.a)[+10 Extra credit] In hint #2, why should you use (currentRoot–oldRoots) <0.00006instead of (currentRoot–oldRoots)== 0? Write your answer in the Worddocument.b)[+10 Extra credit] Even if you do everything correctly, fzero can return solutions faraway from your guess. Why do you think this happens? Write your answer in theWord document.

Get answer to your question and much more

(Note: Print ALL roots. This self-check only gives you the first and last.)

Week 5 HomeworkENGR 112Fzero whileComments for grader/additional information (if any)Script File%Nick Vrvilo%May 11th, 2017%Desc: Finds all of the intersections of two given functions in the domain%of 2 <= x <= 10 while ignoring all of the otherintersectionsclear;%clears workspaceclc;%clears command windowclf;%clears figurex = 2:.05:10;%our first function named F1 w/respect to xF1 = @(x) 100*exp(-x) -1;%our second function named F2 w/respect to xF2 = @(x) sin(pi*x);%our third anon function that takes one variable and returns zero when the%two functions intersectF3 = @(x) 100*exp(-x) - 1 - sin(pi*x);%an array in the domain of x we will be evaluating our functions at to find

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 16 pages?

Upload your study docs or become a

Course Hero member to access this document