Sponsored links: Algebra eBooks
 

Related

return

a:[1, 2, 3, 4];

for m in a do buildq(...

Calculate

return

list:[1, 2, false, 3,...

for i in list do (n:[...

Calculate

return

a:[1, 2, 3, 4];

for m in a do buildq(...

Calculate

return

list:[1, 2, false, 3,...

for i in list do (n:[...

Calculate

return

Run Example
(%i1)remvalue(n,z);
(%o1)                           [false, false]
(%i2) matchdeclare(a,lambda([x],freeof(x,n)));
(%o2)                                done
(%i3) matchdeclare(b,lambda([x],freeof(x,n) and integerp(x) and x>
0));
(%o3)                                done
(%i4) matchdeclare(f,all);
(%o4)                                done
(%i5) matchdeclare(g,lambda([x],freeof(n-1,x)));
(%o5)                                done
(%i6) defrule(r1,zt(1,n,z),z/(z-1));
                                                 z
(%o6)                      r1 : zt(1, n, z) -> -----
                                               z - 1
(%i7) defrule(r2,zt(n,n,z),z/(z-1)^2);
                                                z
(%o7)                    r2 : zt(n, n, z) -> --------
                                                    2
                                             (z - 1)
(%i8) defrule(r3,zt(1/n,n,z),log(z/(z-1)));
                                1                 z
(%o8)                   r3 : zt(-, n, z) -> log(-----)
                                n               z - 1
(%i9) defrule(r4,zt(a^n,n,z),z/(z-a));
                                   n             z
(%o9)                     r4 : zt(a , n, z) -> -----
                                               z - a
(%i10) defrule(r5,zt(a^(n-1),n,z),1/(z-a));
                                 n - 1             1
(%o10)                  r5 : zt(a     , n, z) -> -----
                                                 z - a
(%i11) defrule(r6,zt(binomial(n,b),n,z),z/(z-1)^(b+1));
                                                       - b - 1
(%o11)         r6 : zt(binomial(n, b), n, z) -> (z - 1)        z
(%i12) defrule(r7,zt(n^b,n,z),block([tmp:z/(z-1)],  for i:1 thru b do tmp:-z*diff(tmp,z),  factor(tmp)));
                b                          z
(%o12) r7 : zt(n , n, z) -> block([tmp : -----], 
                                         z - 1
                           for i thru b do tmp : - diff(tmp, z) z, factor(tmp))
(%i13) defrule(r8,zt(sin(a*n),n,z),z*'sin(a)/((z^2-2*z*'cos(a)+1)));
                                                sin(a) z
(%o13)          r8 : zt(sin(a n), n, z) -> -------------------
                                            2
                                           z  - 2 cos(a) z + 1
(%i14) defrule(r9,zt(cos(a*n),n,z),z*(z-'cos(a))/(z^2-2*z*'cos(a)+1));
                                             z (z - cos(a))
(%o14)          r9 : zt(cos(a n), n, z) -> -------------------
                                            2
                                           z  - 2 cos(a) z + 1
(%i15) defrule(r10,zt(kron_delta(b,n),n,z),1/z^b);
                                                        1
(%o15)              r10 : zt(kron_delta(b, n), n, z) -> --
                                                         b
                                                        z
(%i16) defrule(r11,zt(a^n*f,n,z),'subst(z/a,z,ztrans(f,n,z)));
                     n                        z
(%o16)     r11 : zt(a  f, n, z) -> substitute(-, z, ztrans(f, n, z))
                                              a
(%i17) defrule(r12,zt(n^b*g,n,z),block([tmp:ztrans(g,n,z)],  for i:1 thru b do tmp:-z*'diff(tmp,z),  return(tmp)));
                   b
(%o17) r12 : zt(g n , n, z) -> block([tmp : ztrans(g, n, z)], 
                                                           dtmp
                                   for i thru b do tmp : - ---- z, return(tmp))
                                                            dz
(%i18) defrule(r13,zt(exp(-a*n),n,z),z/(z-exp(-a)));
                                - a n               z
(%o18)               r13 : zt(%e     , n, z) -> ---------
                                                      - a
                                                z - %e
(%i19) defrule(r14,zt(f(n-m),n,z),z^(-m)*ztrans(f(n),n,z));
                                            ztrans(f(n), n, z)
(%o19)          r14 : zt(f(n - m), n, z) -> ------------------
                                                     m
                                                    z
(%i20) declare(zt,linear);
(%o20)                               done
(%i21) ztrans1(e):=apply1(e,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14);
(%o21) ztrans1(e) := apply1(e, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, 
                                                                 r12, r13, r14)
(%i22) ztrans(f,n,z):=ev(ztrans1(zt(f,n,z)),diff,subst);
(%o22)     ztrans(f, n, z) := ev(ztrans1(zt(f, n, z)), diff, subst)
(%i23) defrule(ir1,izt(z/(z-a),z,n),a^n);
                                     z              n
(%o23)                   ir1 : izt(-----, z, n) -> a
                                   z - a
(%i24) defrule(ir2,izt(1/(z-a),z,n),a^(n-1));
                                   1              n - 1
(%o24)                 ir2 : izt(-----, z, n) -> a
                                 z - a
(%i25) declare(izt,linear);
(%o25)                               done
(%i26) invztrans1(e):=apply1(e,ir1,ir2);
(%o26)               invztrans1(e) := apply1(e, ir1, ir2)
(%i27) invztrans(f,z,n):=invztrans1(izt(f,z,n));
(%o27)          invztrans(f, z, n) := invztrans1(izt(f, z, n))
(%i28) ztrans(1,n,z);
                                       z
(%o28)                               -----
                                     z - 1
(%i29) ztrans(a,n,z);
                                      a z
(%o29)                               -----
                                     z - 1
(%i30) expand(ztrans((-1)^n,n,z));
                                       z
(%o30)                               -----
                                     z + 1
(%i31) ztrans(n,n,z);
                                      z
(%o31)                             --------
                                          2
                                   (z - 1)
(%i32) ztrans(n^2,n,z);
                                   z (z + 1)
(%o32)                             ---------
                                          3
                                   (z - 1)
(%i33) ztrans(a^(n-1),n,z);
                                       1
(%o33)                               -----
                                     z - a
(%i34) factor(ztrans(a^(n-1)+n^2,n,z));
                         3      2      2
                      2 z  - a z  - 2 z  - a z + 3 z - 1
(%o34)                ----------------------------------
                                      3
                               (z - 1)  (z - a)
(%i35) 
Run Example
numer:true;
(%o1)                                true
(%i2) ln(x):=log(x)/log(%e);
                                        log(x)
(%o2)                          ln(x) := -------
                                        log(%e)
(%i3) redondeo(num,decimales):=block(       [a:0],   a:round(num*10^decimales)*10^-decimales,    return(a));
(%o3) redondeo(num, decimales) := block([a : 0], 
                                           decimales    - decimales
                          a : 'round(num 10         ) 10           , return(a))
(%i4) biseccion(a,b,expo,N):=block(       [indice:0,bool:true,fa,fp,fb,fafp,TOL,p,er,tabla:matrix(['N,'a,'b,'p,'f('a),'f('b),'f('p),'f('a)*'f('p),'error])],      fa:f(a),   fa:redondeo(fa,expo+2),   TOL:(10)^(-expo),   for i:1 step 1 while (i<
=N and bool=true) do   (      indice:i,      p:((a+b)/2),         p:redondeo(p,expo+2),      fp:f(p),         fp:redondeo(fp,expo+2),      fb:f(b),         fb:redondeo(fb,expo+2),      er:((b-a)/2),         er:redondeo(er,expo+2),      fafp:redondeo(fa*fp,expo+2),            if ( (fa<
0 and fb<
0) or (fa>
0 and fb>
0) ) then      (	           print("No hay cambio de signo"),	 bool:false      ),      tabla:addrow(tabla,[i,a,b,p,fa,fb,fp,fafp,er]),            if ((fp=0) or (er <
 TOL)) then      (         print("tolerancia cumplida"),	 bool:false      )      elseif (fafp>
0) then      (         a:p,         fa:fp      )      else      (         b:p      )   ),      if (indice=N) then    (      print(concat("Parametro N=",N," se cumplio. Hay cambios de signo f(a) f(b)")),      print("en las iteraciones hechas.")   ),   display(indice,N),   return(tabla));
(%o4) biseccion(a, b, expo, N) := block([indice : 0, bool : true, fa, fp, fb, 
fafp, TOL, p, er, tabla : matrix(['N, 'a, 'b, 'p, 'f('a), 'f('b), 'f('p), 
'f('a) 'f('p), 'error])], fa : f(a), fa : redondeo(fa, expo + 2), 
        - expo
TOL : 10      , for i while (i <= N) and (bool = true) 
                    a + b
do (indice : i, p : -----, p : redondeo(p, expo + 2), fp : f(p), 
                      2
fp : redondeo(fp, expo + 2), fb : f(b), fb : redondeo(fb, expo + 2), 
     b - a
er : -----, er : redondeo(er, expo + 2), fafp : redondeo(fa fp, expo + 2), 
       2
if ((fa < 0) and (fb < 0)) or ((fa > 0) and (fb > 0))
 then (print("No hay cambio de signo"), bool : false), 
tabla : addrow(tabla, [i, a, b, p, fa, fb, fp, fafp, er]), 
if (fp = 0) or (er < TOL) then (print("tolerancia cumplida"), bool : false)
 elseif fafp > 0 then (a : p, fa : fp) else b : p), 
if indice = N then (print(concat("Parametro N=", N, 
" se cumplio. Hay cambios de signo f(a) f(b)")), 
print("en las iteraciones hechas.")), display(indice, N), return(tabla))
(%i5) f(x):=x-2^-x;
                                            - x
(%o5)                          f(x) := x - 2
(%i6) biseccion(0,1,3,3);
Parametro N=3 se cumplio. Hay cambios de signo f(a) f(b) 
en las iteraciones hechas. 
                                  indice = 3

                                     N = 3

      [ N   a    b      p      f(a)      f(b)     f(p)     f(a) f(p)  error ]
      [                                                                     ]
      [ 1   0    1     0.5     - 1.0     0.5    - 0.20711   0.20711    0.5  ]
(%o6) [                                                                     ]
      [ 2  0.5   1    0.75   - 0.20711   0.5     0.1554    - 0.03218  0.25  ]
      [                                                                     ]
      [ 3  0.5  0.75  0.625  - 0.20711  0.1554  - 0.02342   0.00485   0.125 ]
(%i7) 
Run Example
show(L)::=block([simp:false], simp:false, buildq([L], first([L[1]/L[2]])));
                                                                         L
                                                                          1
(%o1) show(L) ::= block([simp : false], simp : false, buildq([L], first([--])))
                                                                         L
                                                                          2
(%i2) show([0, 1]), simp:false;
                                       0
(%o2)                                  -
                                       1
(%i3) L:[0, 1];
(%o3)                               [0, 1]
(%i4)  R:[1, 0];
(%o4)                               [1, 0]
(%i5) k:[L, L+R, R];
(%o5)                      [[0, 1], [1, 1], [1, 0]]
(%i6) show(L), simp:false;
                                       0
(%o6)                                  -
                                       1
(%i7) show(R), simp:false;
                                       1
(%o7)                                  -
                                       0
(%i8) show(L+R), simp:false;
                                       1
(%o8)                                  -
                                       1
(%i9) h:[];
(%o9)                                 []
(%i10) block([m:[]], for i in k do (append(m, [show(i)]), return(m))), simp:false;
(%o10)                                []
(%i11) 
[abs,append,args,block,return,rhs,sin] [abs,block,display,fpprec,fpprintprec,return] [addrow,append,block,copylist,copymatrix,delete,error,hipow,length,makelist,print,resultant,return,row,submatrix] [addrow,block,concat,display,false,if,log,matrix,numer,print,return,round,true,while] [addrow,block,concat,false,if,log,matrix,numer,print,return,round,true,while] [append,args,block,return,rhs,sin] [append,atom,block,delete,flatten,if,lambda,load,map,return] [append,block,buildq,first,return,show,simp] [append,block,debugmode,print,return,rhs,true] [append,block,delete,flatten,lambda,length,makelist,map,return] [append,block,do,expand,hipow,length,makelist,part,print,product,rat,return,sqrt,unique] [append,block,do,flatten,load,makelist,return] [append,block,do,length,makelist,return] [append,block,do,load,makelist,return] [append,block,length,makelist,return] [append,block,length,return] [append,block,listify,makelist,primep,rest,return,setify] [append,block,listify,makelist,primep,return,setify] [apply,args,block,col,copymatrix,do,genmatrix,map,mod,quotient,return,transpose] [apply1,binomial,block,cos,defrule,delta,diff,ev,exp,factor,freeof,kron_delta,lambda,linear,log,matchdeclare,remvalue,return,sin,subst] [atom,block,expand,false,length,part,print,return,sqrt] [bern,bfloat,block,fpprec,makelist,numer,return,sum] [bfloat,bftorat,block,emptyp,equal,first,fpprec,if,is,mod,not,numer,ratepsilon,ratprint,return,round] [bfloat,bftorat,block,emptyp,first,fpprec,if,mod,not,numer,ratepsilon,ratprint,return] [bfloat,bftorat,block,ev,float2bf,makelist,mod,ratepsilon,ratprint,return] [bfloat,bftorat,block,float2bf,makelist,mod,ratepsilon,ratprint,return] [bftorat,block,cons,delete,do,emptyp,first,float2bf,fpprec,lambda,last,listp,map,mod,ratepsilon,ratprint,rest,return] [bftorat,block,cons,delete,emptyp,false,first,float2bf,fpprec,if,integerp,kill,lambda,listp,map,mod,ratdenom,ratepsilon,ratprint,rest,return] [bftorat,block,emptyp,equal,first,float,fpprec,if,is,mod,not,numer,ratepsilon,ratprint,return,round] [bftorat,block,emptyp,first,float,fpprec,if,integerp,mod,not,numer,ratepsilon,ratprint,return] [bftorat,block,ev,false,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,false,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [bftorat,block,float2bf,fpprec,if,integerp,mod,ratdenom,ratepsilon,ratprint,return] [binomial,block,ceiling,diff,expand,ratsubst,return,sum] [binomial,block,delta,determinant,do,expand,genmatrix,hipow,kron_delta,makelist,part,print,return,subst] [binomial,block,delta,determinant,do,expand,genmatrix,kron_delta,return] [binomial,block,genmatrix,return] [block,concat,do,kill,makelist,obase,return,stringdisp,true,while] [block,concat,do,kill,makelist,obase,return,while] [block,denom,equal,ev,fullratsimp,lhs,maplist,return,rhs,trigexpand] [block,display,fpprec,fpprintprec,jacobi,printf,return] [block,display,fpprec,fpprintprec,return] [block,do,endcons,plot2d,return] [block,do,mod,return,while] [block,endcons,floor,plot2d,return] [block,length,map,matrix,print,return] [block,print,return] [block,return] [do,evenp,first,if,lambda,makelist,map,return,setify,subset] [do,float,if,print,return]

Related Help

Help for Return