function exercise1 ( )

%*****************************************************************************80
%
%% exercise1 verifies that psi_square() generates the uv_square velocities.
%
%  Discussion:
%
%    The velocity field from uv_square() is exactly zero on the boundary.
%
%    The velocity field from uv_from_psi() is nonzero on the boundary,
%    because our finite difference estimates are only first order.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 June 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exercise1:\n' );
  fprintf ( 1, '  Use psi_square() to generate stream function values\n' );
  fprintf ( 1, '  and then velocity vectors.\n' );
  fprintf ( 1, '  Compare these to the velocities from uv_square().\n' ); 
%
%  Set up the spatial grid.
%
  nr = 11;
  nc = 11;
  [ X, Y ] = xy_square ( nr, nc );
%
%  Get the velocities directly.
%
  [ U, V ] = uv_square ( X, Y );
%
%  Get stream function values.
%
  PSI = psi_square ( X, Y );
%
%  Derive velocities from the stream function.
%
  [ U2, V2 ] = uv_from_psi ( X, Y, PSI );
%
%  Compute difference between the two sets of velocities.
%
  diff = norm ( U2 - U ) + norm ( V2 - V );
  fprintf ( 1, '  U, V  = velocities from uv_square()\n' );
  fprintf ( 1, '  U2,V2 = velocities derived from psi_square()\n' );
  fprintf ( 1, '  ||U-U2|| + ||V-V2|| = %g\n', diff );

  return
end

