2 * Functions and Variables for Bernstein::
5 @node Functions and Variables for Bernstein, , Bernstein, Bernstein
6 @section Functions and Variables for Bernstein
8 @deffn {Function} bernstein_poly (@var{k}, @var{n}, @var{x})
10 Provided @code{k} is not a negative integer, the Bernstein polynomials
11 are defined by @code{bernstein_poly(k,n,x) = binomial(n,k) x^k
12 (1-x)^(n-k)}; for a negative integer @code{k}, the Bernstein polynomial
13 @code{bernstein_poly(k,n,x)} vanishes. When either @code{k} or @code{n} are
14 non integers, the option variable @code{bernstein_explicit}
15 controls the expansion of the Bernstein polynomials into its explicit form;
19 (%i1) load(bernstein)$
21 (%i2) bernstein_poly(k,n,x);
22 (%o2) bernstein_poly(k, n, x)
23 (%i3) bernstein_poly(k,n,x), bernstein_explicit : true;
25 (%o3) binomial(n, k) (1 - x) x
28 The Bernstein polynomials have both a gradef property and an integrate property:
31 (%i4) diff(bernstein_poly(k,n,x),x);
32 (%o4) (bernstein_poly(k - 1, n - 1, x)
33 - bernstein_poly(k, n - 1, x)) n
34 (%i5) integrate(bernstein_poly(k,n,x),x);
37 hypergeometric([k + 1, k - n], [k + 2], x) binomial(n, k) x
38 ----------------------------------------------------------------
42 For numeric inputs, both real and complex, the Bernstein polynomials evaluate
46 (%i6) bernstein_poly(5,9, 1/2 + %i);
48 (%o6) -------- + -----
50 (%i7) bernstein_poly(5,9, 0.5b0 + %i);
51 (%o7) 3.076171875b2 %i + 1.5380859375b2
54 To use @code{bernstein_poly}, first @code{load("bernstein")}.
59 @defvr {Variable} bernstein_explicit
60 Default value: @code{false}
62 When either @code{k} or @code{n} are non integers, the option variable
63 @code{bernstein_explicit} controls the expansion of @code{bernstein(k,n,x)}
64 into its explicit form; example:
67 (%i1) bernstein_poly(k,n,x);
68 (%o1) bernstein_poly(k, n, x)
69 (%i2) bernstein_poly(k,n,x), bernstein_explicit : true;
71 (%o2) binomial(n, k) (1 - x) x
73 When both @code{k} and @code{n} are explicitly integers, @code{bernstein(k,n,x)}
74 @emph{always} expands to its explicit form.
79 @deffn {Function} multibernstein_poly (@var{[k1,k2,@dots{}, kp]}, @var{[n1,n2,@dots{}, np]}, @var{[x1,x2,@dots{}, xp]})
81 The multibernstein polynomial @code{multibernstein_poly (@var{[k1, k2, ...,
82 kp]}, @var{[n1, n2, ..., np]}, @var{[x1, x2, ..., xp]})} is the product of
83 bernstein polynomials @code{bernstein_poly(k1, n1, x1)
84 bernstein_poly(k2, n2, x2) ... bernstein_poly(kp, np, xp)}.
86 To use @code{multibernstein_poly}, first @code{load("bernstein")}.
90 @deffn {Function} bernstein_approx (@var{f}, @var{[x1, x1, @dots{}, xn]}, n)
92 Return the @code{n}-th order uniform Bernstein polynomial approximation for the
93 function @code{(x1, x2, ..., xn) |--> f}.
97 (%i1) bernstein_approx(f(x),[x], 2);
99 (%o1) f(1) x + 2 f(-) (1 - x) x + f(0) (1 - x)
101 (%i2) bernstein_approx(f(x,y),[x,y], 2);
103 (%o2) f(1, 1) x y + 2 f(-, 1) (1 - x) x y
106 + f(0, 1) (1 - x) y + 2 f(1, -) x (1 - y) y
109 + 4 f(-, -) (1 - x) x (1 - y) y + 2 f(0, -) (1 - x) (1 - y) y
112 + f(1, 0) x (1 - y) + 2 f(-, 0) (1 - x) x (1 - y)
115 + f(0, 0) (1 - x) (1 - y)
118 To use @code{bernstein_approx}, first @code{load("bernstein")}.
122 @deffn {Function} bernstein_expand (@var{e}, @var{[x1, x1, @dots{}, xn]})
124 Express the @emph{polynomial} @code{e} exactly as a linear combination of multi-variable
125 Bernstein polynomials.
128 (%i1) bernstein_expand(x*y+1,[x,y]);
129 (%o1) 2 x y + (1 - x) y + x (1 - y) + (1 - x) (1 - y)
134 Maxima signals an error when the first argument isn't a polynomial.
136 To use @code{bernstein_expand}, first @code{load("bernstein")}.