%This script will evaluate the area underneath a curve between two points
%either by shells or integration
% Lower Bouns (L) is the x value to start the evaluation at
% Upper Bound (U) is the end x value
% f is the function you wish to input
% the script will use a stepsize of 1 for time purposes but can be changed
% by changing h in the script
% the user can select 4 options for the integral (a basic integral, shells, disks, and arc length)
% for basic integral enter 'integral when prompted
% for shells, enter 'shells', 
% for disks, enter 'disks'
% for arc length, enter 'arclength'


function [M]= Final_Project(f,a,b,n)


i = (b-a)/n;                 


m = input('enter a method');



    switch m 
        %%%%%%%%%%%%%%%%%%%%%%%%%Basic Integral%%%%%%%%%%%%%%%%%%%
       case 'integrate'
           

syms x 

%input the Function you want to evaluate

f = @(x)eval(f);        %evaluate function


j = 0;

for a = i
   j = j+1;
   
   M(j) = (b-a)*(f((a+b)/2));                   % Midpoint Rule
   T(j) = ((b-a)/2)*(f(a)+f(b));                % Trapezoid Rule
   S(j) = ((b-a)/6)*(f(a)+(4*f((a+b)/2)+f(b))); % Simpson's Rule
      
   M
   T
   S
   % integral solver uses three different approximations
   hold on
   
plot(i,M,'g')

plot(i,T,'r')

plot(i,S,'c')
end
        


    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Arc length%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        case'arclength'      
syms x 
  
f = @(x)eval(f);        %evaluate function

j = 0;

for a = i
   j = j+1;
   
    S(j) = ((1)+((b-a)/6)*(f(a)+(4*f((a+b)/2)+f(b))^2))^(1/2); % Simpson's Rule
end
S

 %%%%%%%%%%%%%%%%%%%%%%%%%%Begin Shell intergation%%%%%%%%%%%%%%%%%%%%%%%%
        
        case'shell'        
            
            
syms x           

       
f = @(x)eval(f);        %evaluate function

j = 0;

for a = i
   j = j+1;
   
    S(j) = (2*pi)*((b-a)/6)*(f(a)+(4*f((a+b)/2)+f(b))); % Simpson's Rule
end
S

plot(i,S,'c')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Disk Method%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        case'disk'        
                   

syms x        
f = @(x)eval(f);        %evaluate function

j = 0;

for a = i
   j = j+1;
   
    S(j) = (pi)*((b-a)/6)*(f(a)+(4*f((a+b)/2)+f(b))^2); % Simpson's Rule
end
S

plot(i,S,'c')

plot(i,S,'c')

    end
end