acer

32405 Reputation

29 Badges

19 years, 345 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Yiannis Galidakis 

Note that it's not strictly necessary to pare down list F inside the plotting loop, using select. I did that to reduce the plot data and memory requirements. The key to getting your zooming look is, rather, the use of plottools:-transform. to make sure all frames get the exact same view, after rescaling.

In my previous attachment I changed the code to build PP (or P) using a table, which is converted into a list after the loop finishes. It is quite inefficient to construct large lists by appending.

In the following attachment I also made a related to change to the construction of list F, using seq instead of repeatedly appending to the list F in a loop. That runs faster when processing the L made from farey(100) say.

You should really try not to create lists in a loop, by appending. It makes such code as this much slower than it has to be. It can make time and memory resources be O(n^2) rather than O(n), say, and so make your code scale up much less well.

I also added dynanic (faked) x-tickmarks, to show more clearly that it is zooming in. You can of course remove that bit.

A nice next step might be to dynamically construct F depending upon the loop index k (and thus also upon w). The bookkeeping for that is a bit trickier, though, and may involve changing how you build L as well. The idea is to produce the same total number of values for F for each frame, using each k and w value, but to construct them with a repeatedly changing value range. It would mean that the central portion of the plots would remain filled with lines, as it zooms. That would be cheaper to produce, and leaner, than simply bumping up the value passed to farey() to produce a single, re-used, and very large F.

FareySeq_modif2b.mw

 

 

@Winkel That error message is telling you that the save command expects additional arguments.

Look at the help-page for save. That command expects the assigned names you want to save to the file.

Eg,

    save name1, name2,...,namek, fileName;

You have merely,

    save fileName;

and so the error message is "must specify names to save".

So, what are the names (whose values have been computed in your worksheet) that you want to save?

 

@Yiannis Galidakis Is this more like what you want?


restart

with(plots):

farey := proc (N::posint) local a, b; sort([op({seq(seq(a/b, a = 0 .. b), b = 1 .. N)})]) end proc:

L := farey(50):

F := []:

for k to nops(L) do F := [op(F), [[L[k], 0], [L[k], 1/denom(L[k])]]] end do:

Ox := 1/2;

1/2

0

M := 1;

1

M1 := M;

1

M2 := 10;

10

N := 30;

30

dM := abs(M2-M1+1)/N;

1/3

Ptab := 'Ptab':

"Frame:", 0

"Frame:", 5

"Frame:", 10

"Frame:", 15

"Frame:", 20

"Frame:", 25

plots:-display(PP, insequence = true);

 

``


Download FareySeq_modif2.mw

What does the Maple command kernelopts(homedir) return? 

(Presumably your OSX user name is not "Name"...)

acer

@Markiyan Hirnyk Yes, Robert's Answer itself contained `&lang;` and `&rang;` rather than < and >. I've corrected it.

@Carl Love It works for me in Maple 2015.1.

Markiyan's worksheet contains ⟨u,v,w⟩ which is,

`⟨u`,v,`w⟩`

That's the unicode U+27E8 and not the usual left bracket. You can also get it in Maple using the plaintext Maple Notation input,

`&#10216;`

Or maybe it's U+2329... What's also critical is that Markiyan's sheet has that bracket symbol concatenated with the `u`. Similarly for the `w` and the right bracket.

So the second argument to the Plane command is not a Vector, in his uploaded sheet. It's no wonder he has difficulty in getting the example to work.

@mapleq2013 I think I see what you mean now. I'll try and figure it out. I may not be around for a few days, though.

@mapleq2013 Since I don't see C=(-A3^(-1)).(B+A4) getting close to B when g gets close to zero, and since you state that it ought to, then I would hazard that A3 and A4 are not as you intended.

@mapleq2013 You have g appearing in A1,A2,A3, and A4 but not in your construction of B.

You assign (-A3^(-1)).(B+A4) to Bm but then you don't use Bm in constructing C! You just use B in constructing C.

My guess it that you just made an oversight during your revising, to not utilize Bm the Matrix that depended upon g. Is that possible?

Also, I don't see that C is very close to (-A3^(-1)).(B+A4) when g=0, although I do see a difference in Bm between say g=1/10 and g=1/1000.

Much (if not most) file i/o is disabled in the MaplePlayer.

acer

@mapleq2013 I was hunting for a simplification of the Matrix you were assigning to C (which was not just B). I wanted this because it would (at least) reduce the time spent evaluating at each numeric x-y pair. It's quite possible that the simplifier I was using on Matrix C before did not have any effect. I'd have likely left it in the code anyway, in case I found something better later. And I believe that I have, now.

I don't have the same Intel i7 machine available right now. But on an AMD FX-8320 (4 physical cores?) running 64bit Maple 12.02 for MS-Windows I see a meaningful reduction in computation time if I use the variant simplifier when constructing Matrix C,

 u -> simplify(expand(u), size) 

Here is that variant, used in my modification to Carl's fsolve method to efficiently uses all 6 roots found for each x-y pair.

example_modif1b.mw

I included some calls to show the length of the entries in 6x6 Matrix C, both with and without that simplifier.

All 6 surface plots get generated in about 15 seconds using that code and machine, while it takes about 45 seconds using the earlier one I had. Using that alternate simplifer to preprocess C gets me about a 2-fold speedup when using the alternate Eigenvalues approach.

Well, you can experiment this simplification stuff and its effect on timings.

Interestingly, I see it all run about 4-5 times faster using the 64bit Linux version of Maple 12.02 on a quad-core Intel i5 than on the 64bit MS-Windows version of Maple 12.02 on that AMD FX-8320. I guess that's Maple 12 archaeology.

Simplification of multivariate trig terms is a bit of a dark art. I kept all initial constants as exact rationals, to aid in simplification. It's interesting to me, that while the counterintuitive inner expand step helped simplify C, I was able to subsequently grind down the symbolic characteristic polynomial (not shown in my sheets) more using an inner combine step. ...not that I got any joy from solve on it.

@TomM Those older kinds of plot persistence, such as for axis style, (manual) sizing, etc, are implemented by design, I believe.

But it's obviously undesirable when thumb-nailing gets applied while rendering singleton plot output not even part of a sequence or an assignment statement.

 

@mapleq2013 That call to map is applying its first argument (a procedure) to its second argument (which happens to be a Matrix in your example).

The procedure being mapped across the Matrix is this:

u -> simplify(simplify(combine(u)),size)

That procedure does three nested operations. Each might do a different kind of "simplification", which is a broadly used term. It's possible that the inner use of combine had little or no useful effect, where I used it.

The u is the formal parameter of that procedure. The procedure will get called on each element of the Matrix, and so (in turn) each element will be used as a value of u.

For example,

M := Matrix( [[1,2], [3,4]] );
                                      [1  2]
                                 M := [    ]
                                      [3  4]
map( u->sin(u)^2, M);
                             [      2        2]
                             [sin(1)   sin(2) ]
                             [                ]
                             [      2        2]
                             [sin(3)   sin(4) ]

Sorry, I'm not sure what else might be unclear to you about this.

@mapleq2013 

1) M[i,j,..] means the whole 1-dimensional portion of Array M, where i and j are fixed and the third index runs its whole range. In this example the third index of M goes from 1 to 6. In this example M[i,j,..] is the same as M[i,j,1..6] or M[i,j,1..-1] or M[i,j,1..] or M[i,j,..-1].

This form of indexed accessing of an Array is allowed for both extraction and for assignment. In this case I am using it on the left hand side of an assignment statement, for assigning into M. Here I assigned a 6-element Vector into this portion of M, though alternatively I could insert a 6-element Array. See also this help-page.

2) Yes, I used seq to repeat something 6 times, ie. for i=1..6. The increment of the seq command is 1, by default. Yes, I was extracting 2-dimensional Arrays from the 3-dimensional Array M. It is clear that you have already figured out most all of this.

matrixplot has a few options to display 2-dimensional data differently than as a surface (ie. as a histogram, too). But when used to show a surface there is not too much difference from surfdata. But one important difference is that the tickmarks on the two dependent axes from matrixplot are just the index values of the Array or Matrix. But surfdata accepts two additonal arguments to specify arbitrary ranges for the tickmarks shown on the two independent axes.

The map command applies its first argument across the entries of its second argument (which is usually something indexable). The map and the eval commands do two quite unrelated things.

3) I confess that since I was producing a grid of points for a only a finite grid (for plotting purposes) I did not take the time to examine just how close any pair of the surfaces got, or what their qualitative behaviour is where they get close. I may have jumped the gun there, sorry.

4) Maple is quite capable of doing numerics well, and fast, though that is not very widely known. Many people get caught by the fact that there are often several or many ways to do something in Maple, and often only a few of those ways are most efficient. Numerics in Maple is not a stranger to this issue.

Sometimes you'll find problems for which it makes sense to compute a general symbolic answer and then evaluate that at many numeric sets of values. And sometimes that will be slow, and it'll turn out to be better to do the many numeric computations instead.

@necron Well, in several of your test cases you are evaluating at y=something_less_than_Pi and your c33 becomes identically zero due to the piecewise produced by f1(y).

I do not understand why you'd want to introduce a multiplicative piecewise term like f1(y) and make the integrand discontinuous when you could instead just split the y-integral into a few more smoother pieces. Numerical quadrature methods often rely on smoothness.

First 324 325 326 327 328 329 330 Last Page 326 of 593