Name

plq_build — Piecewise linear quadratic (plq), build a zeroth- or first-order function approximation

Calling Sequence

plqf = plq_build(x,f,df)
plqf = plq_build(x,f,df [,needEval] [,exclude] [,method] [,plqf])

Parameters

x

column vector. A grid of points on which the function is sampled.

f

function or column vector. The function to build a PLQ representation of.

df

function or column vector, optional. The derivative of f.

needEval

boolean, optional. False, or not entered implies that function does not need to be evaluated and the function is vectorized, otherwise evaluate point by point.

exclude

boolean, optional.

method

boolean, optional. The method 'plq' or not entered implies a normal plq approximation. The method 'soqs' uses a Shape-Preserving Osculatory Spline approximation (see McAllister and Roulier, ACM TOMS, Sep. 1981). If no derivatives are provided, forward differentiation is used for 'plq' and shape-preserving calculation is used for 'soqs'.

plqf

matrix. A plq function with dimensions n x 4.

Description

<listitem>

Builds a plq approximation of a function when given a function and optionally the function's derivative. If df is given, a first-order model is built, otherwise a zeroth-order model is built.

</listitem>

Examples

//Example 1
x=linspace(0,4)';
plqf = plq_build(x,exp,exp);
y=eval_plq(plqf,x);

//Example 2
function y=f(x),i1=find(x<0);i2=find(x==0);i3=find(x>0);y(i1)=%inf*ones(i1);y(i2)=0;y(i3)=x(i3).*log(x(i3))-x(i3);endfunction
function y=df(x),i1=find(x<=0);i2=find(x>0);y(i1)=%inf*ones(i1);y(i2)=log(x(i2));endfunction
x=linspace(0,20,3)';
plqf = plq_build(x,f,df);
y = eval_plq(plqf,x);
  

See Also

plq_function

Authors

Yves Lucet, University of British Columbia, BC, Canada