1 (kill(all), load("bernstein"),0);
4 [errcatch(bernstein_poly()),
5 errcatch(bernstein_poly(2)),
6 errcatch(bernstein_poly(5,6)),
7 errcatch(bernstein_poly(false,false,false,false))];
10 bernstein_poly(0,0,x);
13 [bernstein_poly(0,1,x), bernstein_poly(1,1,x)];
16 [bernstein_poly(0,2,x), bernstein_poly(1,2,x),bernstein_poly(2,2,x)];
17 [(1-x)^2,2*(1-x)*x,x^2]$
19 bernstein_poly(5,1,x);
22 bernstein_poly(-1,1,x);
25 bernstein_poly(k,n,0);
28 bernstein_poly(k,n,1);
31 expand(makelist(sum(bernstein_poly(k,n,x),k,0,n),n,0,15));
32 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]$
34 makelist(sum(bernstein_poly(k,n,1/5 + %i),k,0,n),n,0,25);
35 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]$
37 map(lambda([s], is(abs(1-s) < 1.0e-10)), makelist(sum(bernstein_poly(k,n,0.4 + %i),k,0,n),n,0,12));
38 [true,true,true,true,true,true,true,true,true,true,true,true,true]$
40 (fpprec : 54, map(lambda([s], is(abs(1-s) < 1.0e-50)), makelist(sum(bernstein_poly(k,n,1.4b0- %i/5),k,0,n),n,0,12)));
41 [true,true,true,true,true,true,true,true,true,true,true,true,true]$
44 (reset(fpprec), listarith : true,0);
47 (q : block([bernstein_explicit : false,k,n,x], makelist(diff(bernstein_poly(k,n,x),v),v,[k,n,x]))
48 -block([bernstein_explicit : true,k,n,x], makelist(diff(bernstein_poly(k,n,x),v),v,[k,n,x])),
49 expand(subst([k=5,n=8],q)));
57 block([expand_hypergeometric : true, bernstein_explicit : false,i1,i2],
58 i1 : integrate(bernstein_poly(k,n,x),x,0,z),
59 i2 : integrate(bernstein_poly(12,18,x),x,0,z),
60 expand(subst([k=12,n=18], i1-i2)));
63 block([expand_hypergeometric : true, bernstein_explicit : false,i1,i2],
64 i1 : integrate(bernstein_poly(k,n,x),x,0,z),
65 i2 : integrate(bernstein_poly(5,5,x),x,0,z),
66 expand(subst([k=5,n=5], i1-i2)));
69 (declare(kk,integer, nn, integer, z, complex),0);
72 conjugate(bernstein_poly(kk,nn,z));
73 bernstein_poly(kk,nn,conjugate(z))$
76 conjugate(bernstein_poly(k,n,z));
77 conjugate(bernstein_poly(k,n,z))$
79 (remove(z,complex,kk,integer, nn,integer),0);
82 bernstein_approx(f(x),[x],1);
85 bernstein_approx(f(x),[x],3);
86 f(1)*x^3+3*f(2/3)*(1-x)*x^2+3*f(1/3)*(1-x)^2*x+f(0)*(1-x)^3$
88 bernstein_approx(f(x,y),[x,y],1);
89 f(1,1)*x*y+f(0,1)*(1-x)*y+f(1,0)*x*(1-y)+f(0,0)*(1-x)*(1-y)$
91 bernstein_approx(f(x,y),[x,y],2);
92 f(1,1)*x^2*y^2+2*f(1/2,1)*(1-x)*x*y^2+f(0,1)*(1-x)^2*y^2+2*f(1,1/2)*x^2*(1-y)*y+4*f(1/2,1/2)*(1-x)*x*(1-y)*y+2*f(0,1/2)*(1-x)^2*(1-y)*y+f(1,0)*x^2*(1-y)^2+2*f(1/2,0)*(1-x)*x*(1-y)^2+f(0,0)*(1-x)^2*(1-y)^2$
94 errcatch(multibernstein_poly(2,3,x));
97 errcatch(multibernstein_poly([2],[3],x));
100 errcatch(multibernstein_poly([1,2,3],[u,n,k],[8]));
103 errcatch(multibernstein_poly(2,3,false, false));
106 expand(multibernstein_poly([2,4,5],[7,8,9],[x,y,z]) - xreduce("*", map('bernstein_poly, [2,4,5],[7,8,9],[x,y,z])));
109 multibernstein_poly([9,q,p],[8,q,p],[x,y,z]);
112 multibernstein_poly([q,p,r,9],[l,s,s,5],[w,x,y,z]);
115 q : bernstein_expand(x*y+1,[x,y]);
116 2*x*y+(1-x)*y+x*(1-y)+(1-x)*(1-y)$
121 q : bernstein_expand(x*y+a,[x,y]);
122 (a+1)*x*y+a*(1-x)*y+a*x*(1-y)+a*(1-x)*(1-y)$
127 q : bernstein_expand(x*y+a,[x]);
133 q : bernstein_expand(x^2 + y^2 + x + y - 42,[x,y]);
134 -38*x^2*y^2-79*(1-x)*x*y^2-40*(1-x)^2*y^2-79*x^2*(1-y)*y-164*(1-x)*x*(1-y)*y-83*(1-x)^2*(1-y)*y-40*x^2*(1-y)^2
135 -83*(1-x)*x*(1-y)^2-42*(1-x)^2*(1-y)^2$
138 x^2 + y^2 + x + y - 42$
140 q : bernstein_expand(sqrt(5) * x^2 + (1 - %pi) * y^2 + 2*%e * x+ y - 42,[x,y]);
141 (-2*%pi+2*%e+sqrt(5)-39)*x^2*y^2+2*(-2*%pi+%e-39)*(1-x)*x*y^2+(-2*%pi-39)*(1-x)^2*y^2+2*(2*%e+sqrt(5)-83/2)*x^2*(1-y)*y
142 +4*(%e-83/2)*(1-x)*x*(1-y)*y-83*(1-x)^2*(1-y)*y+(2*%e+sqrt(5)-42)*x^2*(1-y)^2+2*(%e-42)*(1-x)*x*(1-y)^2-42*(1-x)^2*(1-y)^2$
145 -2*%pi*y^2+2*y^2+y+sqrt(5)*x^2+2*%e*x-42$
147 (forget(k+1 > 0), remvalue(q),0);