algsubs - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Substitution : algsubs

algsubs

substitute subexpressions into an expression

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

algsubs(a = b, f)

algsubs(a = b, f, v)

algsubs(a = b, f, v, options)

Parameters

a, b

-

algebraic expressions

f

-

any expression

v

-

name or list or set of names

Description

• 

The function algsubs performs an algebraic substitution, replacing occurrences of a with b in the expression f.  It is a generalization of the subs command, which only handles syntactic substitution. The purpose of algsubs can be seen from these five examples where subs fails.

algsubs( s^2=1-c^2, s^3 );

c2+1s

(1)

algsubs( a+b=d, 1+a+b+c );

1+d+c

(2)

algsubs( a*b=c, 2*a*b^2-a*b*d );

2bccd

(3)

algsubs( a*b/c=d, 2*a*b^2/c );

2db

(4)

algsubs( a^2=0, exp(2-a+a^2/2-a^3/6) );

ⅇ2a

(5)
• 

Where the expression being replaced has more than one variable, the result is ambiguous. For example, should algsubs(a+b=c, 2*a+b) return 2cb or a+c? What should algsubs(a+b=c, a+Pi*b) return? Should algsubs(x*y^2=c, x*y^4) return cy2 or c2x? The algsubs command provides two modes for breaking ambiguities, an exact mode and a remainder mode (the default).

  

Both modes depend on the ordering of the variables that appear in a. This can be set to a specific ordering by specifying the variables v in a list as a third argument. If the variables are not explicitly given, the set of indeterminates in a, b which are functions and names defines the variables and their order. Also, the result is collected in the variables given.

  

Both modes require that monomials in a divide monomials in f for a substitution to occur. A monomial u in a divides a monomial v in f if for each variable x in u, then either 0<degreeu,xdegreev,x or degreev,xdegreeu,x<0.

  

For example, the monomial x2y2 divides the monomial x3y2 but not xy2 or x2y.

  

Note: The algsubs command currently works only with integer exponents.

  

Note that the requirement for monomials in a to divide monomials in f means that the negative powers of u in the following example are not substituted, and must be handled separately as shown.

f := a/u^4+b/u^2+c+d*u^2+e*u^4;

f:=au4&plus;bu2&plus;c&plus;du2&plus;eu4

(6)

algsubs(u^2=v,f);

ev2&plus;dv&plus;c&plus;bu2&plus;au4

(7)

algsubs(1/u^2=1/v,f);

eu4&plus;du2&plus;cv2&plus;bv&plus;av2

(8)
  

Hence, to substitute for both positive and negative powers.

algsubs(u^2=v,algsubs(1/u^2=1/v,f));

ev4&plus;dv3&plus;cv2&plus;bv&plus;av2

(9)
• 

If the option remainder is specified, or no option is specified, a generalized remainder is computed. If the leading monomial of a divides the leading monomial of f then the leading monomial of f is replaced with the appropriate value, and this is repeated until the leading monomial in f is less than the leading monomial in a.

• 

If the option exact is specified, then if the value a being replaced is a sum of terms ai, and the value f it is replacing is the sum of terms fi, then the replacement is made if and only if each monomial ai divides fi and ai&equals;cfi that is, the coefficients must all be the same. For example, algsubs( x^2+2*y=z, 3*x^2+6*y ) succeeds with c&equals;3 but algsubs(x^2+2*y=z, 3*x^2+3*y) fails.

• 

The algsubs command goes recursively through the expression f. Unlike the subs command it does not substitute inside indexed names, and function calls are applied to the result of a substitution. Like subs, it does not expand products or powers before substitution. Hence algsubs( x^2=0, (x+1)^3 ) yields x&plus;13.

Examples

algsubsa&plus;b&equals;c&comma;&ExponentialE;a&plus;b&plus;d

&ExponentialE;c&plus;d

(10)

algsubsPVT&equals;R&comma;P2VT2PR

PR&plus;RPT

(11)

algsubss&plus;1t&equals;y&comma;s&plus;1t&plus;13s2t

y&plus;131ty

(12)

fsinx3cosxsinx2&plus;cosx2sinx&plus;cosx3

f:=sinx3cosxsinx2&plus;cosx2sinx&plus;cosx3

(13)

algsubssinx2&equals;1cosx2&comma;f

2cosx3&plus;sinxcosx

(14)

Truncating polynomials

fexpandu&plus;w1w3

f:=u3&plus;3u2w3u2w&plus;3uw26u&plus;3uw2&plus;w33w&plus;3w1w3

(15)

algsubsu2&equals;0&comma;f

w63w4&plus;3w21w3&plus;3w42w2&plus;1uw2

(16)

algsubsu2&equals;0&comma;f&comma;u&comma;w

3uw26u&plus;3uw2&plus;w33w&plus;3w1w3

(17)

algsubs1w2&equals;0&comma;f&comma;u&comma;w

u3&plus;3u2w3u2w&plus;3uw26u&plus;w33w&plus;3w

(18)

algsubsuw&equals;0&comma;f

u33u2w6u&plus;3uw2&plus;w33w&plus;3w1w3

(19)

algsubsuw&equals;0&comma;f

u3&plus;3u2w&plus;3uw26u&plus;w33w&plus;3w1w3

(20)

Ambiguous cases

f2a&plus;b

f:=2a&plus;b

(21)

algsubsa&plus;b&equals;c&comma;f&comma;a&comma;b

2cb

(22)

algsubsa&plus;b&equals;c&comma;f&comma;b&comma;a

a&plus;c

(23)

algsubsa&plus;b&equals;c&comma;f&comma;exact

2a&plus;b

(24)

fa1&plus;a21xa1&plus;a2&plus;a1ya1&plus;a2a2a1&plus;a2z

f:=a1&plus;a21xa1&plus;a2&plus;a1ya1&plus;a2a2a1&plus;a2z

(25)

algsubsa1&plus;a2&equals;p&comma;f

xp1p&plus;ya2&plus;ppa2pz

(26)

algsubsa1&plus;a2&equals;p&comma;f&comma;exact

xp1p&plus;ya1pa2pz

(27)

See Also

applyrule

simplify

simplify/siderels

subs

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam