function [ phii, phiix ] = phi ( il, x, xleft, xrite ) %% PHI evaluates a linear basis function and its derivative. % % Discussion: % % The functions are evaluated at a point X in an interval. In any % interval, there are just two basis functions. The first % basis function is a line which is 1 at the left endpoint % and 0 at the right. The second basis function is 0 at % the left endpoint and 1 at the right. % % Modified: % % 05 November 2006 % % Parameters: % % Input, integer IL, the local index of the basis function. % % Input, real X, the evaluation point. % % Input, real XLEFT, XRITE, the endpoints of the interval. % % Output, real PHII, PHIIX, the value of the basis function % and its derivative. % if ( xleft <= x & x <= xrite ) if ( il == 1 ) phii = ( xrite - x ) / ( xrite - xleft ); phiix = -1.0 / ( xrite - xleft ); else phii = ( x - xleft ) / ( xrite - xleft ); phiix = 1.0 / ( xrite - xleft ); end % % If X is outside of the interval, then the basis function % is always zero. % else phii = 0.0; phiix = 0.0; end