function value = u_exact ( x, problem ) %% U_EXACT returns the value of the exact solution at a point X. % % Modified: % % 01 November 2006 % % Parameters: % % Input, real X, the evaluation point. % % Input, integer PROBLEM, indicates which problem to be solved. % * 1, u = x, p=1, q=0, f=x, u(0)=0, u'(1)=1. % * 2, u = 2*(1-cos(0.5*pi*x))/pi, p=1, q=0, % f = -0.5*pi*cos(0.5*pi*x) + 2*sin(0.5*pi*x)*(1-cos(0.5*pi*x)/pi % u(0) = 0, u'(1)=1. % % Output, real VALUE, the value of the exact solution at X. % % % Test problem 1 % if ( problem == 1 ) value = x; % % Test problem 2 % elseif ( problem == 2 ) value = 2.0 * ( 1.0 - cos ( 0.5 * pi * x ) ) / pi; end