Arithmetic with function(s)

`fn = fncmb(function,operation)`

`f = fncmb(function,function) `

fncmb(function,matrix,function)

fncmb(function,matrix,function,matrix)

f = fncmb(function,op,function)

The intent is to make it easy to carry out the standard linear operations of scaling and adding within a spline space without having to deal explicitly with the relevant parts of the function(s) involved.

returns
(a description of) the function obtained by applying to the values
of the function in `fn = fncmb(function,operation)`

`function`

the operation specified
by `operation`

. The nature of the operation depends
on whether `operation`

is a *scalar*,
a *vector*, a *matrix*, or a *string*,
as follows.

| Multiply the function by that scalar. |

| Add that vector to the function's values; this requires the function to be vector-valued. |

| Apply that matrix to the function's coefficients. |

| Apply the function specified by that string to the function's coefficients. |

The remaining options only work for *univariate* functions.
See Limitations for more information.

returns (a description of) the pointwise sum of the two functions.
The two functions must be of the same form. This particular case of
just two input arguments is not included in the above table since
it only works for univariate functions.`f = fncmb(function,function) `

`fncmb(function,matrix,function) `

is the same as `fncmb(fncmb(function,matrix),function)`

.

`fncmb(function,matrix,function,matrix) `

is the same as `fncmb((fncmb(function,matrix),fncmb(function,matrix)))`

.

`f = fncmb(function,op,function) `

returns the ppform of the spline obtained by the pointwise combining
of the two functions, as specified by the string `op`

. ```
op
can be
```

one of the strings `'+'`

, `'-'`

, `'*'`

.
If the second function is to be a constant, it is sufficient simply
to supply here that constant.

`fncmb(fn,3.5)`

multiplies (the coefficients
of) the function in `fn`

by 3.5.

`fncmb(f,3,g,-4)`

returns the linear combination,
with weights 3 and –4, of the function in `f`

and
the function in `g`

.

`fncmb(f,3,g)`

adds 3 times the function in `f`

to
the function in `g`

.

If the function *f* in `f`

happens
to be scalar-valued, then `f3=fncmb(f,[1;2;3])`

contains
the description of the function whose value at *x* is
the 3-vector (*f*(*x*), 2*f*(*x*),
3*f*(*x*)). Note that, by the convention
throughout this toolbox, the subsequent statement fnval(*f*3, *x*)
returns a 1-*column*-matrix.

If `f`

describes a surface in R^{3},
i.e., the function in `f`

is 3-vector-valued bivariate,
then `f2 = fncmb(f,[1 0 0;0 0 1])`

describes the
projection of that surface to the (*x*, *z*)-plane.

The following commands produce the picture of a ... spirochete?

c = rsmak('circle'); fnplt(fncmb(c,diag([1.5,1]))); axis equal, hold on sc = fncmb(c,.4); fnplt(fncmb(sc,-[.2;-.5])) fnplt(fncmb(sc,-[.2,-.5])) hold off, axis off

If `t`

is a knot sequence of length `n+k`

and `a`

is
a matrix with `n`

columns, then `fncmb(spmak(t,eye(n)),a)`

is
the same as `spmak(t,a)`

.

`fncmb(spmak([0:4],1),'+',ppmak([-1 5],[1 -1]))`

is
the piecewise-polynomial with breaks -`1:5`

that,
on the interval [0 .. 4], agrees with the function *x*|→ *B*(*x*|0,1,2,3,4)
+ *x* (but has no active break at 0 or 1, hence differs
from this function outside the interval [0 .. 4]).

`fncmb(spmak([0:4],1),'-',0)`

has the same
effect as `fn2fm(spmak([0:4],1),'pp')`

.

Assuming that `sp`

describes the B-form of
a spline of order <`k`

, the output of

fn2fm(fncmb(sp,'+',ppmak(fnbrk(sp,'interv'),zeros(1,k))),'B-')

describes the B-form of the same spline, but with its order raised to `k`

.

`fncmb`

only works for *univariate* functions,
except for the case `fncmb(function,operation)`

,
i.e., when there is just one function in the input.

Further, if two functions are involved, then they must be of
the same type. This means that they must either both be in B-form
or both be in ppform, and, moreover, have the same knots or breaks,
the same order, and the same target. The only exception to this is
the command of the form `fncmb(function,op,function)`

.

Was this topic helpful?