# Question:How to factor out specific parts of expression

## Question:How to factor out specific parts of expression

Maple

Kitonum had provided us the basis for a solution to this question.  I created a proc to make it versatile.
The problem was how to force Maple to display the RHS of :

Here is the proc(I've condensed the variables)

```extract := proc(a, expr)
local f:
f := a:
``(f)*expand(expr/f);
end proc:```

```eq := 1/cao - 1/caa:
extract(1/cao, eq);

```

Now suppose we had an trigonometric expresssion and we extract cos(x) out of it

```expr := cos(x) - sin(x)/(x^2*y) + 3*x*y

bb := extract(cos(x), expr)

```

ok, that's good, now we would like to keep the order but simplify the middle term sin/cos to tan.  The best way about it is to use algsubs and manually substitute the relation with the option exact.  I don't Maple can achieve this without the manual help.

```algsubs(sin(x)/cos(x) = tan(x), bb, exact)

```

Now we're at the mercy of Maple here.  Maple always likes to throw negative terms out front.  The premise of Maple is to show it as it would appear on paper.  I mentioned exact and it shouldn't have changed the order but it did.  So maybe if we use sort we can right it.

```sort(%)

```

Ok, good but now Maple has thrown the single term multiplier at the end.

Can anyone get maple to put the cos(x) term out front?

﻿