Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Another possibility is to use ?depends instead of ?has.  It tests whether the expression depends, mathematically, on name or names. For example

select(depends, Int(x, x=0..1) + x, x);
                                                                x

The integral uses (has) x, but does not depend on it as it is a dummy variable.

The directories in the path to the file must exist. So you could do

dir := "/tmp/whatever1/whatever2":
if not FileTools:-IsDirectory(dir) then
    FileTools:-MakeDirectory(dir, 'recurse');
end if;
mla := cat(dir, "/mymla.mla"):
march("create", mla);

?LibraryTools:-SaveLib is different from ?savelib, the latter is a lower level command. Use the former, instead.

The constraint x^2 + y^2 <= 2*y is equivalent to x^2 + (y-1)^2 <= 1, which is the interior of a unit circle with center at (0,1).  The area of interest is the portion below the line x=y.  In polar coordinates, the two-form being integrated is r^2*dr &^ dtheta.  Let omega = 1/3*r^3*dtheta, so d(omega) = r^2*dr&^dtheta.  Using Stokes' theorem, integrate omega along the boundary of the region.  The integral is zero on the straight part because the flow is orthogonal to the path, so we just have to integrate the curved section.  Along the curve, r = 2*sin(theta), so we get

8/3*int(sin(theta)^3, theta = 0..Pi/4) = (16 - 10*sqrt(2))/9

which agrees with Preben's result. 

To achieve that, do

plotsetup(char):

To restore the normal plot, do

plotsetup(default):

 

Could you demonstrate what you mean by running j from  1 to s separately?

The following hint might be useful. Rather than assign to to a table a, make a a matrix.  That is, before the double loop, assign

a := Matrix(s):

then at the conclusion of the double loop, display a:

a;

That makes it easier to visually check whether it is what you expect.

 

 

 

Try posting just text, or a worksheet with input.  You've trimmed all the useful input, that worksheet is not usable as is.

You could try something like the following:

y := 1 + a/c + b/c^2:
subs(c=1/cinv, y):
subs(cinv=1/c, convert(series(%, cinv, 2),polynom));
                                                        1 + a/c 

As Acer recommends, the immediate code behind an embedded component should be short. I restrict it to a single procedure call, possibly with an argument appropriate to the particular component. During the development, I use the form

(SomeAction)();

Then, when I need to debug this, it can be quickly instrumented by changing it to

mdc(SomeAction)();

that is, by prepending mdc to the function call.  The mdc procedure---the main entry point to the Maple Debugger Client---instruments its argument and returns the procedure, which is then executed and launches a nice debugger. Contact me if interested in mdc. 

Use

kernelopts(printbytes=false):

 

Here's a modification to Roman's method that avoids O(n^2) list building.  If is useful if there are many repeated elements.

TableInverse := proc(T)local eq, indx, tmp, inv;
    for eq in op(2,op(T)) do tmp[rhs(eq)][lhs(eq)] := 0 end do;
    for indx in indices(tmp,'nolist') do inv[indx] := {indices(tmp[indx],'nolist')}; end do;
    op(inv);
end proc:


The Maple ?rsolve procedure solves this if you convert to polynomials. 

eqs := { a(n)*(a(n-1)+3) = a(n-1)+2, a(1) = 2 }:
rsolve(eqs, a(n) ); 

 

There are a few ways you can do this with Maple.  One is to mimic Matlab's multiple output method.  For example

MyProc := proc(x) return ( x, x+1, x^2 ); end proc:
(a,b,c) := MyProc(3); 
                            a, b, c := 3,4,9

The variables a, b, and c are now assigned 3, 4, and 9, respectively.

That isn't, however, necessarily the best approach, particularly if you are dealing with Matrices. You might be better off passing the output Matrices to the procedure as arguments and have the procedure operate on them directly.  For example

MyProc := proc(A :: Matrix, B::Matrix, C::Matrix) 
    B[..,..] := A^2;
    C[..,..] := A+B;
    NULL;
end proc:
X := <1,2;3,4>: Y := Matrix(2): Z := Matrix(2):
MyProc(X,Y,Z):
Y,Z;
          [ 7  10]   [8  12]
          [     ],  [     ]
          [15 22]  [18 26]
y := 16^j/16:
subs(16=z,1/16=1/z,y):
combine(%,power,symbolic):
subs(z=16, %);
 

I now see that that is essentially Carl's approach, but with ?combine,power instead of simplify. Hmm. A simpler approach, then, is

y := 16^j/16:
subs(k=j-1,simplify(subs(j=k+1,y))); 

 

{DE,DF} is a set of lists.  To get a set of equations, do op~({DE,DF}).

Computing manually I get 30!/25!/3!/2!*5^2 = 35626500. This comes from creating the venn diagram of the sets, noting that there must be exactly 3 in the middle region, 25 in C minus A minus B, leaving 2 for the other 5 regions.  Those two can be distributed 5^2 ways.  The lhs of the product is the number of ways to partition a set of 30 elements in subsets of 25, 3, and 2.

Note: fixed original computation

Per response from OP, my assumption that A union B union C = S is incorrect. Fortunately, it is easy to handle the more general case, just multiply by the number of ways to partition a set of 25 elements into two sets (the sets being C \ (A union B) and S \ (A union B union C)). That factor is 2^25.  So the overall result is

30!/25!/3!/2!*5^2*2^25 = 1195426971648000

Another option, possibly simpler, is to use a DataTable embedded component.  From the Components palette, click the DataTable icon.  A dialog will open querying for the size and name of the associated Matrix. You can directly access and assign elements in the DataTable via the associated Matrix.  You can also change the row and column names by right-clicking on the embedded component and selecting the "Row Name" or "Column Name" items. The names are for display, access to the cells is via integer indices.

First 32 33 34 35 36 37 38 Last Page 34 of 114