Carl Love

Carl Love

28045 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Joe Riel LinearAlgebra:-Generic is a great (and highly abstract) package for working over arbitrary fields, and I appreciate your example showing how to use it. When the field is GF(p) for word-sized primes p, then the package LinearAlgebra:-Modular is an extremely fast (really astoundingly fast) alternative.

@tomleslie Tom, the OP doesn't want all the 4x4 binary matrices. They want the 4x4 binary matrices of rank 3 and 4 over GF(2). In this context, "rank" means the number of vector space dimensions spanned by the columns (or rows---it's the same number) of the matrix.

@gtbastos See below for my complete Answer to the rank problem over GF(2).

@Joe Riel Joe, your code may be an efficient way to count the matrices, but it doesn't save them (or any representation of them) because Iterator reuses the output rtable. Your line
found[cnt] := eval(p);
needs to be changed to something like
found[cnt]:= copy(M)

@Joe Riel Joe, I assume that the output that you used in the code above is a method implemented in Iterator. How is that done? Can you show the code or example code of something similar?

Your request seems a bit unusual at face value, although it's certainly easily done, as the other Answers show. Those Answers are computing the rank over the complex numbers. Did you want that, or did you want the rank over GF(2), which seems like a more-normal request?

@Jackk I think that you are trying to use the comma (,) in place of the decimal point (.). Certainly that's the way that it's done in many written human languages, but as far I know, in Maple you must use the decimal point. For example, 13/10 = 1.3 not 1,3.

@brian bovril Like this:
 

restart:

N:= 9:

Dist:= Matrix(
   N$2, shape= symmetric, scan= triangular,
   [0, op]~([[26,15,20,7 ,25,16,24,29],
                [15,23,26,33,40,38,54],
                   [24,13,20,27,35,43],
                      [26,42,34,15,39],
                         [18,14,31,32],
                            [25,49,45],
                               [32,20],
                                  [30]]
)):

d:=<0, 18, 26, 11, 30, 21, 16, 29, 37>:

Procedure "tour_length" calculates the length of a given tour.

tour_length:= proc(tour::list(posint))
   option remember;  
   add(Dist[tour[i],tour[i+1]], i= 1..nops(tour)-1) + Dist[tour[-1],tour[1]]
end proc:

P:= [$2..5]:

Tour2:= ([1,op]~)~(combinat:-setpartition(P));

[[[1, 5], [1, 2, 3, 4]], [[1, 2], [1, 5], [1, 3, 4]], [[1, 3], [1, 5], [1, 2, 4]], [[1, 4], [1, 5], [1, 2, 3]], [[1, 2], [1, 3], [1, 4], [1, 5]], [[1, 2, 3, 4, 5]], [[1, 2, 5], [1, 3, 4]], [[1, 2], [1, 3, 4, 5]], [[1, 2, 4], [1, 3, 5]], [[1, 3], [1, 2, 4, 5]], [[1, 2, 3], [1, 4, 5]], [[1, 4], [1, 2, 3, 5]], [[1, 3], [1, 4], [1, 2, 5]], [[1, 2], [1, 4], [1, 3, 5]], [[1, 2], [1, 3], [1, 4, 5]]]

M:= nops(Tour2):

Tours_Distances:= (tour_length~)~(Tour2);

[[14, 85], [52, 14, 59], [30, 14, 69], [40, 14, 56], [52, 30, 40, 14], [98], [59, 59], [52, 72], [69, 35], [30, 82], [56, 53], [40, 61], [30, 40, 59], [52, 40, 35], [52, 30, 53]]

MM:= Matrix((3,M), [[$1..M], Tour2, Tours_Distances])^%T;

MM := Matrix(15, 3, {(1, 1) = 1, (1, 2) = [[1, 5], [1, 2, 3, 4]], (1, 3) = [14, 85], (2, 1) = 2, (2, 2) = [[1, 2], [1, 5], [1, 3, 4]], (2, 3) = [52, 14, 59], (3, 1) = 3, (3, 2) = [[1, 3], [1, 5], [1, 2, 4]], (3, 3) = [30, 14, 69], (4, 1) = 4, (4, 2) = [[1, 4], [1, 5], [1, 2, 3]], (4, 3) = [40, 14, 56], (5, 1) = 5, (5, 2) = [[1, 2], [1, 3], [1, 4], [1, 5]], (5, 3) = [52, 30, 40, 14], (6, 1) = 6, (6, 2) = [[1, 2, 3, 4, 5]], (6, 3) = [98], (7, 1) = 7, (7, 2) = [[1, 2, 5], [1, 3, 4]], (7, 3) = [59, 59], (8, 1) = 8, (8, 2) = [[1, 2], [1, 3, 4, 5]], (8, 3) = [52, 72], (9, 1) = 9, (9, 2) = [[1, 2, 4], [1, 3, 5]], (9, 3) = [69, 35], (10, 1) = 10, (10, 2) = [[1, 3], [1, 2, 4, 5]], (10, 3) = [30, 82], (11, 1) = 11, (11, 2) = [[1, 2, 3], [1, 4, 5]], (11, 3) = [56, 53], (12, 1) = 12, (12, 2) = [[1, 4], [1, 2, 3, 5]], (12, 3) = [40, 61], (13, 1) = 13, (13, 2) = [[1, 3], [1, 4], [1, 2, 5]], (13, 3) = [30, 40, 59], (14, 1) = 14, (14, 2) = [[1, 2], [1, 4], [1, 3, 5]], (14, 3) = [52, 40, 35], (15, 1) = 15, (15, 2) = [[1, 2], [1, 3], [1, 4, 5]], (15, 3) = [52, 30, 53]})

LimitDist:= (L::positive)-> select(T-> max(tour_length~(T)) <= L, Tour2):

Ind:= proc(T::list(list(posint)))
   local p;
   member(T, Tour2, p);
   p
end proc:

MM[Ind~(LimitDist(56)), ..];

Matrix([[4, [[1, 4], [1, 5], [1, 2, 3]], [40, 14, 56]], [5, [[1, 2], [1, 3], [1, 4], [1, 5]], [52, 30, 40, 14]], [11, [[1, 2, 3], [1, 4, 5]], [56, 53]], [14, [[1, 2], [1, 4], [1, 3, 5]], [52, 40, 35]], [15, [[1, 2], [1, 3], [1, 4, 5]], [52, 30, 53]]])

``

``


 

Download Tours.mw

@BK The relevant DOS/Windows commands are CD and SET PATH=..., but I can't provide any more help than that. As I said, this error has nothing to do with Maple. Perhaps Acer can give a better example. Or, you could get better help on a Windows/DOS forum. A place to start might be a Google search on "how to set dos path".

@BK Since awk is not a standard Windows command but your batch file does run in a command window, I guess that you have some third-party version of awk installed. My guess is that you need to change the batch file so that its first command is to change the working directory (aka folder) so that it is the same as the one from which the batch did work. If I give Maple the command ssystem("dir"), it shows me that the working directory is C:\Program Files\Maple 2016. This is probably not the working directory that you were using when you successfully ran the batch file.

@BK That is an error due to the commands in the batch file. The error has absolutely nothing to do with Maple. It looks like you may be trying to run the Linux command awk on a Windows system. If that is what you're trying to do, it may help if you install a free program named Cygwin.


 

fq:= piecewise(
   p < -5, 0.,
   p < -3, .161711971*(p+5.)^3,
   p < -1, -1.798464149*p^2-.544033315*p+7.541565235-.3076373305*p^3,
   p < 1, 0.809338641e-1*p^3-.6327505649*p^2+.6216802691*p+7.930136430,
   p < 3, 0.7445052690e-1*p^3-.613300552*p^2+.602230257*p+7.936619768,
   p < 5, 0.19182821e-2*p^3+0.39489651e-1*p^2-1.35614035*p+9.894990378,
   p < 7, -0.256603524e-2*p^3+.106754411*p^2-1.69246414*p+10.45553002,
   p < 9, -0.254356370e-2*p^3+.106282509*p^2-1.68916084*p+10.44782231,
   p < 11, -0.2031067084e-1*p^3+.585994401*p^2-6.00656786*p+23.40004343,
   p < 13, 0.4137545813e-1*p^3-1.449647855*p^2+16.38549696*p-58.70419431,
   p < 15, -0.273325019e-1*(p-15.)^3,
   15 <= p, 0.
):
m:= piecewise(1 <= p and p <=9, fq):  


The above is the same input as you had in your posted worksheet. Now all you need to do is

simplify(m);

piecewise(p < 1, 0, p < 3, 0.7445052690e-1*p^3-.613300552*p^2+.602230257*p+7.936619768, p < 5, 0.19182821e-2*p^3+0.39489651e-1*p^2-1.35614035*p+9.894990378, p < 7, -0.256603524e-2*p^3+.106754411*p^2-1.69246414*p+10.45553002, p < 9, -0.254356370e-2*p^3+.106282509*p^2-1.68916084*p+10.44782231, p = 9, 2.00000012864, 9 < p, 0)

That's all there is to it: just simplify(m), like I originally said.


 

Download simplify_nested_piecewise.mw

@dellair Yes, I know what you want!!!  Have you tried the simplify command as I suggested???

@tomleslie What you're missing is that the OP wants a simplified algebraic representation of the nested piecewise expressions; they aren't interested in the plot.

@dellair So, do you understand?

First 363 364 365 366 367 368 369 Last Page 365 of 709