Pseudomodo

260 Reputation

8 Badges

13 years, 339 days

 

Istra balagina kish kish karia.

MaplePrimes Activity


These are replies submitted by Pseudomodo

I'm not sure that I understand exactly what you're asking now. To have the entries of Matrices/Arrays/Vectors of greater dimension than the default be printed in full you can adjust the interface(rtablesize) setting.

For example  interface(rtablesize=50):  to have ones larger than 50 be shown in full. The default value for interface(rtablesize) in the Standard GUI is 10. When you call the interface command to set this, the return value is the previous setting (and which you might choose to ignore, or suppress by ending the statement with a full colon).

But maybe you are asking about something else? Are you seeing the output being elided? Could you upload a worksheet that demonstrates the problem?

I'm not sure that I understand exactly what you're asking now. To have the entries of Matrices/Arrays/Vectors of greater dimension than the default be printed in full you can adjust the interface(rtablesize) setting.

For example  interface(rtablesize=50):  to have ones larger than 50 be shown in full. The default value for interface(rtablesize) in the Standard GUI is 10. When you call the interface command to set this, the return value is the previous setting (and which you might choose to ignore, or suppress by ending the statement with a full colon).

But maybe you are asking about something else? Are you seeing the output being elided? Could you upload a worksheet that demonstrates the problem?

Could you post enough of the code so that we could run it ourselves?

@Preben Alsholm I generated the equations in the order that they could be supplied sequentially, for the given small example. Ie, bottom to top.

But yes, of course, if the dependencies are not all in one direction for some other as yet unseen example then he'd have to use the solve command or something else.

@Preben Alsholm I generated the equations in the order that they could be supplied sequentially, for the given small example. Ie, bottom to top.

But yes, of course, if the dependencies are not all in one direction for some other as yet unseen example then he'd have to use the solve command or something else.

@Fermi The problem example isn't actually in the screeenshot. Thomas's suggestion to upload a worksheet which you know certainly reproduces the problem (saved with output) might be the best way to proceed.

Markiyan Hirnyk wrote:

    >     > add(A);
    >
    >    Error, invalid input: add expects 2 arguments, but received 1

It's pretty obvious from Joes "Musing" commentary that Maple does not currently support the syntax add(A) for A some Vector. The meaning is that it could be a nice enhancement in behavior of Maple.

Pointing out that it currently generates an error message, with no further commentary, just makes a whoosh noise.

Markiyan Hirnyk wrote:

    >     > add(A);
    >
    >    Error, invalid input: add expects 2 arguments, but received 1

It's pretty obvious from Joes "Musing" commentary that Maple does not currently support the syntax add(A) for A some Vector. The meaning is that it could be a nice enhancement in behavior of Maple.

Pointing out that it currently generates an error message, with no further commentary, just makes a whoosh noise.

@Christopher2222 At which point did you run into trouble while trying to implement it?

Have you worked through the examples in the help? (eg. the damper one, to start)

@Markiyan Hirnyk For this example, n=0 could get special treatment (unless we are informed that n::posint). And yes, I was aware of what happened for n in {-3,-2,-1}.

But for other examples, more work may be required. Suppose that the term -240*r^(2*n+4)*n^2 in the numerator of `a` had instead been -240*r^(2*n-4)*n^2. Then n=2 would be yet another special case that would render the approach eval(r*a,r=0) as invalid.

A safer method might be to apply expand, combine(...,power), collect w.r.t `r`, and then examine the powers of r. The examination could solve the various powers of `r` for `n`, and build up a piecewise result involving those solutions-in-n.

Maybe a result like this:

a := (1/11520)*(4518-4320*r^(2*n)-5760*_C1*n^4*r^2-97920*_C1*n^2*r^2-97920*_C1*n*r^2
     -40320*_C1*n^3*r^2+2020*r^6*n^3+1500*r^6*n^2-1440*r^(2*n+6)+60*r^8-2880*r^(2+2*n)
     -720*r^4-100*n^5-339*n^2+3018*r^2+4560*r^(2+2*n)*n-240*r^(2*n-4)*n^2
     -480*r^(2+2*n)*n^4+50*r^8*n-130*r^8*n^4-270*r^8*n^3-170*r^8*n^2-20*r^8*n^5
     +480*r^(2*n+6)*n+480*r^(2*n+6)*n^3-480*r^(2*n+6)*n^2-1680*r^(2+2*n)*n^3
     +160*n^5*r^6-102*n*r+320*r^2*n^5+1783*r^2*n^4-34560*_C1*r^2-360*r^4*n^5
     -102*n^2*r-42*n^3*r-6*n^4*r+551*r^2*n^2+2551*r^2*n-1440*n^2*r^4-3240*r^4*n
     +240*r^(2*n)*n^2+1200*r^(2*n)*n^3-5040*r^(2*n)*n+240*r^(2*n)*n^4
     +480*r^(2+2*n)*n^2+97920*_C1*n^2+97920*_C1*n+40320*_C1*n^3+5760*_C1*n^4
     +2140*n*r^6+2481*r^2*n^3+240*r^(2*n+4)*n^4-3600*r^4*n^3-2160*r^4*n^4
     +1020*r^6*n^4+1800*r^6-507*n^4-589*n^3+34560*_C1-36*r-1399*n)
     /((17*n^2+17*n+6+7*n^3+n^4)*r);

piecewise(n = 0, 11/3840+(1/2)*_C1,
          n = 2, (1/2)*_C1-277/34560,
          (1/11520)*
           (97920*_C1*n^2+97920*_C1*n+40320*_C1*n^3+5760*_C1*n^4+4518-507*n^4
            -339*n^2-589*n^3-100*n^5-1399*n+34560*_C1)/(17*n^2+17*n+6+7*n^3+n^4));

Naturally, it could be that the questioner's method of arriving at expression `a` precludes such powers as r^(2*n-4) in the numerator.

@Markiyan Hirnyk For this example, n=0 could get special treatment (unless we are informed that n::posint). And yes, I was aware of what happened for n in {-3,-2,-1}.

But for other examples, more work may be required. Suppose that the term -240*r^(2*n+4)*n^2 in the numerator of `a` had instead been -240*r^(2*n-4)*n^2. Then n=2 would be yet another special case that would render the approach eval(r*a,r=0) as invalid.

A safer method might be to apply expand, combine(...,power), collect w.r.t `r`, and then examine the powers of r. The examination could solve the various powers of `r` for `n`, and build up a piecewise result involving those solutions-in-n.

Maybe a result like this:

a := (1/11520)*(4518-4320*r^(2*n)-5760*_C1*n^4*r^2-97920*_C1*n^2*r^2-97920*_C1*n*r^2
     -40320*_C1*n^3*r^2+2020*r^6*n^3+1500*r^6*n^2-1440*r^(2*n+6)+60*r^8-2880*r^(2+2*n)
     -720*r^4-100*n^5-339*n^2+3018*r^2+4560*r^(2+2*n)*n-240*r^(2*n-4)*n^2
     -480*r^(2+2*n)*n^4+50*r^8*n-130*r^8*n^4-270*r^8*n^3-170*r^8*n^2-20*r^8*n^5
     +480*r^(2*n+6)*n+480*r^(2*n+6)*n^3-480*r^(2*n+6)*n^2-1680*r^(2+2*n)*n^3
     +160*n^5*r^6-102*n*r+320*r^2*n^5+1783*r^2*n^4-34560*_C1*r^2-360*r^4*n^5
     -102*n^2*r-42*n^3*r-6*n^4*r+551*r^2*n^2+2551*r^2*n-1440*n^2*r^4-3240*r^4*n
     +240*r^(2*n)*n^2+1200*r^(2*n)*n^3-5040*r^(2*n)*n+240*r^(2*n)*n^4
     +480*r^(2+2*n)*n^2+97920*_C1*n^2+97920*_C1*n+40320*_C1*n^3+5760*_C1*n^4
     +2140*n*r^6+2481*r^2*n^3+240*r^(2*n+4)*n^4-3600*r^4*n^3-2160*r^4*n^4
     +1020*r^6*n^4+1800*r^6-507*n^4-589*n^3+34560*_C1-36*r-1399*n)
     /((17*n^2+17*n+6+7*n^3+n^4)*r);

piecewise(n = 0, 11/3840+(1/2)*_C1,
          n = 2, (1/2)*_C1-277/34560,
          (1/11520)*
           (97920*_C1*n^2+97920*_C1*n+40320*_C1*n^3+5760*_C1*n^4+4518-507*n^4
            -339*n^2-589*n^3-100*n^5-1399*n+34560*_C1)/(17*n^2+17*n+6+7*n^3+n^4));

Naturally, it could be that the questioner's method of arriving at expression `a` precludes such powers as r^(2*n-4) in the numerator.

We were not told that n is a positive integer, were we?

Is this suggested answer correct when n=0?

There are four special cases, where the powers of `r` involve n. Of those, the cases n={-3,-2,-1} also make the denominator vanish.

We were not told that n is a positive integer, were we?

Is this suggested answer correct when n=0?

There are four special cases, where the powers of `r` involve n. Of those, the cases n={-3,-2,-1} also make the denominator vanish.

@joannjubin Do you understand that by giving us just the one example, for mult(a,a) to "multiply" a by itself, the question is ambiguous? What's the result you expect for `a` and `b` different Matrices (of different dimensions if allowed)?

One interpretation of your single example, using loops,

mult:=proc(A::Matrix,B::Matrix)
local i,j,C,S;
uses LinearAlgebra;
C:=Matrix(RowDimension(A),ColumnDimension(A));
S:=0;
for i from 1 to RowDimension(B) do
for j from 1 to ColumnDimension(B) do
S:=S + B[i,j];
od;
od;
for i from 1 to RowDimension(A) do
for j from 1 to ColumnDimension(A) do
C[i,j]:=C[i,j]+S*A[i,j];
od;
od;
return C;
end proc:

a:=<<1|2|3>,<4|5|6>>;

mult(a,a);
                               [21   42   63]
                               [            ]
                               [84  105  126]

a*add(z,z in a);
                               [21   42   63]
                               [            ]
                               [84  105  126]

Look at the ambiguity of your single example. Two different methods get the same result for "multiplying" `a` with `a`, but get different results for "multiplying" `a` with `b`.

multONE:=proc(A::Matrix,B::Matrix)
local i,j,C,S;
uses LinearAlgebra;
C:=Matrix(RowDimension(A),ColumnDimension(A));
S:=0;
for i from 1 to RowDimension(B) do
for j from 1 to ColumnDimension(B) do
S:=S + B[i,j];
od;
od;
for i from 1 to RowDimension(A) do
for j from 1 to ColumnDimension(A) do
C[i,j]:=C[i,j]+S*A[i,j];
od;
od;
return C;
end proc:


multTWO:=proc(A::Matrix,B::Matrix)
local i,j,C,S;
uses LinearAlgebra;
C:=Matrix(RowDimension(A),ColumnDimension(A));
S:=0;
for i from 1 to RowDimension(B) do
for j from 1 to ColumnDimension(B) do
S:=S + A[i,j];
od;
od;
for i from 1 to RowDimension(A) do
for j from 1 to ColumnDimension(A) do
C[i,j]:=C[i,j]+S*B[i,j];
od;
od;
return C;
end proc:


a:=<<1|2|3>,<4|5|6>>;
                                    [1  2  3]
                               a := [       ]
                                    [4  5  6]

b:=<<2|5|7>,<1|8|4>>;
                                    [2  5  7]
                               b := [       ]
                                    [1  8  4]

multONE(a,a);
                               [21   42   63]
                               [            ]
                               [84  105  126]


multTWO(a,a); # same as multONE(a,a)
                               [21   42   63]
                               [            ]
                               [84  105  126]


multONE(a,b);
                               [ 27   54   81]
                               [             ]
                               [108  135  162]


multTWO(a,b); # different from multONE(a,b)
                               [42  105  147]
                               [            ]
                               [21  168   84]

@joannjubin Do you understand that by giving us just the one example, for mult(a,a) to "multiply" a by itself, the question is ambiguous? What's the result you expect for `a` and `b` different Matrices (of different dimensions if allowed)?

One interpretation of your single example, using loops,

mult:=proc(A::Matrix,B::Matrix)
local i,j,C,S;
uses LinearAlgebra;
C:=Matrix(RowDimension(A),ColumnDimension(A));
S:=0;
for i from 1 to RowDimension(B) do
for j from 1 to ColumnDimension(B) do
S:=S + B[i,j];
od;
od;
for i from 1 to RowDimension(A) do
for j from 1 to ColumnDimension(A) do
C[i,j]:=C[i,j]+S*A[i,j];
od;
od;
return C;
end proc:

a:=<<1|2|3>,<4|5|6>>;

mult(a,a);
                               [21   42   63]
                               [            ]
                               [84  105  126]

a*add(z,z in a);
                               [21   42   63]
                               [            ]
                               [84  105  126]

Look at the ambiguity of your single example. Two different methods get the same result for "multiplying" `a` with `a`, but get different results for "multiplying" `a` with `b`.

multONE:=proc(A::Matrix,B::Matrix)
local i,j,C,S;
uses LinearAlgebra;
C:=Matrix(RowDimension(A),ColumnDimension(A));
S:=0;
for i from 1 to RowDimension(B) do
for j from 1 to ColumnDimension(B) do
S:=S + B[i,j];
od;
od;
for i from 1 to RowDimension(A) do
for j from 1 to ColumnDimension(A) do
C[i,j]:=C[i,j]+S*A[i,j];
od;
od;
return C;
end proc:


multTWO:=proc(A::Matrix,B::Matrix)
local i,j,C,S;
uses LinearAlgebra;
C:=Matrix(RowDimension(A),ColumnDimension(A));
S:=0;
for i from 1 to RowDimension(B) do
for j from 1 to ColumnDimension(B) do
S:=S + A[i,j];
od;
od;
for i from 1 to RowDimension(A) do
for j from 1 to ColumnDimension(A) do
C[i,j]:=C[i,j]+S*B[i,j];
od;
od;
return C;
end proc:


a:=<<1|2|3>,<4|5|6>>;
                                    [1  2  3]
                               a := [       ]
                                    [4  5  6]

b:=<<2|5|7>,<1|8|4>>;
                                    [2  5  7]
                               b := [       ]
                                    [1  8  4]

multONE(a,a);
                               [21   42   63]
                               [            ]
                               [84  105  126]


multTWO(a,a); # same as multONE(a,a)
                               [21   42   63]
                               [            ]
                               [84  105  126]


multONE(a,b);
                               [ 27   54   81]
                               [             ]
                               [108  135  162]


multTWO(a,b); # different from multONE(a,b)
                               [42  105  147]
                               [            ]
                               [21  168   84]
1 2 3 4 5 6 Page 1 of 6