Symbolic object generation


TOOLBOXES FUNCTIONS


The function sym creates symbolic objects (sym-objects) and transforms constant, string, polynomial and rational objects to sym-objects.

Symbolic atoms (e.g., a and b below) are complex by default (at least for versions of Maxima higher than 5.9.3). It is possible to declare one of the following types for symbolic variables: even, odd, integer, rational, irrational, real, imaginary, complex (see also function syms).

// Symbolic objects from atoms (slow)

   a = sym('a');
   b = sym('b','real');
   M = [a*b*a*b 1/(1/a);cos(-a)^2-1 0]

   M  =

   !a^2*b^2     a  !
   !               !
   !cos(a)^2-1  0  !

// Symbolic objects from strings (much faster)

   str = ['a*b*a*b' '1/(1/a)';'cos(-a)^2-1' '0'];
   M = sym(str)

   M  =

   !a^2*b^2     a  !
   !               !
   !cos(a)^2-1  0  !

// Alternatively

   str = '[a*b*a*b 1/(1/a);cos(-a)^2-1 0]';
   M = sym(str);

Now are presented some hidden conversions performed by the function sym

// Mixture of constant, sym, string, polynomial and rational objects

   s = poly(0,'s');
   a = sym('a');
   M = [1/s a+1;'s'*a*(1/s) a*s]

   M  =

   !1/s  a+1  !
   !          !
   !a    a*s  !

The function syms is a shortcut for defining 1-by-1 real sym-objects

   syms a b real
   c = a + %i*b;
   symtype(a)

   ans  =

   real

   symtype(c)

   ans  =

   complex

The function findsym identifies symbolic parameters from a symbolic expression.

   P = sym('3*a^3*b^2*c+8*a^2*c-a^2*c');
   params = findsym(P)

   params  =

   !a  c  b  !

The function findsym identifies symbolic parameters from a symbolic expression.

   P = sym('3*a^3*b^2*c+8*a^2*c-a^2*c');
   params = findsym(P)

   params  =

   !a  c  b  !

The function syml defines symbolic lists (syml-objects). These objects are useful only as input arguments of the function maxima.

   equ = syml(['a*x+b*y=3','a*x*y=2']);

   equ  =

   symbolic list -> [b*y+a*x = 3,a*x*y = 2]

TOP