QuestionQuestion

Please see Questions.pdf

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

function [x,Emaxs] = crude (f, xL, xU, Edes, display)
% CUDE Finds a minimum by performing a bisection like search
% Inputs: f = a function of one variable
%         xL = lower bound of region containing minimum
%         xU = upper bound of region containing minimum
%         Edes = function stops when x is guaranteed within Edes of minimum
%         display = display option (0 = no display (default), 1 = display)
% Outputs: x - estimate of minimum
%          Emaxs - value of Emax as a function of iteration number k;
if nargin < 5; display = 0; end

if display
fprintf ...
('    N       xL          xA          xB          xU          Emax\n');
end

functionCount = 0;

for k = 0 : 1000

    Emax = (xU - xL) / 2;
    Emaxs(k+1)=Emax;   

    xA = xL + 0.49 * (xU - xL); fxA = f(xA);
    xB = xL + 0.51 * (xU - xL); fxB = f(xB);
    functionCount = functionCount + 2;
   
    if display
      fprintf ('%5d %12.6f %12.6f %12.6f %12.6f %12.6f\n', ...
               k, xL, xA, xB, xU, Emax);
    end
   
    if Emax <= Edes
       x = (xL + xU) / 2; % take midpoint as final answer
       if display
            % the last two function evaluations weren't actually needed
            % (the results weren't used) and could be eliminated
            fprintf ('Tolerance achieved after %d function evaluations.\n', ...
                     functionCount - 2);
       end...
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Mathematics - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats