Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 363 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

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)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(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]))^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.

@Axel Vogt I would modify your procedure so that it produces output which can always be parsed back to its original form and such that that output can be properly indented, which ending lines with backslashes doesn't allow.

split_for_print:=proc(expr, len::posint)
#expr = any Maple expression
#len = length to split with line breaks
     printf("parse(\n");
     map2(printf, "     %v\n", [StringTools:-LengthSplit(sprintf("%a", expr), len)]);
     printf(")\n");
end proc:

Here we see that it produces properly indented output that can be copy-and-pasted anywhere:

split_for_print(evalf[119](Pi), 40);

     parse(
          "3.14159265358979323846264338327950288419"
          "7169399375105820974944592307816406286208"
          "9986280348253421170679821480865132823066"
     )

And here we see that it behaves correctly when the input is a complicated expression that already contains quote marks and backslashes (that's the purpose of the %v format):

split_for_print(eval(split_for_print), 40);

     parse(
          "proc (expr, len::posint) printf(\"parse(\\n\"); "
          "map2(printf,\"     %v\\n\",[StringTools:-Le"
          "ngthSplit(sprintf(\"%a\",expr),len)]); printf(\""
          ")\\n\") end proc"
     )

Now copy-and-paste that to an external file and back to an input prompt to test its executability:

SplitForPrint:= parse(
     "proc (expr, len::posint) printf(\"parse(\\n\"); "
     "map2(printf,\"     %v\\n\",[StringTools:-Le"
     "ngthSplit(sprintf(\"%a\",expr),len)]); printf(\""
     ")\\n\") end proc"
):
showstat(SplitForPrint);

     SplitForPrint := proc(expr, len::posint)
        1   printf("parse(\n");
        2   map2(printf,"     %v\n",[StringTools:-LengthSplit(sprintf("%a",expr),len)]);
        3   printf(")\n")
    end proc

You can see that it's identical to the original procedure.

By the way, all of the above works in both the Standard (with 1D input) and Classic GUIs.

@Ronan For example, a row vector can be entered as <1 | 2 | 3> or `<|>`(1, 2, 3). The latter is called prefix form because the operator comes before the operands. Almost every operator in Maple has a prefix form. Some more examples:

1 + 2 + 3       or `+`(1,2,3)
[1,2,3]           or `[]`(1,2,3)
A[1,2]               or `?[]`(A, [1,2])
f(a,b)                or `?()`(f, [a,b])
a or b                
or `or`(a,b)
[1,2] +~ [3,4] or `~`[`+`]([1,2], [3,4])

@testht06 Would it useful to you to have a procedure for it so that you could enter simply

M &^ (1/k) mod 2;

?

@Ronan I see that you've extended my block-matrix ideas to the <...,...;...,...operator, which, oddly enough, has no prefix form. 

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