Comandos Úteis e Simples
Seção 2.1: Simplificação
Session 2.1.2: collect
| > | p := 1 + x + 3 + 5*x + 6*y + 17*y^2 + 35*x + 52*x^2 + 99*x*y + (x+y)^3; |
| > | collect( p, x ); |
| > | collect( p, y ); |
| > | collect( p, [x,y] ); |
| > | collect( p, [x,y], distributed ); |
| > | restart; |
| > | Logistic := x -> diff(x,t) - x*(1-x); |
Think of $v$ as $x_n$.
| > | alias(w = v + h*v*(1-v)); |
The following is the cubic Hermite interpolant between v and w, which is the value of the Euler step from v.
| > | interpolant := v + t*v*(1-v) + (v*(1-v) - w*(1-w))/h^2*t^2*(h-t); |
| > | eval( interpolant, t=0 ); |
| > | eval( interpolant, t=h ); |
| > | eval( diff(interpolant, t), t=0); |
| > | eval( diff(interpolant, t), t=h ); |
| > | defect := Logistic( interpolant ); |
| > | simpler := collect( eval(defect,t=theta*h), h, factor ); |
| > | series( simpler, h, 3 ); |
| > | restart; |
| > | currentdir("C:/books/ess/programs"); |
| > | read "veil.mpl"; |
| > | K := table(); |
| > | VK := LEM( K ): |
Warning, label K is assigned a value already.
Save its contents and issue the command unassign( K );
There is no need to repeat the call to LEM.
| > | unassign( K ): |
| > | VC := LEM( C ): |
| > | p1 := sort( randpoly( [x,y,z], dense, degree=7 ) ); |
| > | compact1 := collect( p1, [x,y], distributed, VK:-veil ); |
| > | K[1] = VK:-unveil( K[1] ); |
| > | K[2] = VK:-unveil( K[2] ); |
| > | zero := VK:-unveil( compact1, infinity ) - p1: |
| > | normal( zero ); |
| > | p2 := sort( randpoly( [r,ln(r),Y], dense, degree=6 ) ); |
| > | compact2 := collect( p2, [r,ln(r)], distributed, VC:-veil ); |
| > | zero := VC:-unveil( compact2 ) - p2: |
| > | expand( zero ); |
| > | p3 := sort( randpoly( [x,y,z,r,ln(r)], dense, degree=3 ) ); |
| > | compact3 := collect( p3, [x,y], distributed, VK:-veil ); |
| > | compact4 := collect( compact3, [y], VC:-veil ); |
| > | VC:-unveil( C[22] ); |
| > | VK:-unveil( K[32] ); |
| > | L := [seq( K[i]=VK:-unveil(K[i]), i=29..34 )]; |
| > | codegen[fortran](L,optimized); |
t2 = log(r)
t3 = r*t2
t5 = z**2
t9 = r*z
t11 = r**2
t14 = t2**2
t20 = z*t2
K(29) = 63+31*r+52*t3-24*t5*z+95*z+19*t9-18*t11*t2+65*t14*t2+95*t1
#1*r+85*t5+60*t20-24*t2+46*t14-67*t9*t2-20*r*t14-36*t5*t2+46*t11+35
#*t11*z-63*r*t5
K(30) = -68*t3+65*r-39-66*t5+62*t9-68*z-43*t14+67*t11-40*t20-6*t2
t48 = 95*t2
K(31) = -63-8*t9+44*t20-81*t5-34*r+t48+80*z-23*t3+81*t14+5*t11
t53 = 8*z
K(32) = t53+93*t2+20*r+45
K(33) = -44+18*t2+95*r-t53
K(34) = 36*r-8+t48-98*z
| > | codegen[C](L,optimized); |
t2 = log(r);
t3 = r*t2;
t5 = z*z;
t9 = r*z;
t11 = r*r;
t14 = t2*t2;
t20 = z*t2;
K[28] = 63.0+31.0*r+52.0*t3-24.0*t5*z+95.0*z+19.0*t9-18.0*t11*t2+65.0*t14
*t2+95.0*t11*r+85.0*t5+60.0*t20-24.0*t2+46.0*t14-67.0*t9*t2-20.0*r*t14-36.0*t5*
t2+46.0*t11+35.0*t11*z-63.0*r*t5;
K[29] = -68.0*t3+65.0*r-39.0-66.0*t5+62.0*t9-68.0*z-43.0*t14+67.0*t11
-40.0*t20-6.0*t2;
t48 = 95.0*t2;
K[30] = -63.0-8.0*t9+44.0*t20-81.0*t5-34.0*r+t48+80.0*z-23.0*t3+81.0*t14+
5.0*t11;
t53 = 8.0*z;
K[31] = t53+93.0*t2+20.0*r+45.0;
K[32] = -44.0+18.0*t2+95.0*r-t53;
K[33] = 36.0*r-8.0+t48-98.0*z;
| > |
| > |
| > |