1. Engineering
  2. Computer Science
  3. from quotrealquot calculus you should know the derivative offixx2 is...

Question: from quotrealquot calculus you should know the derivative offixx2 is...

Question details

From real calculus, you should know the derivative offix-x2 is f(x) = 2x. So atxz 300, the exact value of the derivative f(300) is obviously 600. However, computers approximate the derivative by taking the limit f(x)-lim So applying this to the fx)x2example above, I would hope that f(300) would be well-approximated by the limit f 300) 600-lim 2.5 12 pts f(x+a)-f(x) (300+a)* - (300) Lets test this out using MATLAB for smaller-and-smaller values a, and look at the errors! Specifically, well look at the right-hand-side of the limit using a range of a from 1 to 1018, and compare that approximate value of the derivative to the exact value of f(300) 600. (A) First, make the exact MATLAB function deriv.m below to evaluate the approximate limit for any a function fprime-deriv(a) x 300: end Do not simplify or change the formula for deriv (a) in any way! The equation is important so the mathematical operations are done the same way for everyone in the course. If you change it, you may not see the numerical phenomena below, of which your explanation is being graded Make your own script, called HW2_5.m, that uses deriv.m to calculate vectors of the following four parameters using the 19 values of a in the vector [1, 0-1, 102, 103, (B) , 1048] a, derma), absolute value of error, absolute value of % relative error For example, you might call the four vectors a, fprime, Error and PctError .Define error here as the difference between deriv(a) and the exact value of 600 Your error must be only positive, because soon youll take its logarithm. Try using the built-in command abs to take the absolute value of elements in a vector. (C) Add to the end of your script, the following code fragment to make two plots in your figure window: one of the approximate derivative, and one of the log1o of the percent relative error, both as a function of the base-10 logarithm of a: subplot (211): plot (log10 (a), fprime, -o) xlabel (log_1_0 (a)ylabel (Approx Derivative) subplot (212): plot (log10 (a), log10 (PctError),-o) xlabel ( log-1-0 (a) ) ; ylabel ( log-1-0( 1 % Error ! ) ) Are any of these plotting commands new for you? · subplot (211) and 3ubplot (212) allow you to put two plots in the same figure .log10 (x) returns the base-10 logarithm of x. Dont use log (x), thats used instead for the natural log (i.e. In(x)). The underscores (_) in the x-and y-labels tell MATLAB to write the next letter as a subscript font, so your label looks very professional, as in log1o (a)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution