dharr

Dr. David Harrington

3491 Reputation

17 Badges

18 years, 97 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a professor of chemistry at the University of Victoria, BC, Canada, where my research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are replies submitted by dharr

ans1 is a 1..3, 1..13 Array, as may be seen by changing the : to ;. So ans1[12..14,3] leads to an indexing error, since 12 is not in the range 1..3.

By the way, why not just export the Array contents directly, rather than extracting them from a plot?

@ijuptilk Sorry, forgot about discont only for 2D. But at least in Maple 2015 I am not seeing a problem, though I didn't explore all ranges.

plot3d(y/(x+1)+1/(y^2-y), x = -3 .. 3, y = -3 .. 3, view = [default, default, -8 .. 8],
 style = surfacecontour);

gives

 

@ijuptilk use discont=true if there are discontinuities.

@Carl Love Excellent effort, going beyond. Vote up.

@mehdibgh Here's an example - words refers to memory usage. (The second PrintProfiles is for both calls to test.)
 

restart

with(CodeTools:-Profiling):

test:=proc(V,n)
  local i;
  for i to n do
    V(i):=i^2;
  end do;
  V;
end proc:

V := Vector[row]()

V := Vector[row](10, {(1) = 1, (2) = 4, (3) = 9, (4) = 16, (5) = 25, (6) = 36, (7) = 49, (8) = 64, (9) = 81, (10) = 100})

Profile(test);

test(V, 5)

Vector[row]([1, 4, 9, 16, 25, 36, 49, 64, 81, 100])

CodeTools:-Profiling:-PrintProfiles(test);

test

test := proc(V, n)
local i;
     |Calls Seconds  Words|
PROC |    1   0.000    191|
   1 |    1   0.000      0| for i to n do
   2 |    5   0.000    191|   V(i) := i^2
                            end do;
   3 |    1   0.000      0| V
end proc

test(V, 10)

Vector[row]([1, 4, 9, 16, 25, 36, 49, 64, 81, 100])

CodeTools:-Profiling:-PrintProfiles(test);

test

test := proc(V, n)
local i;
     |Calls Seconds  Words|
PROC |    2   0.000    286|
   1 |    2   0.000      0| for i to n do
   2 |   15   0.000    286|   V(i) := i^2
                            end do;
   3 |    2   0.000      0| V
end proc

``

 

Download Profile.mw

Maple has the CodeTools:-Profiling package to help you find where these limitations are. As a first step, you can put the critical part in a procedure and pass it to CodeTools:-Profiling:-Profile - see the help page for that.

@Ronan For URLs I think you need forward slashes always. For Maple filenames, forward slashes always work (platform independently), but on windows backslashes work, but need to be escaped, i.e., \\ is \

(I said the text file is opened by notepad, but actually it is by the browser.)

@jeremy_murphy Maple's combstruct package implements much of the material in Flajolet's book. One defines a combinatorial system, e.g., binary trees, using a (usually recursive) grammar, and then you can calculate the number of objects (trees) of a given size n (=number of leafs), list all objects of a given size, and find a generating function whose coefficients are the number of objects of the different sizes. The entropy would normally be ln(number of objects) (this is the Shannon formula when all objects have the same probability), or sometimes one has a "entropy constant" (see "hard hexagon entropy constant" on mathworld,com, which is the limit((number of objects of size n)^(1/n), n->infinity), or exp(entropy/size).

An example such as sequences of 1's and 2's that sum to n might be closer to what you are thinking, since there could be different probablities for sequences with different numbers of 2's.

The combstruct package is quite powerful but needs some practice to figure out. If you can be more specific about what you want, or want me to show an example I can do that. I think, however, that getting from the generating function to the entropy is non-trivial.

@Carl Love Number of states is clearer. I was confused about the use of n for the size of the combinatorial "object", and for the size of the "outcome alphabet". In the sorts of physics objects I tend to deal with, the size could be say n=5 for 5 sites, and then the number of states is the number of possibilities (with equal probabibilities or not) and is larger than that. The formula for entropy is the same. For equal probabilities the formula simplifies to ln(W), W = number of possibilities. The derived formula I gave is then the limiting entropy per site for n infinity. In this case the result can be viewed differently as a two-state system as you pointed out (we have moved from a micocanonical ensemble picture to a grand canonical ensemble picture in physics terminology).

Perhaps the OP can give some more specifics about the type of functions. But I'm guessing if any software can find a symbolic solution, Maple can!

 

@Carl Love As I recall, that was the standard for FORTRAN E format, and you needed a 1P modifier to get it the way it should be, i.e., as you stated.

The message is clear -- the presence of eta+S makes this a delay DE, and you have boundary conditions, e.g., theta(10)=0, and Maple can't solve such equations (except S=0).

@yasi 

Your figure had the z-axis going too high, so I solved that problem. Because you used "seq(0.312^i,i=1..4,1), which produces numbers equally spaced on a log axis, I pointed you in that direction. The tick labels in the list go at the numbers they represent. You want them "in the grid place". Surely you do not mean an equally spaced grid as now and the list of numbers in places that are not correct for numbers in the plot? I suspect that can be done, but I don't know how to do that. Perhaps you mean a non-evenly spaced grid? I'll let you figure out how to do that.

If by the z-axis shortened mean the whole figure scaled, see the size option.

Obviously, I'm not good at understanding you, so I'll let others respond from now on. 

@yasi The range plotted is determined by the view option, which is currently 3e-10..3e-7, so change to z_min..z_max or whatever you want. For the ticks, you can just put them in the list instead of generating them with seq: [1e-7,3e-8,5e-9,9e-10]

If you want a log scale, then you will have to specify that with the axis option, or take the log of the data, but then I'm not sure what you want with the grids.

yas.mw

@Deeshani I do not understand what you want to do in your overall question, but the piecewise plot can be simply plotted as on the attached. The ode solution was called "m", but you were plotting "sol".

plot.mw

@pointerbender I agree that probably the mean is just calculated from the sum. But leaving out u(0)=0 didn't help, which seemed to suggest it needed to look like a recursion, even if it wasn't. The help page perhaps implies that having the start at n=0 rather than n=1 is the way it works internally, which is why I went for that. But if it works for u(1)=x[1]. even better.

1 2 3 4 5 6 7 Last Page 3 of 32