Code covered by the BSD License

### Highlights from Multi-dimensional polynomial evaluation

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 2.73 KB File ID: #44098 Version: 1.0

# Multi-dimensional polynomial evaluation

by

### Yi Sui (view profile)

Multi-dimensional polynomial evaluation

File Information
Description

POLY_ND(order,x,y,z,...) returns the polynomial terms of N variables.
The input can be column vectors of numbers, chars, or symbols.
The terms are orgnized in ascending dimensions.i.e x then x,y then x,y,z.
EXAMPLE 1
syms x,y,z,t
poly_nd(4,x,y)
ans =
[ 1, x, x^2, x^3, x^4, y, x*y, x^2*y, x^3*y, y^2, x*y^2, x^2*y^2, y^3, x*y^3, y^4]

poly_nd(2,x,y,z)
ans =
[ 1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2]

poly_nd(2,x,y,z,t)
ans =
[ 1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2, t, t*x, t*y, t*z, t^2]

EXAMPLE 2
x=[0 1 2]'; %numbers vector
y=['y1'; 'y2'; 'y3']; % chars vector
z=sym('z',[1,3]); %symbols vector
poly_nd(2,x,y,z)
ans =
[ 1, 0, 0, y1, 0, y1^2, z1, 0, y1*z1, z1^2]
[ 1, 1, 1, y2, y2, y2^2, z2, z2, y2*z2, z2^2]
[ 1, 2, 4, y3, 2*y3, y3^2, z3, 2*z3, y3*z3, z3^2]

POLYVAL_ND(p,order,x,y,z,...) returns the value of ND polynomial p evaluated at point (x,y,z,...)

e.g for a 3D 2rd order polynomial:
coef: p = [p000 p100 p200 p010 p110 p020 p001 p101 p011 p002 ];
value: v = [ 1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2] *p'
p is orgnized in ascending dimension.i.e x then x,y then x,y

Required Products Symbolic Math Toolbox
MATLAB
MATLAB release MATLAB 8.1 (R2013a)