MaplePrimes Questions

Search Questions:

Latest Questions Latest Questions Feed

Hi,

I don't manage to animate a DensityPlot. Here is my program :

> restart;
> with(Statistics): with(plots):
> P := lambda->RandomVariable(Poisson(lambda)):
> animate(DensityPlot,[P(n),range=0..10],n=1..5,frames=5);

And here is the error message :

Plotting error, non-numeric vertex definition

Thanks for any help

Hi

I'm dealing with 2nd order ODE on Maple. By using " infolevel 5" Maple tell me that it use Kovacic's algorithm to find the solution. Could anybody tell me how or at least some idea so that I can go on this my self. Following here my ODE

Thank you so much

Chaimongkol

I have two questions and I don't know whether it can be solved using Maple. The first question is that I have a text file, the data of which has been sorted using Unix procedure SORT. Since the data has been sorted, we just need to compare consecutive lines. Our aim is to count the total number of the same lines of this file and obtain the maximum number of the same consecutive lines. For example, the data of the file, named file.txt, is:

1,0,5,-2,2,0
1,0,5,-2,3,0
1,0,5,-2,4,-2
1,0,5,-4,4,0
1,0,5,-4,4,0
1,0,5,-4,4,0
1,0,5,0,5,-2
1,0,5,0,6,0
1,0,5,0,6,0

I want to get two numbers: the total number of the same lines 5 and the maximum number of the same consecutive lines 3. Another question is, given a string s, if s is not contained in this file, then the program returns NULL;otherwise, the program returns the total number it appears and the specific line numbers it appears. For instance, suppose the string is s=1,0,5,-4,4,0, then it returns the total number 3 and the line numbers 4,5,6.

Best regards,

Liu

In Maple, I seem to keep finding commands in different Maple build-in packages that does the same thing. Which is very confusing for someone trying to learn Maple.

Maple seems to have good things in it, but at the same time, it strikes me as a large bag with lots of tools and commands thrown in with little sense of coherence. One needs one command from one package to finish the job started using a command from a different package, and an option from one place to patch something done with a command from another package.

Here is one example. I wanted to obtain the diagonal of a matrix. So far, I found 3 commands that do the same exact thing:

A:=Matrix([ [1,2,3],[4,5,6],[7,8,9]]);
MTM:-diag(A);  #1
LinearAlgebra:-Diagonal(A);  #2
Student:-LinearAlgebra:-Diagonal(A);  #3

I am sure if continue to look, I might find another command to do the same thing hiding in some other package.

The problem for new user like me, is how does one decide which comand to use. This is the same as with constructing a Matrix. There is the Matrix([[]]) notation and metod, and there is the <<>> notation that does the same thing but with different and conflicting syntax.

Having many commands that do duplicate things is not a good thing at all. Commands should be axiomatic and orthogonal to each others. I think there should be a document that describes from a high level all these packages, may be as a block diagram with arrows that show the relation, if any, between them, and how they interact and when to use one vs. the other.

Is there a reason for this duplication of functionality? Does any one at Maplesoft look at such issues?

 

Hello,

 

in summary, I have a problem with the evaluation of a matrix multiplication between matrices with trigonometric entries.

Im a bloody beginner with Maple, so sorry in case this question is stupid or I posted in a wrong way!

 

There is the 6x6-Matrix  L, which has entries like:  Lmn = L1 + L2 cos(2 phi + phi_0).

I want to transform this Matrix L with  the 3x6 rotational Matrices T and its 6x3 Inverse-Matrix  T_p_inverse, 

like:                              L_transformated = T * L * T_p_inverse

 

The problem is, that I don't get Maple to simplify the solution.

I tried combine, simplify, expand, evala, but maple does not combine and simplify the solution. Due to the trigonometric entries and orthonomal row-vectors in T, I expect the solution to be quite simple.

Attached you find my worksheet!   transformation_L.mw

It would be great if somebody can help me or give me a hint!

Thanks a lot!

nilssson

 ---------------------------------------------------------------------

Here are the exact Matrices:

 

 

 

 

 

Hi
I am trying to define commutation rules between operators a1, a2, b1, b2.


restart;
with(Physics);
with(Library);
Setup(mathematicalnotation = true);

Setup(op = {a1, a2, b1, b2});
alias(A = %AntiCommutator);
algebra := [A(a1, a1) = 0, A(a2, a2) = 0, A(a1, a2) = 0, A(b2, a1) = 0, A(a1, b1) = 1,
A(a2, b2) = 1];
Se
tup(algebrarules = algebra);

However, the command Setup(algebrarules = algebra); causes an error. What is wrong? Noteworthy that if commutator is considered instead of anticommutator alias(A = %Commutator); then correct result follows.
Thank you.

Hello!

I would like to start with the following set of 9 elements,
A = { E11, E12, E21, E22, E11+E12, E11+E21, E12+E22, E21+E22, E11+E12+E21+E22 }.

I need a procedure that takes each of those elements and creates 3 new ones in the following way: Eij becomes Eij1, Eij2, Eij1+Eij2. So for example, E11 will become: E111, E112, and E111+E112. And for example the fifth element in A (i.e. E11+E12) will become the 3 new elements: E111+E121, E112+E122, and E111+E121 + E112+E122.

Since each of the 9 elements gets triplicated, there will be a new set, call it B, with 27 elements.

B = {E111, E112, E111+E112, E121, E122, E121+E122, ... }

Now I want to repeat this process of triplicating again so that, for example, E111 becomes: E1111, E1112, and E1111+E1112. And so on. This new set C will have 81 elements. Now I want to repeat this one last time. The final set, D, will have 243 (3^5) elements. 

Step 2: 

For every pair of elements x and y in D, I want to compute z:=(x+y)mod2. If z already belongs to D, discard it, otherwise, place z in the set D2. Do this until there are no more elements to add together (note that if x+y is computed then I don't want y+x to be computed also--that's inefficient). Maybe the most efficient way is to perform all possibly combinations of x+y mod 2 to create the set D2 and then just go: D2 setminus D.

Step 3: For x in D and y in D2 perform all possible combinations of z:=(x+y)mod2 and place these in D3 then perform set subtraction again: D3 minus D2 minus D.

Repeat this process again: x in D and y in D3 to create new elements in D4. Repeat again until Dm is empty (that is, D(m-1) will be the last set that contains new elements). I'm expecting around 12 sets... 

The issue with this whole algorithm is that I often run out of memory so I need a clever way to do this, since this algorithm is essentially classifying 2^32 elements into disjoint sets. Thank you! 

I figured how to insert row in middle of a matrix using <<>> notation. But I am trying to stick to one notation which is the Matrix() and Vector() for now. 

Here is what I am trying to do. Insert a row in the third row of  Matrix. This works:

A:=< <1|2|3>,<4|5|6>,<7|8|9>>;
A:=<<A[1..2,..],<90|91|92>,A[3,..]>>;

But when I try

A:=Matrix([ [1,2,3],[4,5,6],[7,8,9]]);
A:=Matrix([ A[1..2,..], [91,92,92], A[3,..] ]);

Error, (in Matrix) this entry is too tall or too short: [91, 92, 92]

I also tried:
A:=Matrix([ A[1..2,..], Vector[row](91,92,92), A[3,..] ]);
A:=Matrix([ A[1..2,..],Matrix([[91,92,92]]), A[3,..] ]);

I am starting to think I should go back to using <<|,|,|>> notation, even thought I do not like it, but at least it seems more logical. 
How would you insert row in middle of matrix, using Matrix() constructor from an existing Matrix?

 

 

I have a polynomial p in two variables x and y, and I want to extract all the coefficients of p. For example, let p:=x^3+2*x*y^2-2*y^2+x, and I want to obtain the coefficient vector [1,0,0,1,0,2,0,0,-2,0], where 1,0,0,1,0,2,0,0,-2,0 are respectively the coefficients of x^3, x^2, x^2*y,x,x*y,x*y^2,y^0,y,y^2,y^3. In general, let 

p(x,y)=sum(sum(c_*{i, j}*x^(n-i)*y^j, j = 0 .. i), i = 0 .. n)

=c_{0,0}x^n

+c_{1,0}x^{n-1}+c_{1,1}x^{n-1}y

+c_{2.0}x^{n-2}+c_{2,1}x^{n-2}y+c_{2,2}x^{n-2}y^2

+\dots

+c_{n,0}+c_{n,1}y+c_{n,2}y^2+\dots+c_{n,n}y^{n}.

It is possible that some coefficients c_{i,j} are equal to 0. How to obtain the coefficient vector [c_{i,j},i=0..n,j=0..i] of p(x,y)?

Thanks a lot.

When the loop variable can be written as a unit step sequence, I never really distinguish between using

seq( f(i), i=m..n ), and

f(i) $ i=m..n

However I recent came across a case where the 'seq' construct ran about 2.5x faster. Is using 'seq' always faster? Does it depend on the function being evaluated? Why is there such a large difference in execution time

The original example which exhibited the problem is shown below, although after some experimentation, I have found other cases where 'seq' is faster (and plenty where it doesn't seem to make any difference!)

Example code for implementation using '$' is

restart:
ulim:=1000000:
t1:=time():
ans:= max
          ( { iquo(3*d, 7)/d $ d = 1..ulim }
             minus
            {3/7}
         ):
t2:= time()-t1;


Example code for for implementation using 'seq' is

restart:
ulim:=1000000:
t1:= time():
ans:= max
        ( { seq
            ( iquo(3*d, 7)/d, d=1..ulim )
          }
          minus
          {3/7}
        ):
t2:= time()-t1;

On my machine, the version using the 'seq' construct runs 2.5x faster

 

The help page for ?error says the following:

  • A numbered parameter of the form %n displays the nth msgParam in lprint notation.

However this is not literally true if %n happens to refer to a Maple object.  When a Maple object is lprint-ed, it looks for the object's ?ModuleDeconstruct method and uses that.  But in fact if M is an object, an error call like

error "invalid input: object %1 is wrong", M

displays M using its module shell

   Error, invalid input: object  module() export.... local... option object; end module  is wrong.

This is ugly and seems to contradict the ?error help page.  Why isn't the ModuleDeconstruct method of M invoked?  It is one of the few circumstances where an object is displayed "raw" without using either its ModulePrint or ModuleDeconstruct methods.  And can anyone suggest a workaround?

Sorry, don't have access to Maple 18, the above is for my M17.

Thanks,

Ian.

 

I am learning a bit of Maple. I noticed I can use map and seq to obtain the same result I want. So I was wondering when to use each, or if it just a style issue or if there is more to it.

I am sure there are cases when map can only be used, and cases when seq() only can be used. But are there general rules of thumb to look for when deciding which to use? Here is an example of what I mean

restart;
plot( map(i->i*sin(t),[seq(i,i=.1..1,.2)]),t=-2*Pi..2*Pi);   #1
plot( [seq(i*sin(t),i=.1..1,.2)],t=-2*Pi..2*Pi);  #2

Both give the same result

I kind'a like map more myself, but seq is a little shorter in this case. Just looking for thoughts and hints from the experts.

 

One would expect that hitting F3 will split from _end_ of the current line (where the cursor is at).

But what Maple does is actually split everything from the current cursor location. Which means if the cursor happened not to be exactly at the end of the line, the current line itself will also be split and broken.

It is much more logical to split starting from end of current _line_ (where the cursor is at), not current character, because that is what normally one would want to do. One will have large block of code, and want to split it from one line down to the end.  It is a simple usability issue, which Maple UI seems to suffer allot from.

Is there a way to modify this behavior? I keep hitting F3 and forget to move the cursor to the end of the line before, and end up wasting time having to fix things afterwords since the line itself is split.

 

 

This is a typical problem of what I find when learning DynamicSystems. Basically, I create number of systems by changing one paramter (the damping ratio in this case) and want to plot the unit step of all of them on the same plot to compare the effect of the damping ratio.

I setup the TransferFunction, used Simulate to obtain the response of each to the same input. The problem comes when I want to plot the respones.  I have to use plot[odeplot] it seems. But this only like to take one response at a time.

I can't use plot() since I do not have the actual function of the response in time. Unless I try to extract the differential equation from the sytem object, solve that and get a solution then use plot(). But if I do all of this, what do I need DynamicSystems in first place? 

I will show what I tried. I am sure there is some way to do this in Maple I just do not know yet the correct function or setup.

restart;
alias(DS=DynamicSystems);
H:=(w,zeta)->w^2/(s^2+2*zeta*w*s+w^2);
sys:= (w,zeta)->DS:-TransferFunction(H(w,zeta)):
sol:=seq(DS:-Simulate(sys(1,zeta),Heaviside(t)),zeta=0.1..1.2,.2):

Now I want to plot all the solutions in sol. I wanted to use plot(...) only to be able to obtain the automatic coloring of each solution.

If I try to use plots[odeplot], it works, but only on one at a time:

plots[odeplot](sol[1],t=0..10);

If I try this, it fails:

plots[odeplot]([sol],t=0..10);

I can get each plot separatly and then use display() but then lose the automatic coloring of the lines:

plots:-display(seq(plots[odeplot](sol[i],t=0..10),i=1..nops([sol])));

I am looking for the above plot, but have the lines each colors differently. I also need to figure how to add legend later. But one step at a time. I can't hard code the color in the plots[odeplot] call itself, since I do not know what color to give each line. plot([....],t=0..) allready does this automatically. But I can't use it!

Just to give an idea of the kind of plot I am trying to obtain, here it is in Mathematica:

sys = TransferFunctionModel[w^2/(s^2 + 2 z*w*s + w^2), s];
zValues = Range[.2, 1.2, .2];
fun = OutputResponse[sys /. {w -> 1, z -> #}, UnitStep[t], {t, 0, 12}] & /@ zValues;
Plot[Evaluate@Flatten@Table[fun[[i]], {i, 1, Length[fun]}], {t, 0, 12}, Frame -> True, PlotRange -> {{0, 12}, {-.1, 1.7}}]

 

 

 

How to calculate the integral of (z-z0)*z/sqrt((x-x0)^2+(y-y0)^2+(z-z0)^2)
over the unit sphere {(x,y,z):x^2+y^2+z^2<=1}
under the assumtion x0^2+y0^2+z0^2<=1 (x0^2+y0^2+z0^2>1)?
Its physical interpretation suggests the integral can be expressed through  elementary functions of the parameters.

My tries are
VectorCalculus:-int((z-z0)*z/sqrt((x-x0)^2+(y-y0)^2+(z-z0)^2),[x,y,z]=Sphere(<0,0,0>,1)) assuming x0^2+y0^2+z0^2<=1;

and

VectorCalculus:-int(eval((z-z0)*z/sqrt((x-x0)^2+(y-y0)^2+(z-z0)^2),
[x=r*sin(psi)*cos(theta),y=r*cos(psi)*sin(theta),z=r*cos(psi)])*r^2*sin(psi),
[r,psi,theta]=Parallelepiped(0..1,0..Pi,0..2*Pi)) assuming x0^2+y0^2+z0^2<=1;

The both are spinning on my comp. Also

VectorCalculus:-int((z-1/4)*z/sqrt((x-1/2)^2+(y-1/3)^2+(z-1/4)^2),[x,y,z]=Sphere(<0,0,0>,1),numeric);

is spinning.
Edt. The omitted part of the code assuming x0^2+y0^2+z0^2<=1 is added.

1 2 3 4 5 6 7 Last Page 3 of 1044