# Items tagged with expandexpand Tagged Items Feed

October 08 2015
0 1

### Rearranging the “expression of equations”: Further...

October 05 2015
1
0

A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

Before I begin, a quick note that the content below was primarily created by one of our summer interns, Pia, with guidance and advice from me.

The Question: Rearranging the expression of equations

SY G wanted to be able to re-write an equation in terms of different variables.  SY G presented this example:

I have the following two equations:

x1 = a-y1-d*y2;
x2 = a-y2-d*y1;

I wish to express the first equation in terms of y1 and x2, so that

x1 = c - b*y1+d*x2;

where c=a-a*d and b=1-d^2. How can I get Maple to rearrange the original equation x1 in term of y1, x2, c and b?

This question was answered by nm who provided code with a systematic approach:

restart;
eq1:=x1=a-y1-d*y2:
eq2:=x2=a-y2-d*y1:
z:=expand(subs(y2=solve(eq2,y2),eq1)):
z:=algsubs((a-a*d)=c,z):
algsubs((1-d^2)=b,z);

On the other hand, Carl Love answered this enquiry using a more direct and simple code:

simplify(x1=a-y1-d*y2, {a-y2-d*y1= x2, 1-d^2= b, a-a*d= c});

Let’s talk more about the expand, algsubs, subs, and simplify commands

First let’s take a look at the method nm used to solve the problem using the commands expand, subs, solve and algsubs.

The expand command, expand(expr, expr1, expr2, ..., exprn), distributes products over sums. This is done for all polynomials. For quotients of polynomials, only sums in the numerator are expanded; products and powers are left alone.

The solve command, solve(equations, variables), solves one or more equations or inequalities for their unknowns.

The subs command, subs(x=a,expr), substitutes a for x in the expression expr.

The function algsubs, algsubs(a = b, f),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.

Let’s tackle the Maple code written by nm step by step:

1) restart;
The restart command is used to clear Maple’s internal memory

2)  eq1:=x1=a-y1-d*y2:
eq2:=x2=a-y2-d*y1:
The names eq1 and eq2 were assigned to the equations SY G provided.

3) z:=expand(subs(y2=solve(eq2,y2),eq1)):
A new variable, z, was created, which will end up being x1 written in the terms SY G wanted.

• solve(eq2,y2)
• the solve command was used to solve the expression eq2 for the variable y2.

• subs(y2=solve(eq2,y2),eq1)
• The subs command was used to replace in expression eq1, y2 as determined by the solve step.

• expand(subs(y2=solve(eq2,y2),eq1))
• The expand command was used to distribute products over sums. Note: this step served to ensure that the final output looked exactly how SY G wanted.

4) z:=algsubs((a-a*d)=c,z):
First, nm equated a-a*d to c, so later the algsubs command could be applied to substitute the new variable c into the expression z.

5) algsubs((1-d^2)=b,z);
Again, nm equated 1-d^2 to b, so later the algsubs command could be applied to substitute the new variable b into the expression z.

An alternate approach

Now let us check out Carl Love’s approach. Carl Love uses the simplify command in conjunction with side relations.

The simplify command has many calling sequences and one of them is the simplify(expr,eqns), that is known as simplify/siderels. A simplification of expr with respect to the side relations eqns is performed. The result is an expression which is mathematically equivalent toexpr but which is in normal form with respect to the specified side relations. Basically you are telling Maple to simplify the expression (expr) using the parameters (eqns) you gave to it.

I hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let me know.

### The collect command does not work...

September 23 2015
0 3

Why does the collect command work for some expressions and not for others. Here is a screen shot

http://prntscr.com/8jps7r

The collect command is supposed to rewrite the expression in terms of the variable descending order.

p := expand((a^2+2*x)*(a^2+2*x));
4      2        2   2
a  + 4 a  x + 4 x

collect(p, x);
4      2        2   2
a  + 4 a  x + 4 x

Does not work.

But if you look at the screenshot , it works for other expressions.

### it possible teach maple not simplify some values...

June 09 2015
0 11

hi  for example to calculate the following

residue((Psi(-z)+Eulergamma)^2*h(z), z = 2)

gives

3*h(2)+(D(h))(2)

but it possible to write

as( Psi(2)+Eulergamma(z))*h(2)+(D(h))(2)

so that

and Psi(z)+Eulergamma== harmonicNumber(z-1)

the result must be

harmonicNumber(2)*h(2)+(D(h))(2)

it is possible that Maple gives explit form of the values function avoid to calculate automatic.

thanks

### expand causing lhs to be zero...

March 03 2015
0 3

I am trying to expand out the terms  of equation 13.  The expand command causes the lhs to be zero?

 (1.1)

 (1.2)

 (1.3)

 (1.4)

 (1.5)

 (1.6)

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

 (9)

 (10)

 (11)

 (12)

 (13)

 (14)

Why does the expand command cause the lhs to be zero?

### Actually evaluate or simplify an algebraic express...

January 18 2015
1 1

When I write in maple the following:

x*(x+y)

What do I need to write to make maple make the operation that will evaluate the expression and show the following?

x^2+x*y

simplify(%) or evaluate(%) only shows it the same way it was inputted to start with.

### how to select terms from one expression into 2 dif...

January 11 2015
2 3

I am trying separation of variables in Maple. I get an equation that has the form

And now I want to tell Maple to assign the terms with 1/R in them to one variable, say eq21, and the term with 1/Z to second variable, say eq22 The idea is that I can later more easily work with each separate ode.

I do not know to separate those apart. I could offcourse copy and paste by hand, but I want to automate this.

I tried match() and patmatch() but I am not seeing the way. Here is the code:

restart;
T:=  (r,z)-> Z(z)*R(r);
eq1:= diff(T(r,z),r\$2)+1/r*diff(T(r,z),r)+diff(T(r,z),z\$2);
eq2:=expand(eq1/(Z(z)*R(r)));

#need now way to break the above into 2 different variables.

ps. I know I can do this:

restart;
T:=  (r,z)-> Z(z)*R(r);
eq1:= diff(T(r,z),r\$2)+1/r*diff(T(r,z),r)+diff(T(r,z),z\$2);
eq2:=expand(eq1/(Z(z)*R(r)));
eq3:=collect(eq2,1/R(r));
eq21:=op(1,eq3);
eq22:=op(2,eq3);

But this for me is not the right way to do it. I think there should be more algebraic way.

### Separate the powers of exponential functions...

November 01 2014
1 4

AOA... How are you all. I need the answer of the following question.

input in Maple: expand(exp(a+b)+exp(c+b))

output:  exp(a)*exp(b)+exp(c)*exp(b)

and

input in Maple: expand(exp(2a+b)+exp(3c+b))

output:  (exp(a))^2*exp(b)+(exp(c))^3*exp(b)

but i need exp(2a)*exp(b)+exp(3c)*exp(b)

PhD (Scholar)
Department of Mathematics

### inconsistency in expanding (a+b)^n...

July 30 2014
0 1

Hi Maple friends.

expand( (a+b)^2 );

a^2+2*a*b+b^2

expand( (a+b)^3 );

a^3+3*a^2*b+3*a*b^2+b^3

expand( (a+4)^4 )

a^4+16*a^3+96*a^2+256*a+256 (???)

Pascal's triangle shows that 'expand( (a+4)^4 )' should have resulted in a^4+4*a^3*b+6*a^2*b^2+4*a*b^3+b^4

Where are the b variables in Maple's solution?

### Expand (a+b)^n in binomial expansion form...

July 26 2014
1 3

expand( (a+b)^n)

convert((a+b)^n,Sum)

none  expands in  binomial  form.  Is there any way for Maple to generate  binomial  expansion of (a+b)^n  without

entering  manually.

martin

### expansion of product of variables...

March 04 2014
0 1

Please tell me how to do about the following problem to me.

g:=(b*y)^k*k*y;

simplify(%);

Then, what I obtained was (b*y)^k*k*y, not (b^k)*k*y^(k+1).

expand of the command brought the same answer not (b^k)*k*y^(k+1).

Please tell me what was wrong to my calculation.

Taro.

### how to evaluate this integral...

January 26 2014
0 1

f:=Intat(1.0000000000000000000*(1.7969454312181156991*_f^1.2+1.80)^1.2/sqrt(-1.4974545260150964159*(8.9847271560905784954*_f^3+14.640368911168931285*_f^2+30.220202497712627297)^1.2), _f = 0);

I tried to use  value(f);  eval(f); simplify(f); expand(f), but non provide an answer, but return an integral unevaluated.

Is there a command to produce a  numerical result ?

### Help to expand rational function...

December 02 2013
2 13

I am trying to expand  a rational function that is in the form:

P(z) = (1 + z1)2 (1 + z)2· (r1z + r0 + r1z1)

to the form:

P(z) = r1z3 + (4r1 + r0)z2 + (7r1 + 4r0)z + (8r1 + 6r0)

+(7r1 + 4r0)z1 + (4r1 + r0)z2 + r1z3

Can someone show me how to do this please?

### why does combine(sin(x)^2) expands the expression?...

November 14 2013
0 6

This is just a question on terminology. The name "combine" implies pulling terms together. Yet, when applied to something like sin(x)^2 it has the effect of expanding it:

r:=sin(x)^2;
combine(r);

Which seems counter-intutive to me. I tried first expand(r) but that did not expand it.

Fyi, in Mathematica the function to do the above is called

Sin[x]^2;
TrigReduce[%]

1/2 (1 - Cos[2 x])

As Mathematica does not have a Combine[] function.

So, I am just wondering about the naming, that is all. I would never have thought first that a command called combine() will expand sin(x)^2.

### Solve Product of Function With some variables...

October 15 2013
2 4

Dear All,

I need your help, what function in Maple must be used to find the different form of this function

into this function

 1 2 3 Page 1 of 3
﻿