Sponsored links: Algebra eBooks
 

Related

compile-declare-mode_declare

mode_declare(myint,in...

myint:1;

f(x):=myint;

Calculate

compile

load=(sym/compile);

Calculate

compile-define_variable

define_variable(myint...

myint:1;

f(x):=myint;

Calculate

compile-diff-exp-ratsimp-subst

? compile;

dynamalloc:[TRUE];

e(t1,t2):=exp(1/2*(t1...

Calculate

compile-declare-mode_declare

mode_declare(myint,in...

myint:1;

f(x):=myint;

Calculate

compile

load=(sym/compile);

Calculate

compile-define_variable

define_variable(myint...

myint:1;

f(x):=myint;

Calculate

compile-diff-exp-ratsimp-subst

? compile;

dynamalloc:[TRUE];

e(t1,t2):=exp(1/2*(t1...

Calculate

compile

Run Example
(%i1)? compile;

 -- Function: compile (<f_1>, ..., <f_n>)
 -- Function: compile (functions)
 -- Function: compile (all)
     Translates Maxima functions <f_1>, ..., <f_n> into Lisp, evaluates
     the Lisp translations, and calls the Lisp function `COMPILE' on
     each translated function.  `compile' returns a list of the names
     of the compiled functions.

     `compile (all)' or `compile (functions)' compiles all user-defined
     functions.

     `compile' quotes its arguments; the quote-quote operator `'''
     defeats quotation.


  There are also some inexact matches for `compile'.
  Try `?? compile' to see them.

(%o1)                                true
(%i2) dynamalloc:[TRUE];
(%o2)                               [TRUE]
(%i3) e(t1,t2):=exp(1/2*(t1^2*s1^2+2*t1*t2*s12+t2^2*s2^2));
                              1    2   2                   2   2
(%o3)        e(t1, t2) := exp(- (t1  s1  + 2 t1 t2 s12 + t2  s2 ))
                              2
(%i4) diff(e(t1,t2),t1,1,t2,1);
(%o4) 
                                                2   2                   2   2
                                              s2  t2  + 2 s12 t1 t2 + s1  t1
                                              -------------------------------
                2          2                                 2
(2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1) %e
-----------------------------------------------------------------------------
                                      4
           2   2                   2   2
         s2  t2  + 2 s12 t1 t2 + s1  t1
         -------------------------------
                        2
 + s12 %e
(%i5) subst(0,t1,%);
(%o5)             (%i6) subst(0,t2,%);
(%o6)             (%i7) ratsimp(%);
(%o7)             (%i8) diff(e(t1,t2),t1,1,t2,2);
(%o8) 
                                                 2   2                   2   2
                                               s2  t2  + 2 s12 t1 t2 + s1  t1
                                               -------------------------------
                2          2               2                  2
(2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1)  %e
------------------------------------------------------------------------------
                                      8
                                 2   2                   2   2
                               s2  t2  + 2 s12 t1 t2 + s1  t1
                               -------------------------------
            2                                 2
 + s12 (2 s2  t2 + 2 s12 t1) %e
                                 2   2                   2   2
                               s2  t2  + 2 s12 t1 t2 + s1  t1
                               -------------------------------
     2                 2                      2
   s2  (2 s12 t2 + 2 s1  t1) %e
 + -----------------------------------------------------------
                                2
(%i9) subst(0,t1,%);
(%o9)             subst(0,t2,%);
ratsimp(%);
(%o10)            (%i11) diff(e(t1,t2),t1,1,t2,3);
(%o11)            (%i12) (%i12) (%o12) 
                                                 2   2                   2   2
                                               s2  t2  + 2 s12 t1 t2 + s1  t1
                                               -------------------------------
                2          2               3                  2
(2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1)  %e
------------------------------------------------------------------------------
                                      16
                                    2   2                   2   2
                                  s2  t2  + 2 s12 t1 t2 + s1  t1
                                  -------------------------------
              2               2                  2
   3 s12 (2 s2  t2 + 2 s12 t1)  %e
 + --------------------------------------------------------------
                                 4
        2                 2          2
 + (3 s2  (2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2                             2
 %e                               )/4 + 3 s12 s2
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2
 %e
subst(0,t1,%);
subst(0,t2,%);
(%o13)            (%i14) ratsimp(%);
(%o14)            (%i15) diff(e(t1,t2),t1,2,t2,2);
(%o15)            (%i16) subst(0,t1,%);
                        2    2      2               2
(%o16) ((2 s12 t2 + 2 s1  t1)  (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2
 %e                               )/16
                                  2   2                   2   2
                                s2  t2  + 2 s12 t1 t2 + s1  t1
                                -------------------------------
     2      2               2                  2
   s1  (2 s2  t2 + 2 s12 t1)  %e
 + ------------------------------------------------------------
                                4
                                  2   2                   2   2
                                s2  t2  + 2 s12 t1 t2 + s1  t1
                                -------------------------------
     2                 2    2                  2
   s2  (2 s12 t2 + 2 s1  t1)  %e
 + ------------------------------------------------------------
                                4
                       2          2
 + s12 (2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1)
     2   2                   2   2               2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1              s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------             -------------------------------
                  2                    2   2                  2
 %e                                + s1  s2  %e
              2   2                   2   2
            s2  t2  + 2 s12 t1 t2 + s1  t1
            -------------------------------
        2                  2
 + 2 s12  %e
(%i17) subst(0,t2,%);
(%o17)            (%i18) ratsimp(%);
(%o18)            (%i19) diff(e(t1,t2),t1,2,t2,3);
(%o19)            (%i20) subst(0,t1,%);
                        2    2      2               3
(%o20) ((2 s12 t2 + 2 s1  t1)  (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2
 %e                               )/32
                                  2   2                   2   2
                                s2  t2  + 2 s12 t1 t2 + s1  t1
                                -------------------------------
     2      2               3                  2
   s1  (2 s2  t2 + 2 s12 t1)  %e
 + ------------------------------------------------------------
                                8
                          2          2               2
 + (3 s12 (2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2                          2                 2    2
 %e                               )/4 + (3 s2  (2 s12 t2 + 2 s1  t1)
                           2   2                   2   2
                         s2  t2  + 2 s12 t1 t2 + s1  t1
                         -------------------------------
      2                                 2
 (2 s2  t2 + 2 s12 t1) %e                               )/8
                                       2   2                   2   2
                                     s2  t2  + 2 s12 t1 t2 + s1  t1
                                     -------------------------------
       2   2      2                                 2
   3 s1  s2  (2 s2  t2 + 2 s12 t1) %e
 + -----------------------------------------------------------------
                                   2
                                    2   2                   2   2
                                  s2  t2  + 2 s12 t1 t2 + s1  t1
                                  -------------------------------
        2      2                                 2
 + 3 s12  (2 s2  t2 + 2 s12 t1) %e
                                       2   2                   2   2
                                     s2  t2  + 2 s12 t1 t2 + s1  t1
                                     -------------------------------
           2                 2                      2
 + 3 s12 s2  (2 s12 t2 + 2 s1  t1) %e
(%i21) subst(0,t2,%);
(%o21)            (%i22) ratsimp(%);
(%o22)            (%i23) diff(e(t1,t2),t1,3,t2,3);
(%o23)            (%i24) subst(0,t1,%);
                        2    3      2               3
(%o24) ((2 s12 t2 + 2 s1  t1)  (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2                           2                 2
 %e                               )/64 + (3 s1  (2 s12 t2 + 2 s1  t1)
                            2   2                   2   2
                          s2  t2  + 2 s12 t1 t2 + s1  t1
                          -------------------------------
      2               3                  2
 (2 s2  t2 + 2 s12 t1)  %e                               )/16
                          2    2      2               2
 + (9 s12 (2 s12 t2 + 2 s1  t1)  (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2
 %e                               )/16
                                        2   2                   2   2
                                      s2  t2  + 2 s12 t1 t2 + s1  t1
                                      -------------------------------
       2          2               2                  2
   9 s1  s12 (2 s2  t2 + 2 s12 t1)  %e
 + ------------------------------------------------------------------
                                   4
                                        2   2                   2   2
                                      s2  t2  + 2 s12 t1 t2 + s1  t1
                                      -------------------------------
           2                 2    2                  2
   9 s12 s2  (2 s12 t2 + 2 s1  t1)  %e
 + ------------------------------------------------------------------
                                   4
        2                 2    3      2
 + (3 s2  (2 s12 t2 + 2 s1  t1)  (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2                           2   2                 2
 %e                               )/16 + (9 s1  s2  (2 s12 t2 + 2 s1  t1)
                           2   2                   2   2
                         s2  t2  + 2 s12 t1 t2 + s1  t1
                         -------------------------------
      2                                 2
 (2 s2  t2 + 2 s12 t1) %e                               )/4
         2                 2          2
 + (9 s12  (2 s12 t2 + 2 s1  t1) (2 s2  t2 + 2 s12 t1)
     2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------
                  2                         2       2
 %e                               )/2 + 9 s1  s12 s2
     2   2                   2   2              2   2                   2   2
   s2  t2  + 2 s12 t1 t2 + s1  t1             s2  t2  + 2 s12 t1 t2 + s1  t1
   -------------------------------            -------------------------------
                  2                       3                  2
 %e                                + 6 s12  %e
(%i25) subst(0,t2,%);
(%o25)            (%i26) ratsimp(%);
(%o26)            (%i27) 
Run Example
? compile;

 -- Function: compile (<f_1>, ..., <f_n>)
 -- Function: compile (functions)
 -- Function: compile (all)
     Translates Maxima functions <f_1>, ..., <f_n> into Lisp, evaluates
     the Lisp translations, and calls the Lisp function `COMPILE' on
     each translated function.  `compile' returns a list of the names
     of the compiled functions.

     `compile (all)' or `compile (functions)' compiles all user-defined
     functions.

     `compile' quotes its arguments; the quote-quote operator `'''
     defeats quotation.


  There are also some inexact matches for `compile'.
  Try `?? compile' to see them.

(%o1)                                true
(%i2) 
Run Example
kill(all);
(%o0)                                done
(%i1) f(z):=z^3+(4*z^2)+(5*z)+4;
                                   3      2
(%o1)                     f(z) := z  + 4 z  + 5 z + 4
(%i2) ratsimp(z-((2*f(z)*diff(f(z),z,1))/(2*(diff(f(z),z,1)^2)-(f(z)*diff(f(z),z,2)))));
                      5       4       3       2
                   3 z  + 12 z  + 11 z  - 24 z  - 48 z - 20
(%o2)              ----------------------------------------
                          4       3       2
                       6 z  + 32 z  + 63 z  + 48 z + 9
(%i3) g(z):=(3*z^5+12*z^4+11*z^3-24*z^2-48*z-20)/(6*z^4+32*z^3+63*z^2+48*z+9);
                      5       4       3           2
                   3 z  + 12 z  + 11 z  + (- 24) z  + (- 48) z - 20
(%o3)      g(z) := ------------------------------------------------
                              4       3       2
                           6 z  + 32 z  + 63 z  + 48 z + 9
(%i4) niter:25;
(%o4)                                 25
(%i5) cores:[-15,24,-9];
(%o5)                           [- 15, 24, - 9]
(%i6) a:-1;
(%o6)                                 - 1
(%i7) b:1;
(%o7)                                  1
(%i8) c:-1;
(%o8)                                 - 1
(%i9) d:1;
(%o9)                                  1
(%i10) npuntos:150;
(%o10)                                150
(%i11) fractal(x,y):=block([zz:x+%i*y,nn:1], while (nn<
niter and abs(f(rectform(zz)))>
0.001) do (zz:g(rectform(zz)),nn:nn+1),nn ) ;
(%o11) fractal(x, y) := block([zz : x + %i y, nn : 1], 
while (nn < niter) and (abs(f(rectform(zz))) > 0.001) do (zz : 
g(rectform(zz)), nn : nn + 1), nn)
(%i12) compile(fractal);

Warning-> niter is an undefined global variable.
Compiling /tmp/gazonk_7537_0.lsp.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=2, Space=3, Speed=3
Finished compiling /tmp/gazonk_7537_0.lsp.
(%o12)                             [fractal]
(%i13) wxdraw3d(xu_grid=npuntos,yv_grid=npuntos,palette = cores, enhanced3d = [z,x,y,z],  user_preamble = "set pm3d map",explicit(fractal,x,a,b,y,c,d));
(%o13) wxdraw3d(xu_grid = 150, yv_grid = 150, palette = [- 15, 24, - 9], 
enhanced3d = [z, x, y, z], user_preamble = set pm3d map, 
explicit(fractal, x, - 1, 1, y, - 1, 1))
(%i14) 

Related Help

Help for Compile