From: Mr Sir on
So i have this function Z. I want to collect all the 'L' terms.

There are 2 problems; firstly it doesnt collect them all together, it
will have some parameters times by L^3 and then later on have another
clump times L^3 (see output below. Secondly, I have a non-sensical
piece in the output (see the <<& sign)

i have broken up the output for easier viewing

collect(Z,L)

((b_2^3*c^2)*L^4 +

(3*b_1*b_2^2*c^2 - 4*b_2^3*c^2 + 4*a_1*b_2^3*c + 4*a_2*b_2^3*c -
4*a_2*b_1*b_2^2*c)*L^3 +

(2*a_1^2*b_2^3 - 4*a_1*a_2*b_1*b_2^2 + 8*a_1*b_1*b_2^2*c +
2*a_2^2*b_1^2*b_2 - 8*a_2*b_1^2*b_2*c + 20*a_2*b_1*b_2^2*c -
12*a_2*b_2^3*c + 4*b_1^2*b_2*c^2 - 13*b_1*b_2^2*c^2 + 4*b_2^3*c^2)*L^2
+

(4*a_1^2*b_1*b_2^2 - 4*a_1^2*b_2^3 - 8*a_1*a_2*b_1^2*b_2 +
8*a_1*a_2*b_1*b_2^2 + 8*a_1*b_1^2*b_2*c + 8*a_1*b_1*b_2^2*c -
12*a_1*b_2^3*c + 4*a_2^2*b_1^3 - 4*a_2^2*b_1^2*b_2 - 8*a_2*b_1^3*c +
24*a_2*b_1^2*b_2*c - 28*a_2*b_1*b_2^2*c + 12*a_2*b_2^3*c + 4*b_1^3*c^2
- 16*b_1^2*b_2*c^2 + 9*b_1*b_2^2*c^2)*L

-4*a_1^2*b_1*b_2^2 + 2*a_1^2*b_2^3 + 8*a_1*a_2*b_1^2*b_2 -
4*a_1*a_2*b_1*b_2^2 + 8*a_1*b_1^2*b_2*c - 16*a_1*b_1*b_2^2*c +
8*a_1*b_2^3*c - 4*a_2^2*b_1^3 + 2*a_2^2*b_1^2*b_2 + 8*a_2*b_1^3*c -
16*a_2*b_1^2*b_2*c + 12*a_2*b_1*b_2^2*c - 4*a_2*b_2^3*c - 4*b_1^3*c^2
+ 4*b_1^2*b_2*c^2 + b_1*b_2^2*c^2 - b_2^3*c^2)/((4*b_2^4)*L^3
+ <<&

(20*b_1*b_2^3 - 12*b_2^4)*L^2 +

(32*b_1^2*b_2^2 - 40*b_1*b_2^3 + 12*b_2^4)*L +

16*b_1^3*b_2 - 32*b_1^2*b_2^2 + 20*b_1*b_2^3 - 4*b_2^4)

If you see at <<& I have L^3 which is multiplying the denominator. Why
on earth is it there if im trying to group terms. Shouldnt MATLAB
simply have;

(A)L^4+(B)L^3+(C)L^2+(D)L+E

And then I can run a 4-th order polynomial using the coefficients and
solve to find the solution for L.

Help plz
From: Walter Roberson on
Mr Sir wrote:
> ....
> /((4*b_2^4)*L^3
> + <<&
>
> (20*b_1*b_2^3 - 12*b_2^4)*L^2 +
>
> (32*b_1^2*b_2^2 - 40*b_1*b_2^3 + 12*b_2^4)*L +
>
> 16*b_1^3*b_2 - 32*b_1^2*b_2^2 + 20*b_1*b_2^3 - 4*b_2^4)
>
> If you see at <<& I have L^3 which is multiplying the denominator.

I do not see that at all. What I see is that immediately after the /
there is an opening bracket which is not matched until the end of the
entire expression, and thus the denominator is a sum of L^n terms rather
than a single value multiplied by L^3.


I don't know about MuPad, but one of the limitations of Maple's
collect() function was that the expression had to be a polynomial in the
variable being collected. The above is not a polynomial but rather is a
ratio of polynomials, so Maple would not have been able to collect terms
as much as might be expected. The mechanism that one would use in Maple
would be to map() the collect() function over the expression, which
would lead to the numerator and denominator being collected separately.
I have not yet located the MuPad equivalent of the map() function.
From: Steven_Lord on


"Walter Roberson" <roberson(a)hushmail.com> wrote in message
news:WyN1o.5990$hF1.2288(a)newsfe14.iad...
> Mr Sir wrote:
>> .... /((4*b_2^4)*L^3
>> + <<&
>>
>> (20*b_1*b_2^3 - 12*b_2^4)*L^2 +
>>
>> (32*b_1^2*b_2^2 - 40*b_1*b_2^3 + 12*b_2^4)*L +
>>
>> 16*b_1^3*b_2 - 32*b_1^2*b_2^2 + 20*b_1*b_2^3 - 4*b_2^4)
>>
>> If you see at <<& I have L^3 which is multiplying the denominator.
>
> I do not see that at all. What I see is that immediately after the / there
> is an opening bracket which is not matched until the end of the entire
> expression, and thus the denominator is a sum of L^n terms rather than a
> single value multiplied by L^3.

I've confirmed this by pasting the expression into a MATLAB session and
using the NUMDEN function to extract the numerator and denominator of the
expression as polynomials in L. You can then COLLECT or look at the COEFFS
of each of those polynomials separately.

> I don't know about MuPad, but one of the limitations of Maple's collect()
> function was that the expression had to be a polynomial in the variable
> being collected. The above is not a polynomial but rather is a ratio of
> polynomials, so Maple would not have been able to collect terms as much as
> might be expected. The mechanism that one would use in Maple would be to
> map() the collect() function over the expression, which would lead to the
> numerator and denominator being collected separately. I have not yet
> located the MuPad equivalent of the map() function.

What I used was:

[num, den] = numden(Z);
collect(num, L)
collect(den, L)

http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/numden.html

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com