function [x,y] = rope_linsys ( n )
%
%  function [x,y] = rope_linsys ( n )
%
%  ROPE_LINSYS sets up and solves the rope BVP, using linear system techniques.
%
%  Discussion:
%
%    The boundary value problem:
%
%      Y'' = 0.1
%      Y(0) = 0, Y(5) = 0.5
%
%    is discretized by considering N equally spaced points between 0 and 5,
%    and approximating the second derivative by (Y(I-1)-2*Y(I)+Y(I+1))/DX^2.
%
%  Modified:
%
%    16 February 2000
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the order of the system (number of points at which
%    a solution is to be computed.)
%
%    Output, real X(N), Y(N), the X and Y positions of points on the rope.
%
d1 = ones ( n-1, 1 );
d2 = ones ( n, 1 );
A = diag ( d1, -1 ) - 2 * diag ( d2 ) + diag ( d1, +1 );
%
%  Correct the first and last rows.
%
A(1,1) = 1.0;
A(1,2) = 0.0;
A(n,n-1) = 0.0;
A(n,n) = 1.0;
%
%  Set up the right hand side vector, correcting the first and last.
%
dx = 5.0 / ( n - 1 );

b = 0.1 * dx^2 * ones ( n, 1 );
b(1) = 0.0;
b(n) = 0.5;
%
%  Solve.
%
x = linspace ( 0.0, 5.0, n )';
y = A \ b;

