@c -----------------------------------------------------------------------------
@c File     : opsubst.de.texi
@c License  : GNU General Public License (GPL)
@c Language : German
@c Original : obsubst.texi revision 28.11.2007
@c Date     : 08.11.2010
@c Revision : 20.08.2011
@c 
@c This file is part of Maxima -- GPL CAS based on DOE-MACSYMA
@c -----------------------------------------------------------------------------

@menu
* Functions and Variables for opsubst::
@end menu

@c -----------------------------------------------------------------------------
@node Functions and Variables for opsubst,  , opsubst, opsubst
@section Functions and Variables for opsubst
@c -----------------------------------------------------------------------------

@c -----------------------------------------------------------------------------
@anchor{function_opsubst}
@deffn  {Function} opsubst (@var{f}, @var{g}, @var{e})
@deffnx {Function} opsubst (@var{g} = @var{f}, @var{e})
@deffnx {Function} opsubst ([@var{g1} = @var{f1}, @var{g2} = @var{f2}, @dots{}, @var{gn} = @var{fn}], @var{e})

The function @code{opsubst} is similar to the function @code{subst}, except that
@code{opsubst} only makes substitutions for the operators in an expression.  In
general, when @var{f} is an operator in the expression @var{e}, substitute
@var{g} for @var{f} in the expression @var{e}.

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

To use this function write first @code{load("opsubst")}.

Examples:

@example
(%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)
@end example

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

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

The internal representation of @code{-a*b} is @code{*(-1,a,b)}; thus

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

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

@example
(%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);
@end example

However, subscripted operators are allowed:

@example
(%i13) opsubst(g[5], f, f(x));
(%o13)                     g (x)
                            5
@end example
@end deffn

@c --- End of file opsubst.de.texi ---------------------------------------------

