Kitonum

21690 Reputation

26 Badges

17 years, 186 days

MaplePrimes Activity


These are replies submitted by Kitonum

with(GraphTheory):

G := Graph(Trail(1,2,3,4,5,6,4,7,8,2) );

L:=RandomWalkOnGraph(G,2,20);

for i in L do

HighlightVertex(G,i);

M[i]:=DrawGraph(G);

G := Graph(Trail(1,2,3,4,5,6,4,7,8,2) );

od:

plots[display](seq(M[i]$10,i=L), insequence=true);

                     

 

                              

 

 

@Markiyan Hirnyk  Thank you. As for the animation, it is very easy to do, if you use  HighlightVertex  command. But now I have no time to do it, because half an hour begins the final of the European Football League.

@Carl Love   Many thanks for the work done to improve my procedure. Convert your comment to an answer  that I was able to vote for it. It will also be helpful if you added your version as a comment to my post.

@farazhedayati  Unfortunately in the procedure provided that the variables have the names  x  and  y . I replaced the variable  a  with  y . Now it works:

PP := subs(a = y, 0.3800179925e-3*exp(-0.6065722618e-3*(x-29.51704536)^2+(0.6650093594e-3*(x-29.51704536))*(a-12.94061928)-0.1106850312e-2*(a-12.94061928)^2));

ContoursWithLabels(PP, -20 .. 20, -20 .. 20, {seq(0.1e-3 .. 0.3e-3, 0.5e-4)}, [color = black, axes = box], Coloring = [colorstyle = HUE, colorscheme = ["Cyan", "Red"], style = surface]);

 

 

 

@Markiyan Hirnyk  A similar incorrect plotting:

plot(1/x, x=-5..5, y=-5..5, color=red, thickness=4);

@Markiyan Hirnyk  You have incorrectly wrote the first equation (see the original post). Here are the individual plots of the first and second equations. It is clearly seen that the first set (for y<>0) is a subset of the second set. This is a graphic illustration of what I wrote earlier:

a:=sin(165*Pi/180-theta)/10-sin(theta)/y:

b:=(((y^2-20*y*cos(Pi/12)+100)*(sin((165*Pi/180)-theta))^2)/100)-sin(Pi/12)^2:

plots:-implicitplot(a, y=-10..25, theta=0..2*Pi, gridrefine=3, thickness=2):

plots:-implicitplot(b, y=-10..25, theta=0..2*Pi, gridrefine=3, thickness=2):

plots[display](<%% | %>);

         

 

 

 

@spalinowy  I do not understand what your problem. Please download the Maple worksheet in which you received the wrong matrices.

@Joe Riel  Thank you! Unfortunately,  Iterator  package works for me only with  compile=false option. I already wrote about this  here . Maybe you know the reason for this?

@Carl Love  Thank you! In fact, if you remove remember option,  combinat[permute]  works, but 10 times slower than Permute  procedure. See

restart;

P := proc(a, r := nops(a))

local i, k, p, t;

if r = 0 then [[]] else p := NULL;

for i to nops(a) do member(a[i], a, 'k');

if k < i then next end if; t := P(subsop(i = NULL, a), r-1);

p := p, seq([a[i], op(k)], k = t) end do;

[p]; end if;

end proc:

 

L := CodeTools[Usage](P([$1 .. 10])):

 nops(L);

   memory used=5.50GiB, alloc change=0.75GiB, cpu time=3.85m, real time=2.99m, gc time=101.58s

                                                                         3628800

 

Therefore,  remember option is not the only reason for the inefficiency of combinat[permute] command. 

 

@John Fredsted 

for i while i<=5 do

 i;

end do;

@vv  Thank you!  Your version with  compile = false option works wonderfully.

@acer  You wrote "Does the Compiler work at all for you?"  I've explicitly never used  Compiler  and do not know how to answer your question. 

@vv  For some reason, your program does not work on my comp (32 bit Маple  2016.1 on Windows 8.1 ):

Download Error.mw

@Carl Love  Thank you!  I am surprised that you have found something essentially new in my procedure. In fact, it is conceptually very close to  CartProdSeq  procedure and also uses  foldl  command. The only difference is that you first create the whole list (a Cartesian product), and then in for loop enumerates it. This may cause problems with memory, if the original list is long. In my version  the construction of the desired objects occurs dynamically in the process of enumeration in nested sequences.

Here is the example illustrating the above. Problem: find the number of elements from  Cartesian product  [$ 0..9]^8  (total  10^8 elements)  that sum of the first four numbers is equal to the sum of the remaining numbers  (for example, [1,3,9,2,5,0,5,5] satisfies the condition).

restart:

CartProdSeq:= proc(L::seq(list), $)

local S,j;

    eval(subs(S= seq, foldl(S, [_i||(1..nargs)], seq(_i||j= L[j], j= 1..nargs))))

end proc:

 

k:=0:

for M in CartProdSeq([$0..9] $ 8) do

if `+`(M[1..4][])=`+`(M[5..8][]) then k:=k+1 fi;

od:

k;   

 

Error, (in CartProdSeq) Maple was unable to allocate enough memory to complete this computation.  Please see ?alloc

 

restart;

NestedSeq:=proc(Expr::uneval, L::list)

local S;

eval(subs(S=seq, foldl(S, Expr, op(L))));

end proc:

 

M:=[i||(1..8)]:

NestedSeq(`if`(`+`(M[1..4][])=`+`(M[5..8][]), 1, NULL), M=~0..9):

`+`(%);

                                                                 4816030

Edited.

This example:

result := ODETools[convertsys]({(D(x))(t) = x(t), ((D@@2)(y))(t) = y(t)-x(t)}, {}, {x(t), y(t)}, t);

[[YP[1] = Y[1], YP[2] = Y[3], YP[3] = Y[2]-Y[1]], [Y[1] = x(t), Y[2] = y(t), Y[3] = diff(y(t), t)], undefined, []]

(1)

NULL

subs(YP[1] = toto, result[1, 1]);

YP[1] = Y[1]

(2)

subs(lhs(result[1, 1]) = toto, result[1, 1]);

toto = Y[1]

(3)

``

 

Download convertsys.mw

 


 

 

First 79 80 81 82 83 84 85 Last Page 81 of 133