2 * Functions and Variables for Bernstein::
5 @node Functions and Variables for Bernstein, , Package bernstein, Package bernstein
6 @section Functions and Variables for Bernstein
8 @anchor{bernstein_poly}
9 @deffn {Function} bernstein_poly (@var{k}, @var{n}, @var{x})
11 Provided @code{k} is not a negative integer, the Bernstein polynomials
12 are defined by @code{bernstein_poly(k,n,x) = binomial(n,k) x^k
13 (1-x)^(n-k)}; for a negative integer @code{k}, the Bernstein polynomial
14 @code{bernstein_poly(k,n,x)} vanishes. When either @code{k} or @code{n} are
15 non integers, the option variable @code{bernstein_explicit}
16 controls the expansion of the Bernstein polynomials into its explicit form;
20 (%i1) load("bernstein")$
22 (%i2) bernstein_poly(k,n,x);
23 (%o2) bernstein_poly(k, n, x)
24 (%i3) bernstein_poly(k,n,x), bernstein_explicit : true;
26 (%o3) binomial(n, k) (1 - x) x
29 The Bernstein polynomials have both a gradef property and an integrate property:
32 (%i4) diff(bernstein_poly(k,n,x),x);
33 (%o4) (bernstein_poly(k - 1, n - 1, x)
34 - bernstein_poly(k, n - 1, x)) n
35 (%i5) integrate(bernstein_poly(k,n,x),x);
38 hypergeometric([k + 1, k - n], [k + 2], x) binomial(n, k) x
39 ----------------------------------------------------------------
43 For numeric inputs, both real and complex, the Bernstein polynomials evaluate
47 (%i6) bernstein_poly(5,9, 1/2 + %i);
49 (%o6) -------- + -----
51 (%i7) bernstein_poly(5,9, 0.5b0 + %i);
52 (%o7) 3.076171875b2 %i + 1.5380859375b2
55 To use @code{bernstein_poly}, first @code{load("bernstein")}.
60 @anchor{bernstein_explicit}
61 @defvr {Variable} bernstein_explicit
62 Default value: @code{false}
64 When either @code{k} or @code{n} are non integers, the option variable
65 @code{bernstein_explicit} controls the expansion of @code{bernstein(k,n,x)}
66 into its explicit form; example:
69 (%i1) bernstein_poly(k,n,x);
70 (%o1) bernstein_poly(k, n, x)
71 (%i2) bernstein_poly(k,n,x), bernstein_explicit : true;
73 (%o2) binomial(n, k) (1 - x) x
75 When both @code{k} and @code{n} are explicitly integers, @code{bernstein(k,n,x)}
76 @emph{always} expands to its explicit form.
81 @anchor{multibernstein_poly}
82 @deffn {Function} multibernstein_poly (@var{[k1,k2,@dots{}, kp]}, @var{[n1,n2,@dots{}, np]}, @var{[x1,x2,@dots{}, xp]})
84 The multibernstein polynomial @code{multibernstein_poly (@var{[k1, k2, ...,
85 kp]}, @var{[n1, n2, ..., np]}, @var{[x1, x2, ..., xp]})} is the product of
86 bernstein polynomials @code{bernstein_poly(k1, n1, x1)
87 bernstein_poly(k2, n2, x2) ... bernstein_poly(kp, np, xp)}.
89 To use @code{multibernstein_poly}, first @code{load("bernstein")}.
93 @anchor{bernstein_approx}
94 @deffn {Function} bernstein_approx (@var{f}, @var{[x1, x1, @dots{}, xn]}, n)
96 Return the @code{n}-th order uniform Bernstein polynomial approximation for the
97 function @code{(x1, x2, ..., xn) |--> f}.
101 (%i1) bernstein_approx(f(x),[x], 2);
103 (%o1) f(1) x + 2 f(-) (1 - x) x + f(0) (1 - x)
105 (%i2) bernstein_approx(f(x,y),[x,y], 2);
107 (%o2) f(1, 1) x y + 2 f(-, 1) (1 - x) x y
110 + f(0, 1) (1 - x) y + 2 f(1, -) x (1 - y) y
113 + 4 f(-, -) (1 - x) x (1 - y) y + 2 f(0, -) (1 - x) (1 - y) y
116 + f(1, 0) x (1 - y) + 2 f(-, 0) (1 - x) x (1 - y)
119 + f(0, 0) (1 - x) (1 - y)
122 To use @code{bernstein_approx}, first @code{load("bernstein")}.
126 @anchor{bernstein_expand}
127 @deffn {Function} bernstein_expand (@var{e}, @var{[x1, x1, @dots{}, xn]})
129 Express the @emph{polynomial} @code{e} exactly as a linear combination of multi-variable
130 Bernstein polynomials.
133 (%i1) bernstein_expand(x*y+1,[x,y]);
134 (%o1) 2 x y + (1 - x) y + x (1 - y) + (1 - x) (1 - y)
139 Maxima signals an error when the first argument isn't a polynomial.
141 To use @code{bernstein_expand}, first @code{load("bernstein")}.