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

@acer Your technique doesn't work the way that you expect it to. The 5 of the outer evalf supercedes the Digits used by the inner evalf, so the inner evalf is being done at 5-digits precision. Here's a test that shows this:

x:= 1+1e-6:  y:= 1+2e-6:
evalf[5](evalf(y-x));

                               0.
evalf(y-x):  evalf[5](%);
                            0.000001

So, evalf violates the usual rule that arguments are evaluated before being passed!

 

Your attempt to write Maple code doesn't shed much light on your problem. I think that you should take a step back, forget about Maple, and try to describe your problem mathematically. You're trying to solve a differential equation, right? ordinary or partial? numeric or symbolic solution? You mentioned Poincare's theorem (in an earlier version of this Question). You mentioned a change of variables. Now put it all together into a clear mathematical statement of the problem.

@gtbastos Do you want all 4x4 matrices of 0s and 1s of rank 3 or 4 over GF(3)? Or do you want all 4x4 matrices of rank 3 or 4 over GF(3)?

@Carl Love Your system contains no derivatives taken with respect to x. So it's a system of ODEs, not PDEs. So it should be solved numerically with dsolve, treating x as a parameter. Parameters in BVPs in Maple are handled by specifying one additional BC per parameter.

@Carl Love Your error is caused by your double use of square brackets on IBC. You have square brackets where you set the value of IBC, and you have them around IBC in the pdsolve command.

If you fix that problem, then you get an error because none of the IBCs set the value of x. That means that you'll need to rethink this problem. Also note that the trivial solution f(x,y) = 0 = g(x,y) is a solution to this problem. This is the only solution that a numerical solver will find.

@Kitonum Simpler: plot(<x | y>);

@karolin In order that all the intersections appeared neatly in the interior of the plot, I stretched the plot's viewing range of x and y a little on each side. The amount of stretch on each side is 1/3 the distance between the min and max. With the way that I did it, you should be able to reuse the plot command without change for other sets of curves.

@brian bovril The command that you need is

MM[MM[`+tour dists`] =~ min(MM[`+tour dists`])];

You say that you need "to find the area enclosed between the two". But two straight lines can't possibly enclose any area. There must be at least one more boundary curve. Often one of the boundaries is one of the coordinate axes. In this case, that could be the x-axis. But don't assume this! If the problem doesn't explicitly state this, the proper answer is to state that the problem is improperly posed.

You claim that you're using Maple 8, which is a very old version. The ability to solve delay differential equations was only recently added to Maple AFAIK.

The given Matlab code can't possibly do anything useful. Perhaps you should take a step back and describe your overall goal.

@brian bovril This is an ideal application for the new data structure DataFrame, which is somewhat between a Matrix and a table.

Regarding the specific uneven length list problem: You need to use add~ rather than  add.

If you don't want to bother me, then display your worksheets in your posts rather than simply attaching a worksheet.
 

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:

demand:= proc(tour::list(posint))
   option remember;  
   add(d[tour[2..]])
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]]]

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]]

Demand_Reqd:= (demand~)~(Tour2);

[[30, 55], [18, 30, 37], [26, 30, 29], [11, 30, 44], [18, 26, 11, 30], [85], [48, 37], [18, 67], [29, 56], [26, 59], [44, 41], [11, 74], [26, 11, 48], [18, 11, 56], [18, 26, 41]]

SumT_D:= add~(Tours_Distances);

[99, 125, 113, 110, 136, 98, 118, 124, 104, 112, 109, 101, 129, 127, 135]

SumD_D:= add~(Demand_Reqd);

[85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85]

MM:= Matrix((6,L), [[$1..L], Tour2, Tours_Distances, SumT_D,Demand_Reqd, SumD_D])^%T;

MM := Matrix(15, 6, {(1, 1) = 1, (1, 2) = [[1, 5], [1, 2, 3, 4]], (1, 3) = [14, 85], (1, 4) = 99, (1, 5) = [30, 55], (1, 6) = 85, (2, 1) = 2, (2, 2) = [[1, 2], [1, 5], [1, 3, 4]], (2, 3) = [52, 14, 59], (2, 4) = 125, (2, 5) = [18, 30, 37], (2, 6) = 85, (3, 1) = 3, (3, 2) = [[1, 3], [1, 5], [1, 2, 4]], (3, 3) = [30, 14, 69], (3, 4) = 113, (3, 5) = [26, 30, 29], (3, 6) = 85, (4, 1) = 4, (4, 2) = [[1, 4], [1, 5], [1, 2, 3]], (4, 3) = [40, 14, 56], (4, 4) = 110, (4, 5) = [11, 30, 44], (4, 6) = 85, (5, 1) = 5, (5, 2) = [[1, 2], [1, 3], [1, 4], [1, 5]], (5, 3) = [52, 30, 40, 14], (5, 4) = 136, (5, 5) = [18, 26, 11, 30], (5, 6) = 85, (6, 1) = 6, (6, 2) = [[1, 2, 3, 4, 5]], (6, 3) = [98], (6, 4) = 98, (6, 5) = [85], (6, 6) = 85, (7, 1) = 7, (7, 2) = [[1, 2, 5], [1, 3, 4]], (7, 3) = [59, 59], (7, 4) = 118, (7, 5) = [48, 37], (7, 6) = 85, (8, 1) = 8, (8, 2) = [[1, 2], [1, 3, 4, 5]], (8, 3) = [52, 72], (8, 4) = 124, (8, 5) = [18, 67], (8, 6) = 85, (9, 1) = 9, (9, 2) = [[1, 2, 4], [1, 3, 5]], (9, 3) = [69, 35], (9, 4) = 104, (9, 5) = [29, 56], (9, 6) = 85, (10, 1) = 10, (10, 2) = [[1, 3], [1, 2, 4, 5]], (10, 3) = [30, 82], (10, 4) = 112, (10, 5) = [26, 59], (10, 6) = 85, (11, 1) = 11, (11, 2) = [[1, 2, 3], [1, 4, 5]], (11, 3) = [56, 53], (11, 4) = 109, (11, 5) = [44, 41], (11, 6) = 85, (12, 1) = 12, (12, 2) = [[1, 4], [1, 2, 3, 5]], (12, 3) = [40, 61], (12, 4) = 101, (12, 5) = [11, 74], (12, 6) = 85, (13, 1) = 13, (13, 2) = [[1, 3], [1, 4], [1, 2, 5]], (13, 3) = [30, 40, 59], (13, 4) = 129, (13, 5) = [26, 11, 48], (13, 6) = 85, (14, 1) = 14, (14, 2) = [[1, 2], [1, 4], [1, 3, 5]], (14, 3) = [52, 40, 35], (14, 4) = 127, (14, 5) = [18, 11, 56], (14, 6) = 85, (15, 1) = 15, (15, 2) = [[1, 2], [1, 3], [1, 4, 5]], (15, 3) = [52, 30, 53], (15, 4) = 135, (15, 5) = [18, 26, 41], (15, 6) = 85})

MM:= DataFrame(
   <<Tour2> | <Tours_Distances> | <SumT_D> | <Demand_Reqd> | <SumD_D>>,  
   columns= [tour, `tour dists`, `+tour dists`, `dmnd rqd`, `+dmnd rqd`],
   datatypes= [list(list(posint)), list(positive), positive, list(nonnegative), nonnegative]
);

MM := Matrix(16, 6, {(1, 1) = ``, (1, 2) = tour, (1, 3) = `tour dists`, (1, 4) = `+tour dists`, (1, 5) = `dmnd rqd`, (1, 6) = `+dmnd rqd`, (2, 1) = 1, (2, 2) = [[1, 5], [1, 2, 3, 4]], (2, 3) = [14, 85], (2, 4) = 99, (2, 5) = [30, 55], (2, 6) = 85, (3, 1) = 2, (3, 2) = [[1, 2], [1, 5], [1, 3, 4]], (3, 3) = [52, 14, 59], (3, 4) = 125, (3, 5) = [18, 30, 37], (3, 6) = 85, (4, 1) = 3, (4, 2) = [[1, 3], [1, 5], [1, 2, 4]], (4, 3) = [30, 14, 69], (4, 4) = 113, (4, 5) = [26, 30, 29], (4, 6) = 85, (5, 1) = 4, (5, 2) = [[1, 4], [1, 5], [1, 2, 3]], (5, 3) = [40, 14, 56], (5, 4) = 110, (5, 5) = [11, 30, 44], (5, 6) = 85, (6, 1) = 5, (6, 2) = [[1, 2], [1, 3], [1, 4], [1, 5]], (6, 3) = [52, 30, 40, 14], (6, 4) = 136, (6, 5) = [18, 26, 11, 30], (6, 6) = 85, (7, 1) = 6, (7, 2) = [[1, 2, 3, 4, 5]], (7, 3) = [98], (7, 4) = 98, (7, 5) = [85], (7, 6) = 85, (8, 1) = 7, (8, 2) = [[1, 2, 5], [1, 3, 4]], (8, 3) = [59, 59], (8, 4) = 118, (8, 5) = [48, 37], (8, 6) = 85, (9, 1) = 8, (9, 2) = [[1, 2], [1, 3, 4, 5]], (9, 3) = [52, 72], (9, 4) = 124, (9, 5) = [18, 67], (9, 6) = 85, (10, 1) = 9, (10, 2) = [[1, 2, 4], [1, 3, 5]], (10, 3) = [69, 35], (10, 4) = 104, (10, 5) = [29, 56], (10, 6) = 85, (11, 1) = 10, (11, 2) = [[1, 3], [1, 2, 4, 5]], (11, 3) = [30, 82], (11, 4) = 112, (11, 5) = [26, 59], (11, 6) = 85, (12, 1) = 11, (12, 2) = [[1, 2, 3], [1, 4, 5]], (12, 3) = [56, 53], (12, 4) = 109, (12, 5) = [44, 41], (12, 6) = 85, (13, 1) = 12, (13, 2) = [[1, 4], [1, 2, 3, 5]], (13, 3) = [40, 61], (13, 4) = 101, (13, 5) = [11, 74], (13, 6) = 85, (14, 1) = 13, (14, 2) = [[1, 3], [1, 4], [1, 2, 5]], (14, 3) = [30, 40, 59], (14, 4) = 129, (14, 5) = [26, 11, 48], (14, 6) = 85, (15, 1) = 14, (15, 2) = [[1, 2], [1, 4], [1, 3, 5]], (15, 3) = [52, 40, 35], (15, 4) = 127, (15, 5) = [18, 11, 56], (15, 6) = 85, (16, 1) = 15, (16, 2) = [[1, 2], [1, 3], [1, 4, 5]], (16, 3) = [52, 30, 53], (16, 4) = 135, (16, 5) = [18, 26, 41], (16, 6) = 85})

MM[MM[`+tour dists`] >=~ 98 and MM[`+tour dists`] <=~ 99];
 

Matrix([[``, tour, `tour dists`, `+tour dists`, `dmnd rqd`, `+dmnd rqd`], [1, [[1, 5], [1, 2, 3, 4]], [14, 85], 99, [30, 55], 85], [6, [[1, 2, 3, 4, 5]], [98], 98, [85], 85]])

``


 

Download Tours_CL_between.mw

@tomleslie A vector space is built on top of an underlying number system called a field. Usually the field is the real or complex numbers. But all that's required for a field are closure of the operations addition, multiplication, and subtraction; closure of division on the set minus zero; commutivity and associativity of both addition and multiplication; and distributivity of multiplication over addition. The smallest possible field has just two elements, 0 and 1. (Here, 0 and 1 are symbols related to, but not identical to, the usual 0 and 1. You could just as well use false for 0 and true for 1.) The multiplication is the same as usual. The addition is the same as usual except that 1+1 = 0. (If you recognize this as Boolean algebra with + = xor, * = and, 0 = false, 1 = true, then you've recognized correctly.) This field is often called GF(2), GF standing for (Evariste) Galois field, and 2 because it has 2 elements. It turns out that (upto isomorphism) this is the only possible field with 2 elements. This is the field over which the OP is considering matrix operations.

@Joe Riel When used with datatype= float[8], Modular uses the extremely well-optimized Basic Linear Algebra Subprograms (BLAS). There's no theoretic reason why float[8] is faster than integer[8]; it's simply that far more work has been to optimize it, down to the hardware level.

@Joe Riel Using datatype= float[8] with LinearAlgebra:-Modular is much faster than datatype= integer. The package is also slightly faster using order= C_order.

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