acer

32400 Reputation

29 Badges

19 years, 345 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Are you trying to get a pair of curves (X1 versus t, and X2 versus t) or a single parametric curve (X1 versus X2)?

acer

@griffith There have been quite a few posts on this site of involved numeric integrals, where the Questioners were able use the Answers to attain significantly better performance.

So, before parallelizing, might it not be worthwhile to see if the community could help you optimize the time and memory performance in the unparallelized case? Such benefits often migrate over to the parallelized case.

@TomM Good to hear that you've resolved the problem. As you've surmised, I had interpreted the problem as being one where you were trying to run the code in the worksheet that did not contain the components. But the situation is the reverse: you run the shared, defined procedures using the components.

Since your students "do not need to know anything about the programming on the `setup' worksheet" then your motivation for using two worksheets is that you don't like creating and editing the code in a code-edit region? Is that right?

Is it because of the lack of 2D Math in the code-edit region? Of the lack of Find/Replace? Or the lack of syntax-checking?  (The Startup-Code region does have Find/Replace and syntax checking.) Or tabbing and cursor movement? Or is it some other aspects of the editing? I'm just curious, thanks.

@Carl Love I suspect that we are agreement here. I am not a fan of the way that eval can act as temporary escape from evalhf mode, and am ambivalent about mentioning it.

I think that it was was a positive feature of evalhf, for the many Maple releases wherein it was not possible to create Vectors inside evalhf. Always having to pass Matrices/Vectors/Arrays in as arguments to evalhf'd procedures is conducive to lean and efficient programming, I think.

I think this goes for compiled code too.

Give people a chance to run up a huge amount of garbage collection overhead... and they will.

@Carl Love There are a few incorrect claims in your response (but which do not affect the code portion, which nevertheless addresses the posted Question).

In the following example the Vector V was not passed into procedure p. And running under evalhf the procedure p does indeed return a Vector.

restart;

p:=proc()
  local i,V;
  eval(assign('V',Vector(3,datatype=float[8])));
  if true=1 then # will only loop in evalhf mode!
    for i from 1 to 3 do
      V[i]:=i^2;
    end do;
  end if;V;
end proc:

p();

                                    [0.]
                                    [  ]
                                    [0.]
                                    [  ]
                                    [0.]

evalhf(p());

                                    [1.]
                                    [  ]
                                    [4.]
                                    [  ]
                                    [9.]

@yunlongwang If you find that Matrices of large size do not print in full (showing just a summary item) then adjust the rtablesize interface property.

Eg, to allow Matrices only up to size 20x20 to display in full, use the command,

interface(rtablesize=20):

That will affect both Matrices and Vectors. The default is rtablesize=10 in the Standard Java GUI.

@Mac Dude No, there are three possible settings: always use a new engine (mserver), never use a new one, and ask each time. The last one should bring with it a popup menu to select from running mserver instances, or a new mserver, each time File->New or the desktop launcher is used. And the OP has told us that the kernel computational part of this is working OK.

Having said, that, I am not sure whether or not the Maple 18 behaviour with respect to embedded components was correct. Why should embedded components be shared amongst worksheets/documents, just because the kernel engine is? It doesn't sound outrageous to me to consider that embedded components are individual to the sheet in which they are... embedded.

Or perhaps it is supposed to work, and it was broken by accident.

I suggest that you ask Maplesoft Tech Support ( support@maplesoft.com ) , @TomM , or submit a bug report.

Since you have supplied fsolve with no restricted range on t then why is one root (amongst infinitely many roots to your equation) more acceptable to you than another?

Why should fsolve prefer Pi/4 over -Pi/4 (or any other valid root)?

Do you feel that fsolve should always find the root closest to the supplied starting point? What about when the starting point is midway between two valid roots?

acer

Can you show us an example, even if it is pared down with your private code removed?

acer

@Carl Love I was able to improve the original's performance using Int and evalf (with a coarse tolerance) in the definition of g2 (along with some simplification steps of the ensuing results from diff). As you've noted elsewhere, sometimes it works better to deal with an exact result, while sometimes the purely numeric approach can do better. It's not clear to me which is  better here, as it seems both cases are moderated by simplification or code optimization.

But I did notice that using the method=ftocms option on the exact int call in the defintion of g2 yielded a symbolic result involving erf rather than Fresnel. It may be that this helps, in this approach of doing that inner integral exactly (including code optimization).

@goli Why wouldn't you bother to include that extra known information when posing your question?

@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

First 323 324 325 326 327 328 329 Last Page 325 of 592