Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

At this point, it looks like either t or y has been inadvertently assigned a value. I can't tell without seeing your complete code. Please post a worksheet.

After receiving the error, check if either t or y has a value by simply entering

t; y;

Change Diff to diff. Maple 18 accepts Diff, but earlier Maple does not accept it for the DEplot command. (I find this change surprising.)

@Chia You are combining the results of the animate command, display(..., insequence), and the viewpoint option. According to the documentation that is not allowed. However, it produces no error and does seem to produce some possibly useful results. But let's first master the viewpoint option itself before trying to combine it in undocumented ways.

To that end, have you read the page ?plot3d,viewpoint ? Do you understand the significance of the look and upvector options? location is the location of the camera, look is the point the camera is pointed at, and upvector is the direction the appears up in the camera's view.

I've noticed that even viewpoint will not zoom in on text---the text will always be the same plot size. Also, you cannot change the orientation of text.

@Kitonum You wrote:

Zooming into a 2d is already implemented in Maple (version 16). See  ?worksheet,plotinterface,zoom

That is zooming with a mouse rather than being a form of animation. I do bemoan the fact that there are Maple actions possible with a mouse which are not possible programmatically.

Addition: in older versions zooming can be done by scaling along axes.

It is not possible with tickmarks on the axes. I notice that you removed the tickmarks from yours. With a simple curve, the spreading of the tickmarks is essential to providing the illusion that one is moving closer to the plot rather than that the plot is moving at a fixed distance.  

@tomet 

A:-B is the syntax for accessing member B from module A. Most packages are modules, so VectorCalculus:-Norm means "Use the Norm from the VectorCalculus package rather than, say, the Norm from the LinearAlgebra package." It is not robust to rely on the with command working inside a procedure (and an arrow (->) expression is a procedure).

The error that you had in the attached worksheet is the result of very bad design on MapleSoft's part. This only applies if you are using 2d input (I can tell from your worksheet that you are). When you enter something with an underscore such as E_abs, Maple thinks that you are indexing E. Since you do have a variable named E, this causes problems. The problem can be fixed by changing E_abs to Eabs.

The 2d input is loaded with traps like that. I suggest using 1d input instead.

@Carl Love 

Here are some comparable commands:

time(RandomTools:-Generate('Matrix'(float(method= uniform), 1000, 1000)));

     0.671

time(LinearAlgebra:-RandomMatrix(1000, 1000, generator= 0..1.0));

     1.359

@vhha1972 Sorry, but I don't understand it myself. My education in this theory is lacking.

@alpha041 Here's the worksheet with the working ApplyWeights command.


restart:

randomize(2): #Needed to get nontrivial minimal paths.

N:= 100:  #Number of vertices

E:= 2300: #Number if directed edges

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

local Seq,i,j;

option `Copyright (C) 2007, Joseph Riel. All rights reserved.`;

    eval({subs(Seq=seq, foldl(Seq

                              , [cat(i,1..nargs)]

                              , seq(cat(i,j)=L[j],j=nargs..1,-1)

                             ))});

end proc:


AllPossibleEdges:= [
     (CartProdSeq([$1..N], [$1..N]) minus
           {seq([k,k], k= 1..N)}
      )[]
]:

Edges:= combinat:-randcomb(AllPossibleEdges, E):

Weights1:= RandomTools:-Generate(list(float(method= uniform), E)):

WeightedEdges1:= {zip(`[]`, Edges, Weights1)[]}:

G1:= GraphTheory:-Graph(WeightedEdges1);

GRAPHLN(directed, weighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], Array(%id = 18446744074187374710), `GRAPHLN/table/1`, Matrix(%id = 18446744074216096014))

Weights2:= RandomTools:-Generate(list(float(method= uniform), E)):

WeightedEdges2:= {zip(`[]`, Edges, Weights2)[]}:

G2:= GraphTheory:-Graph(WeightedEdges2);

GRAPHLN(directed, weighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], Array(%id = 18446744074187375070), `GRAPHLN/table/2`, Matrix(%id = 18446744074198802974))

(Path1,Cost1):= GraphTheory:-DijkstrasAlgorithm(G1, 1, N)[];

[1, 31, 52, 58, 54, 14, 100], .199037223686419

(Path2,Cost2):= GraphTheory:-DijkstrasAlgorithm(G2, 1, N)[];

[1, 49, 24, 5, 14, 100], .418737682605255

Path_to_Edges:= proc(P::list)
local k;
     {seq([P[k], P[k+1]], k= 1..nops(P)-1)}
end proc:


PPath1:= Path_to_Edges(Path1);

{[1, 31], [14, 100], [31, 52], [52, 58], [54, 14], [58, 54]}

PPath2:= Path_to_Edges(Path2);

{[1, 49], [5, 14], [14, 100], [24, 5], [49, 24]}

G3:= GraphTheory:-Graph(PPath1 union PPath2);

GRAPHLN(directed, unweighted, [1, 5, 14, 24, 31, 49, 52, 54, 58, 100], Array(%id = 18446744074187376150), `GRAPHLN/table/3`, 0)

WeightOfPath:= proc(G::GraphTheory:-Graph, P::list)
local
     e,
     W:= GraphTheory:-WeightMatrix(G, copy= false)
;
     add(W[e[]], e in Path_to_Edges(P))
end proc:


WeightOfPath(G1, Path1);

.199037223686419

WeightOfPath(G2, Path2);

.418737682605255

ApplyWeights:= proc(G1::GraphTheory:-Graph, G2::GraphTheory:-Graph)
#Apply the weights from G1 to G2.
uses GT= GraphTheory;
local W:= GT:-WeightMatrix(G1, copy= false);
     GT:-Graph(
          map(e-> [e, W[e[]]], GT:-Edges(G2, weights= false))
     )
end proc:          


G4:= ApplyWeights(G1, G3);

GRAPHLN(directed, weighted, [1, 5, 14, 24, 31, 49, 52, 54, 58, 100], Array(%id = 18446744074187376390), `GRAPHLN/table/4`, Matrix(%id = 18446744074198482110))

G5:= ApplyWeights(G2, G3);

GRAPHLN(directed, weighted, [1, 5, 14, 24, 31, 49, 52, 54, 58, 100], Array(%id = 18446744074187376630), `GRAPHLN/table/5`, Matrix(%id = 18446744074211497430))

 


Download Two_Paths.mw

@jentox The error message indicates that it is not recognizing the ExcelTools package. Try putting

with(ExcelTools);

on a line by itself and reporting to us the results.

Please attach your worksheet so that we can work with it. Use the green up-arrow, which is the last item on the second row of the toolbar in the MaplePrimes editor.

Forward compatibility has nothing to do with it. Maple is backward compatible, which is what you need. Backward compatible means that code written for older versions still runs on newer versions.

Rather than using cut-and-paste, you can use the read command to input your module. It's simply

read "filename";

@alpha041 Well, like I asked before, suppose that the two paths have a common edge, but that the weights are different in the two representations. How do you choose the weight for that edge?

@alpha041 I just answered this question in your other thread, "paths in graph". Your problem was that edges need to be represented by pairs. A path representation such as [1, 5, 9, 100] will not work. That needs to be converted to {[1,5], [5,9], [9,100]}.

inttrans[fourier](3*cos(2000*Pi*t), t, f);

Also, we need to know u__1[i] and u__2[i] or have recursive equations for them.

First 538 539 540 541 542 543 544 Last Page 540 of 709