[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 75. opsubst

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 75.1 Functions and Variables for opsubst

Function: opsubst
`opsubst` (f,g,e)
`opsubst` (g=f,e)
`opsubst` ([g1=f1,g2=f2,..., gn=fn],e)

  The function `opsubst` is similar to the function `subst`, except that `opsubst` only makes substitutions for the operators in an expression. In general, When f is an operator in the expression e, substitute g for f in the expression e.

  To determine the operator, `opsubst` sets `inflag` to true. This means `opsubst` substitutes for the internal, not the displayed, operator in the expression.

  Examples:

      (%i1) load ("opsubst")$

      (%i2) opsubst(f,g,g(g(x)));
      (%o2)                     f(f(x))
      (%i3) opsubst(f,g,g(g));
      (%o3)                       f(g)
      (%i4) opsubst(f,g[x],g[x](z));
      (%o4)                       f(z)
      (%i5) opsubst(g[x],f, f(z));
      (%o5)                      g (z)
                                  x
      (%i6) opsubst(tan, sin, sin(sin));
      (%o6)                     tan(sin)
      (%i7) opsubst([f=g,g=h],f(x));
      (%o7)                       h(x)

  Internally, Maxima does not use the unary negation, division, or the subtraction operators; thus:

      (%i8) opsubst("+","-",a-b);
      (%o8)                     a - b
      (%i9) opsubst("f","-",-a);
      (%o9)                      - a
      (%i10) opsubst("^^","/",a/b);
                                   a
      (%o10)                       -
                                   b

  The internal representation of -a*b is *(-1,a,b); thus

      (%i11) opsubst("[","*", -a*b);
      (%o11)                  [- 1, a, b]

  When either operator isn't a Maxima symbol, generally some other function will signal an error:

      (%i12) opsubst(a+b,f, f(x));

      Improper name or value in functional position:
      b + a
       -- an error.  Quitting.  To debug this try debugmode(true);

  However, subscripted operators are allowed:

      (%i13) opsubst(g[5],f, f(x));
      (%o13)                     g (x)
                                  5

  To use this function write first `load("opsubst")`.

  Categories: Expressions · Share packages · Package opsubst

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by builduser on June, 8 2018 using texi2html 1.76.