%  numint3.m
% Matlab file for Part 3 of Numeric Calculation of 
% Integrals module

disp('**********************************************')
disp('Part 3: Midpoint Sums ')
disp('**********************************************')
disp('  ')    

    format long
    
    disp('--------------------------------------------')
    disp('Step 1: ')
    disp('Hand in your hand-drawn diagram on a separate')
    disp('piece of paper.  ')    
    disp('Answer the questions by using MATLAB comments ')
    disp('in your diary file. ')
    disp(' ')
    disp('To continue, type the word return and ')
    disp('hit enter!')
    disp(' ')
    
    keyboard;
    disp(' ')
    
    disp('--------------------------------------------')
    disp('Steps 2 and 3: ')
    disp('Answer the questions by using MATLAB comments ')
    disp('in your diary file. ')
    disp(' ')
    disp('To continue, type the word return and ')
    disp('hit enter!')
    disp(' ')
    
    keyboard;
    disp(' ')
    
    disp('---------------------------------------------')
    disp('Enter the integrand function to use in ')
    disp('step 4: ')
    disp(' ')
    disp('  f = fcnchk(''(x^2+5)/6'', ''vectorized'' )  ')
    disp(' ')
    disp(' ')
    disp('To continue, type the word return and ')
    disp('hit enter!')
    disp(' ')
    
    keyboard;
    disp(' ')
    
    disp('--------------------------------------------')
    disp('Step 4: ') 
    disp('Do the midpoint sum calulation for n=5') 
    disp('rectangles. ')
    disp('Does your sum match the applet? ')
    disp('Answer using MATLAB comments in your diary file.')
    disp(' ')
    disp('To continue, type the word return and ')
    disp('hit enter!')
    disp(' ')
    
    keyboard;
    disp(' ')
    
    disp('--------------------------------------------')
    disp('Step 5: ') 
    disp('Answer the questions using MATLAB comments')
    disp('in your diary file.')
    disp(' ')
    disp('To continue, type the word return and ')
    disp('hit enter!')
    disp(' ')
    
    keyboard;
    disp(' ')
    
    disp('---------------------------------------------')
    disp('Step 6: ')
    disp('Below, find the commands that calculate a ')
    disp('midpoint sum. By changing the value of n and')
    disp('re-entering the commands, you can calculate the')
    disp('sum for the number of subintervals you desire.')
    disp('You can enter a new function f(x) and new ')
    disp('endpoints a and b to calculate an approximation')
    disp('to any integral. ')
    disp(' ')
    disp('Enter: ')
    disp(' ')
    disp('  clear f x a b n xpt; ')
    disp('  f = fcnchk(''(x^2+5)/6'', ''vectorized'' )  ')
    disp('  n = 40 ')
    disp('  a = 0, b = 5 ')
    disp('  delx = (b-a)/n; ')
    disp('  xpt = a+0.5*delx: delx: b-0.5*delx; ')
    disp('  areas = f(xpt)*delx; ')
    disp('  MID = sum(areas) ')
    disp(' ')
    disp('------------------------------------------------')
    disp('Discuss how your results compare with those of')
    disp('the applet by using MATLAB comments in your ')
    disp('diary file.')
    disp(' ')
    disp('To continue, type the word return and ')
    disp('hit enter!')
    disp(' ')
    
    keyboard;
    disp(' ')
    
    disp('------------------------------------------------')
    disp('Step 7: ')
    disp('Change the function to f(x)=1/x and the interval')
    disp('to 1 < x < 3 in the MID commands above and do ')
    disp('the calculations to fill in the table below. ')
    disp(' ')
    disp('  Subintervals n     MID Approx to 1/x integral ')
    disp('         5                 1.0928571429')
    disp('        10                 ____________')
    disp('        20                 ____________')
    disp('        40                 ____________')
    disp(' ')
    disp(' ')
    disp('-------------------------------------------- ')
    disp('When you are ready to go on to part 4 ')
    disp('of this module, type: numint4.')
    disp(' ')
