function out ( alpha, beta, f, np, nprint ) %% OUT prints out the computed solution. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 03 November 2006 % % Author: % % Original FORTRAN77 version by Max Gunzburger, Teresa Hodge % MATLAB version by John Burkardt % % Parameters: % % Input, real ALPHA(NP). % ALPHA(I) contains one of the coefficients of a recurrence % relationship that defines the basis functions. % % Input, real BETA(NP). % BETA(I) contains one of the coefficients of a recurrence % relationship that defines the basis functions. % % Input, real F(1:NP+1). % F contains the basis function coefficients that form the % representation of the solution U. That is, % U(X) = SUM (I=0 to NP) F(I+1) * BASIS(I)(X) % where "BASIS(I)(X)" means the I-th basis function % evaluated at the point X. % % Input, integer NP. % The highest degree polynomial to use. % % Input, integer NPRINT. % The number of points at which the computed solution % should be printed out at the end of the computation. % fprintf ( 1, '\n' ); fprintf ( 1, 'Representation of solution:\n' ); fprintf ( 1, '\n' ); fprintf ( 1, 'Basis function coefficients:\n' ); fprintf ( 1, '\n' ); for i = 0 : np fprintf ( 1, ' %4d %12f\n', i, f(i+1) ); end fprintf ( 1, '\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' X Approximate Solution\n' ); fprintf ( 1, '\n' ); for ip = 0 : nprint x = ( 2 * ip - nprint ) / nprint; up = 0.0; for i = 0 : np [ phii, phiix ] = phi ( alpha, beta, i, np, x ); up = up + phii * f(i+1); end fprintf ( 1, ' %12f %12f\n', x, up ); end fprintf ( 1, '\n' ); return end