

%  This program computes an oscillatory integral on the interval
%  x in [-2 2] with the integrand
%
%          exp(-3x^2)exp(-itx)
%
%  and the integrand
%
%          exp(-3x^2)exp(-it(x-x0)^2)
%
%  to illustrate the method of stationary phase.
%  This program requires the supporting mfiles intgnd1.m and intgnd2.
%  The integrals are evaluated using the matlab package quad8.
%  At run time the user must enter the choice of 1 for the linear phase
%  or 2 for the nonlinear phase. User then enters a vector of times
%  at which the integral is to be evaluated. For example, [0:20].
%  In the case of the nonlinear phase, the user must also enter the
%  value x0 which is the stationary point of the nonlinear phase.
%  
%  The values of the integral are placed in the  vector F.
%  The real part of F is plotted against the vector of t values.



m = input(' Enter 1 for the linear phase, 2 for the nonlinear phase  ')
t = input(' Enter the vector of time values    ')
N = size(t,2)
if m == 1
    for k = 1:N
        t(k)
        F(k) = quad8('intgnd1', -2,2,[], [], t(k));
     end

    plot(t,F)
    xlabel( ' increasing t ')
    ylabel('  Re F(t) for linear phase  ')

else
    global x0
    x0 = input(' Enter the stationary point x0 of the phase  ')
    for k = 1:N
        t(k)
        F(k) = quad8('intgnd2', -2,2, [],[],t(k));
    end
    plot(t,F)
    xlabel( '   increasing t ')
    ylabel( ' Re F(t) for nonlinear phase ')
end


