a) Write an function that finds the independent variable value at which a mathematical function is...

90.2K

Verified Solution

Question

Advance Math

a) Write an function that finds the independent variable valueat which a mathematical function is maximized over a specifiedinterval. The function must accept a handle to a function, andevaluate that function at values ranging from x1 to x2 with anincrement of dx. The value returned is the value of x at which themaximum value of f(x) occurs.

Function syntax: xm = xmax(f,x1,x2,dx);

As was the case in the previous problem, this function does notfind the true value of x that maximizes f(x). It only identifiesthe value of x that yields the maximum value of f(x) from amongthose values of x at which the function is evaluated. How closelythis approximates the true maximum point of f(x) will depend on thestep size, dx.
Your function should use only basic arithmetic operations and loopstructures. You may not use any built-in MATLAB functions(e.g., mean.m, sum.m, max.m, min.m, etc.).
Next, you will investigate how the estimated maximum point variesas a function of dx.

b) Write an m-file, ENGR112_HW6_2.m, in which you define thefollowing as an anonymous function.

?(?)=??^2+15??+21.843

Define a logarithmically-spaced vector, dx, of 2000 step sizes,from 10-4… 100, at which xmax.m will be used to approximate themaximizing value of f(x) over the interval of 0 ? x ? 50. Callxmax.m at each value of dx and build a vector of maximizingindependent variable values, xm. In

c) Plot the vector of approximate maximizing values as afunction of step size using a logarithmic axis for the step size.You should see that the approximation converges as step size getssmall enough.

Answer & Explanation Solved by verified expert
3.8 Ratings (538 Votes)
Finding maximum value of an arrayclear allclose allfunction for finding maximum fx for given xfx    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students