Carl Love

Carl Love

28075 Reputation

25 Badges

13 years, 77 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@acer Hmm. My first inclination was to try to pass a view spec to draw, but upon checking ?geometry,draw I saw that it wasn't one of the supported options. So that help page is wrong. But, anyway, your way---nullifying the VIEW spec---is definitely superior. Vote up.

Surprisingly, the VIEW can't be nullfied by

draw(L1, view= [DEFAULT$2]);
Error, (in geometry:-draw) improper op or subscript selector


For those who prefer minimalist code: In the subsindets, z-> NULL can be replaced by 'NULL'. That leads to this curiousity:

subsindets(draw(L1), specfunc(VIEW), ''()'');

produces the same (correct) plot and then gives the unusually formatted error message

Plot Internal Error:unrecognised option Dag in Plot:null

@sikjw1305 

Here's a resource-usage comparison for partitioning into pairs using Iterator:-SetPartitionFixedSize and using combinat:-setpartition. The former requires some significant post-processing to get it to match the format of the latter, but as we can see below, it's worth it.

restart:

AllPairPartitions:= proc(n::And(posint,even))
local p, `n/2`:= n/2;
     {seq([seq([p[2*k-1], p[2*k]], k= 1..`n/2`)],
      p= Iterator:-SetPartitionFixedSize([2$`n/2`]))
     }
end proc:

ByCombinat:= (n::And(posint,even))-> {combinat:-setpartition([$1..n], 2)[]}:     

 

It's not really fair to count the compilation time because it only occurs the first time that the Iterator is used.

CodeTools:-Usage(AllPairPartitions(2)):

memory used=9.55MiB, alloc change=32.00MiB, cpu time=156.00ms, real time=158.00ms, gc time=0ns

CodeTools:-Usage(ByCombinat(2)):

memory used=30.49KiB, alloc change=0 bytes, cpu time=0ns, real time=2.00ms, gc time=0ns

P1:= CodeTools:-Usage(AllPairPartitions(12)):

memory used=4.49MiB, alloc change=0 bytes, cpu time=78.00ms, real time=85.00ms, gc time=0ns

P2:= CodeTools:-Usage(ByCombinat(12)):

memory used=76.65MiB, alloc change=4.00MiB, cpu time=719.00ms, real time=714.00ms, gc time=46.88ms

 

Verify that the two procedures produce the same output.

evalb(P1=P2);

true

 


Download Iterator_vs_combinat.mw

@Thomas Dean It's possible to calculate the exact values in this problem. Just remove the evalfs.

@mojtaba75 Unfortunately, those file download links don't work.

You should never use a variable in an indexed form (beta[1,2]) and an unindexed form (beta) in the same computation as if they were separate variables. They aren't separate variables. But beta__12 and beta are separate variables.

Assuming that Kitonum's interpretation of the second problem is correct (I have some skepticism because the OP said "24", not "48"), here is the same solution using package Iterator. This generalizes Kitonum's solution to an arbitrary number of subfactors.

Bijections:= proc(A::list, B::And(list, satisfies(B-> nops(B)=nops(A))))
local b;
     [seq(zip(`[]`, A, convert(b[],list)), b= Iterator:-Permute(B))]
end proc:

ProductOfBijections:= proc(A::list(list), B::And(list(list), satisfies(B-> nops~(A)=nops~(B))))
uses It= Iterator;
local p, n:= add(nops~(A));
     [seq(op~(convert(p[], list))[..n], p= It:-CartesianProduct(zip(Bijections, A, B)[]))]
end proc:

ProductOfBijections([[3,5],[6,7,9,12]], [[8,10],[1,2,4,11]]);

[[[3, 8], [5, 10], [6, 1], [7, 2], [9, 4], [12, 11]], [[3, 10], [5, 8], [6, 1], [7, 2], [9, 4], [12, 11]], [[3, 10], [5, 8], [6, 1], [7, 2], [9, 11], [12, 4]], [[3, 8], [5, 10], [6, 1], [7, 2], [9, 11], [12, 4]], [[3, 8], [5, 10], [6, 1], [7, 4], [9, 2], [12, 11]], [[3, 10], [5, 8], [6, 1], [7, 4], [9, 2], [12, 11]], [[3, 10], [5, 8], [6, 1], [7, 4], [9, 11], [12, 2]], [[3, 8], [5, 10], [6, 1], [7, 4], [9, 11], [12, 2]], [[3, 8], [5, 10], [6, 1], [7, 11], [9, 2], [12, 4]], [[3, 10], [5, 8], [6, 1], [7, 11], [9, 2], [12, 4]], [[3, 10], [5, 8], [6, 1], [7, 11], [9, 4], [12, 2]], [[3, 8], [5, 10], [6, 1], [7, 11], [9, 4], [12, 2]], [[3, 8], [5, 10], [6, 2], [7, 1], [9, 4], [12, 11]], [[3, 10], [5, 8], [6, 2], [7, 1], [9, 4], [12, 11]], [[3, 10], [5, 8], [6, 2], [7, 1], [9, 11], [12, 4]], [[3, 8], [5, 10], [6, 2], [7, 1], [9, 11], [12, 4]], [[3, 8], [5, 10], [6, 2], [7, 4], [9, 1], [12, 11]], [[3, 10], [5, 8], [6, 2], [7, 4], [9, 1], [12, 11]], [[3, 10], [5, 8], [6, 2], [7, 4], [9, 11], [12, 1]], [[3, 8], [5, 10], [6, 2], [7, 4], [9, 11], [12, 1]], [[3, 8], [5, 10], [6, 2], [7, 11], [9, 1], [12, 4]], [[3, 10], [5, 8], [6, 2], [7, 11], [9, 1], [12, 4]], [[3, 10], [5, 8], [6, 2], [7, 11], [9, 4], [12, 1]], [[3, 8], [5, 10], [6, 2], [7, 11], [9, 4], [12, 1]], [[3, 8], [5, 10], [6, 4], [7, 1], [9, 2], [12, 11]], [[3, 10], [5, 8], [6, 4], [7, 1], [9, 2], [12, 11]], [[3, 10], [5, 8], [6, 4], [7, 1], [9, 11], [12, 2]], [[3, 8], [5, 10], [6, 4], [7, 1], [9, 11], [12, 2]], [[3, 8], [5, 10], [6, 4], [7, 2], [9, 1], [12, 11]], [[3, 10], [5, 8], [6, 4], [7, 2], [9, 1], [12, 11]], [[3, 10], [5, 8], [6, 4], [7, 2], [9, 11], [12, 1]], [[3, 8], [5, 10], [6, 4], [7, 2], [9, 11], [12, 1]], [[3, 8], [5, 10], [6, 4], [7, 11], [9, 1], [12, 2]], [[3, 10], [5, 8], [6, 4], [7, 11], [9, 1], [12, 2]], [[3, 10], [5, 8], [6, 4], [7, 11], [9, 2], [12, 1]], [[3, 8], [5, 10], [6, 4], [7, 11], [9, 2], [12, 1]], [[3, 8], [5, 10], [6, 11], [7, 1], [9, 2], [12, 4]], [[3, 10], [5, 8], [6, 11], [7, 1], [9, 2], [12, 4]], [[3, 10], [5, 8], [6, 11], [7, 1], [9, 4], [12, 2]], [[3, 8], [5, 10], [6, 11], [7, 1], [9, 4], [12, 2]], [[3, 8], [5, 10], [6, 11], [7, 2], [9, 1], [12, 4]], [[3, 10], [5, 8], [6, 11], [7, 2], [9, 1], [12, 4]], [[3, 10], [5, 8], [6, 11], [7, 2], [9, 4], [12, 1]], [[3, 8], [5, 10], [6, 11], [7, 2], [9, 4], [12, 1]], [[3, 8], [5, 10], [6, 11], [7, 4], [9, 1], [12, 2]], [[3, 10], [5, 8], [6, 11], [7, 4], [9, 1], [12, 2]], [[3, 10], [5, 8], [6, 11], [7, 4], [9, 2], [12, 1]], [[3, 8], [5, 10], [6, 11], [7, 4], [9, 2], [12, 1]]]

@Thomas Dean From the strip of choices at the bottom of your Question, click on the rightmost one, More. Select Edit from the pill-down menu.

@mskalsi I don't understand it. Hopefully Edgardo Cheb-Terrab will step in here to explain what's going on.

@sikjw1305 I don't understand how to use setpartition for this purpose. Would you please show an explicit example?

There's a lot of overlap of functionality between packages Iterator and combinat with the former generally being more efficient both with time and memory. Iterator has its own version of setpartition called SetPartitionFixedSize.

@mskalsi I don't understand why this one didn't need value. Since the expression is constructed with capital-D Diff, it should require it. Maybe it has something to do with u being an unassigned symbol in your current example.

What happened with your first example? Was the value required there? If I don't use it, the result ofdchange has the derivative unevaluated. In the worksheet below, notice the subscript t outside the whole expression.


restart:

with(PDEtools):

DepVars := [F(xi), G(xi)]

[F(xi), G(xi)]

alias(F = F(xi), G = G(eta))

F, G

declare(F, G(xi))

F(xi)*`will now be displayed as`*F

G(xi)*`will now be displayed as`*G

u := a[0]+(F*a[1]+G*a[2]+kappa[1])/(mu[0]+mu[1]*(diff(F, xi))+mu[2]*(diff(G, eta)))+(F^2*a[3]+F*G*a[4]+G^2*a[5]+kappa[2])/(mu[0]+mu[1]*(diff(F, xi))+mu[2]*(diff(G, eta)))^2

a[0]+(a[1]*F+a[2]*G+kappa[1])/(mu[0]+mu[1]*(diff(F, xi))+mu[2]*(diff(G, eta)))+(a[3]*F^2+a[4]*F*G+a[5]*G^2+kappa[2])/(mu[0]+mu[1]*(diff(F, xi))+mu[2]*(diff(G, eta)))^2

PDEtools:-dchange({xi= k[1]*x-k[1]*c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2])/(mu[0]+mu[1]*(D(F))(-t*c[1]*k[1]+x*k[1])+mu[2]*(D(G))(-t*c[2]*k[2]+x*k[2]))^2-2*(a[3]*F(-t*c[1]*k[1]+x*k[1])^2+a[4]*F(-t*c[1]*k[1]+x*k[1])*G(-t*c[2]*k[2]+x*k[2])+a[5]*G(-t*c[2]*k[2]+x*k[2])^2+kappa[2])*(-mu[1]*((D@@2)(F))(-t*c[1]*k[1]+x*k[1])*c[1]*k[1]-mu[2]*((D@@2)(G))(-t*c[2]*k[2]+x*k[2])*c[2]*k[2])/(mu[0]+mu[1]*(D(F))(-t*c[1]*k[1]+x*k[1])+mu[2]*(D(G))(-t*c[2]*k[2]+x*k[2]))^3

 


Download [1063]_Sub-equation_Method.mw

 

@one man Did you make the GIF file with Maple, or did you use some external utility to compress it?

Are the entries of A rational functions?

Can you provide a small example of A, say, with N=2?

@Carl Love In the above Answer, why does value(PDEtools:-dchange(...)) not work? It seems to return unevaluated.

You asked:

I'd like to know why did you use depends? Why not simply
B::And(list, satisfies(B-> nops(B)=nops(A)))

I wasn't aware that the depends isn't necessary. Now I see that it isn't. I thought that whenever the type check for one parameter referred to another parameter that depends was needed (see ?parameter_modifiers), but apparently that isn't true.

Is the newer satisfies more efficient than the classical if?

I don't think that satisfies is significantly newer than if. I'd guess that the if is slightly more efficient. The choice is stylistic: Maple is moving to have more and more of the error checking and argument processing done in the procedure headers. A great number of pages of the Maple Programming Guide are devoted to this.

In the previous Bij procedure, the variable b was not declared local.
It should be local but type(b,`local`) gives false and type(b,`global`) also false. Why?
Edit. Ok, it should be type('b',`local`) , type('b',`global`)  and ==> false and true
but even if global,  a global variable b at top level seems to be not affected.
(I.e. b seems to be still local, but type sees the global variable, since it is not declared explicitely. Is it so?)

The index variables of seq, add, and mul have a very special (and poorly documented) status in Maple. In the vast majority of cases, there's no need to declare them. I think that the only time that they need to be declared local is when the corresponding global has been protected.

@one man Did you use a GIF file? How many frames are in your animation? My color gradations are continuous.

First 416 417 418 419 420 421 422 Last Page 418 of 709