Joe Riel

9530 Reputation

23 Badges

20 years, 28 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Note that I used the extension ".m".  That causes Maple to save using its internal format. If you chose a different extension the result will be easily readable (by eye), however, the file is generally larger and takes longer to load.

A := <<1,2>|<3,4>>:
save A, "A.m":
restart;
read "A.m":
A;
                                                 [1    3]
                                                 [      ]
                                                 [2    4]

See www.mapleprimes.com/book/cartesian-products-of-lists for several procedures for computing cartesian products in Maple.

Yes.  See the help pages for OpenMaple

 M := <<2,3>|<4,5>>; 
                                         [2    4]
                                    M := [      ]
                                         [3    5]

max(M);
                         5

You might use applyop to apply the Re function to just the rhs of the equation.  For example,

applyop(Re, 2, A[1,1]);

Or maybe

applyop(evalc@Re, 2, A[1,1]);

Given two lists you can use Equate to equate corresponding elements:

Equate[a,b,c], [1,2,3]);
                                            [a=1,b=2,c=3]

In Maple 13 you can do

[a,b,c] =~ [1,2,3];
                                  [a=1, b=2, c=3]

You could also use zip

zip(`=`, [a,b,c], [1,2,3])

For your case it is more efficient to use a do loop, the reason being that you don't have to create the intermediate lists, since all you really want to do, apparently, is make an assignment:

for i to n do
   A[i] := M[i-1] ... ;
end do:

If you don't need all the points at once, but instead are content to access them one at a time, you could use the combinat[cartprod] iterator constructor.  For example,

dims := [[1.2,3.2], [1.2, 2]]:
ints := map( dim -> [seq(ceil(dim[1])..dim[2])], dims):
T := combinat:-cartprod(ints):

while not T[finished] do lprint(T[nextvalue]()) end do;
[2, 2]
[3, 2]

See www.mapleprimes.com/book/cartesian-products-of-lists

Try the LargeExpressions package.  For example,

with(LargeExpressions):
subsindets(ex
           , `*`
           , Veil[K]
          );
     -2 K[1046] + 2 K[1048] + 2 K[1050] + 4 K[1052] + 2 K[1054]
     + 2 K[1055] + 2 K[1053] + 4 K[1051] + 2 K[1049] + 2 K[1047]
     - 2 K[302] + 2 K[289] - 2 K[44] + 4 K[471] + 2 K[183] + 2 K[96]
     - 4 K[555] - 2 K[229] - 2 K[106] - 4 K[539] + 2 K[36] + 4 K[497]
Unveil[K](K[1046]);
     (-2 K[700] + 2 K[722] - K[148] - K[532] - K[396] + K[203] + 2 K[684]
                                                      10
     - 2 K[747] + K[385] - K[221] + K[510] + K[142]) t

An example would clarify. Are these algebraic equations in which an initial guess value is used in an iterative process (or maybe a call to fsolve)?  Or are they differential equations with initial values?

Is the goal to solve the equation (or something more complicated) or to learn/demonstrate simple programming in Maple?  There are better ways than the brute force method you suggest.  You could, for example, use isolve here:

isolve(355*k = 200*n);  # modified to slightly increase interest
                           {k = 40 _Z1, n = 71 _Z1}

The symbol _Z1 stands for any integer, so the desired solution is n = 71.
 

Another way, if a bit more complicated, is to save it to a custom Maple archive so that it is accessible without having to add a read statement.  For example

myproc := proc(x) return x^2; end proc:
LibraryTools:-Save(myproc, "/home/joe/maple/lib/mylib.mla");
restart;
myproc(a);
                                a^2;

For that to work, the path "/home/joe/maple/lib" should be added to libname sequence.  That can be done by adding a line to the Maple initialization file, say

libname := "/home/joe/maple/lib", libname:

Look in ?worksheet,reference,initialization for description of the use and location of the user initialization file---you have to create it, it is not distributed with Maple.

It isn't clear what you are asking----vectors don't generally "take the values zero and one".  Zero maybe, but not one.  Do you mean components of vectors?  An example would clarify.

Here's a mildly interesting way; it requires Maple13,

A := Matrix([[1,3,a],[1,4,d],[1,1,b],[3,3,c],[3,4,a]]);

m := max(A[..,1]);
n := max(A[..,2]);

T := table(map(curry(op,[1,..])=rhs
               , convert(A[..,1..2], listlist) =~ convert(A[..,3],list)
              ));

B := Matrix(m,n,T);

If you don't have Maple13 you could assign T with

T := table(map(curry(op,[1,..])=rhs
               , Equate(convert(A[..,1..2], listlist), convert(A[..,3],list))
              ));

A simpler approach is to use a loop:

B := Matrix(m,n);
for i to LinearAlgebra:-RowDimension(A) do
    B[A[i,1],A[i,2]] := A[i,3];
end do:

If you could upload what you have done, it would be easier to comment. What sort of animation were you hoping to generate?

Given the odes, here is a simple example of an animation:

ode := { diff(phi(t),t,t) = -phi(t)
         , D(phi)(0) = 0
         , phi(0) = Pi/4
       }:

integ := dsolve(ode, numeric):

f := tt -> plots:-pointplot(eval([[sin,-cos](phi(t))], integ(tt))):

plots:-animate(f
               , [t]
               , t=0..10
               , frames=100
               , scaling=constrained
               , view=[-1..1,-1..1]
               , symbol=circle
              );

First 81 82 83 84 85 86 87 Last Page 83 of 114