Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Your system of differential equations  has the form

x' = A*x + B,

with A and B constant matrices.  As such, it has the solution

x = A^(-1).(exp(A*t).(A.x(0)+B) - B)

You can directly extract A from the system of equations, then use LinearAlgebra:-MatrixExponential to compute exp(A*t). Solve for B by plugging in the given boundary conditions.

Use sys2:-a to access the A matrix, sys2:-b to access the B Matrix, etc.

?Linearize returns a sequence of four elements; the DynamicSystems object is the first element in the sequence. Try

PrintSystem(sol2[1]);

 

 

There is no requirement that a specific region has to be colored. You can customize them however you like.

If you hadn't noticed that the recurrence can be directly summed, you could use ?rsolve:

eq := a(n) = a(n-1) + sqrt(3)/12*(2/3)^(2*n-2):
An := rsolve({eq, a(0)=sqrt(3)/4}, a(n));
                                  1/2      1/2      n
                               2 3      3 3    (4/9)
                         An := ------ - -------------
                                 5           20

limit(An, n=infinity);
                                       1/2
                                    2 3
                                    ------
                                      5

 

The reason your approach fails is that you defined a as a recursive procedure, then called it with a symbolic argument.  Actually, even if you called it with a numeric argument it would fail, unless a(0) is assigned after a(n).  For example,

a := n -> a(n-1) + sqrt(3)/12*(2/3)^(2*n-2):
a(0) := sqrt(3)/4: # this directly assigns a value to the remember table of a
a(10);
                                           1/2
                                464852158 3
                                --------------
                                  1162261467

User ?ifactors, rather than ?ifactor, to generate the factorization.  Its output structure is straightforward to parse.

(**) f := ifactors(135);
                                f := [1, [[3, 3], [5, 1]]]

(**) map(`$`@op, f[2]);
                                       [3, 3, 3, 5]

That was a test of your Maple syntactical knowledge.  More understandable is

map(L->(L[1]$L[2]), f[2]);
                                       [3, 3, 3, 5]

Be wary of that hint.  You almost certainly do not want to use ?has.  Rather, consider using ?member.

The major problem is the way MyMapleLibrary is written; the assignments for the exports (and locals, if there were any) go inside the body of the module.  So it should look like

MyMapleLibrary := module()
export MyPower, MySum;
option package;
    MyPower := proc(a,b) ... end proc;
    MySum := proc() ... end proc;
end module:

Of course, the ... in the above stand for the body of the procedures.

Are you sure that is the error you receive?  Something else is going on. Try calling the code with f('result', 2); 

Use the builtin table index function antisymmetric.

T := table('antisymmetric'):
T[1,2];
            T[1,2]
T[2,1];
           -T[1,2]
T[1,1];
           0

That just indicates the name of the procedure in which the error was generated (more likely trapped).  What was the actual error message?

You can double the speed by removing all the calls to evalhf and wrap the entire call to the procedure in one:

evalhf(GBIKF012(...));

The problem is that you have not initialized Aplus to anything.  When Maple attempts to evaluate

Aplus := Aplus + 2*m;

it recursives indefinitely (think about it).  Try first assigning 0 to Aplus:

Aplus := 0;

I haven't tested your code, but one thing you should not be doing is inserting ?with statements into the body of a procedure. That does not work. They must be at top-level. To get the equivalent effect inside a procedure, use the ?uses statement:

plottingmyarray := proc()
uses StringTools, plots;
    ...
end proc:

A second problem is that the first call to plot will not produce output. To do that, wrap it in a print statement:

print(plot(...));

If the partition is decomposable, which is generally not the case, the following computes it

map[3](select,`subset`,P1 minus P2, P2 minus P1);

No claims as to the efficiency of this

First 37 38 39 40 41 42 43 Last Page 39 of 114