function u = utrue(x)

% function u = utrue(x)
%
% True solution for AMSC/CMSC 661, Homework 1, Spring 2010
%
% Input x: an array of values for which the
%          solution is to be computed.
% Output u: the array of values utrue(x).
%
% Dianne P. O'Leary 02-01-2010

% Parameters for the Weibull function that forms
% the solution.

k = 1.5;
lambda = 1;

% w1 is the value of the Weibull function at x=0,
% and w2 is the value at x=1.  A straight line
% through these values is subtracted from the 
% other Weibull values to make the boundary 
% conditions zero.

w1 = k/lambda * (.1/lambda)^(k-1)*exp(-(.1/lambda)^k);
w2 = k/lambda * (1.1/lambda).^(k-1).*exp(-(1.1/lambda).^k);

% It would be more efficient to set k, lambda, w1,
% and w2 once rather than every time this function
% is called.

% Now we are ready to evaluate the true solution
% and store it in u.

y = x+.1;
u = k/lambda * (y/lambda).^(k-1).*exp(-(y/lambda).^k) ...
     - (1-x)*w1 - x*w2;
 
