acer

32722 Reputation

29 Badges

20 years, 86 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Mac Dude Recreating the procedure trackElement (by invoking proc..end proc, or by sub'sing into an existing template) will usually both be less efficient than using a never changing module local instance of the desired procedure. By which I mean, if the body of trackElement doesn't ever have to change, then you don't need to recreate it by any means each time you call Track. Doing so generates garbage which has to be collected.

I saw nothing in what you originally wrote to indicate the you had any need to recreate trackElement upon each invocation of Track. I think tha Carl was explaining how Maple parses and instantiates rather than making a suggestion that subs would  solve some problem you had.

However, if trackElement does happen to depend on lexcial scoping to use some values from Track which cannot be used merely by being passed as arguments, and if all that precludes wrapping calls to trackElement in evalhf, then you may speed things up by sub'sing in as described. This is likely not the case, though, as the presence of uses LinearAlgebra withing trackElement suggests that you're not currently invoking trackElement under evalhf, because module member referencing is not supported under evalhf.

The problem of "premature evaluation" comes up enough -- with this particular kind of error message -- that it's got its own web-page. If you click on the pink error message in your Maple worksheet (and if Maple's configured to use your web browser) then your web browser should get to this page.

acer

@smith_alpha The FileTools[Text][Open] command accepts an append optional argument.

To get a 2D parameterized curve you can just use the plot command with a particular calling sequence. Eg,

plot( [cos(t), sin(t), t=1..5] );

You attempts to use the plots[spacecurve] and the Student[VectorCalculus][SpaceCurve] commands failed because you left out the 3rd component of, respectively, the list and vector argument.

acer

@Carl Love Part of the reason that he previously got as output just print BChange must have been an erroneous space between print and (BChange) for the input. In other words, this much have originally been coded as 2D Input, with the OP beeing caught out by implicit multiplication. The reported output would thus be a product of the two names, just like shown above. So that would be a syntactic mistake (even if it did not raise an error at runtime).

Since the OP's code actually ran for him then we can surmise that the operator union was quoted in the OP's actual sheet.

@Edo Karura You can use the alias command to make x(t) appear as just x in output, or to use just x instead in input.

You can also put the x above the crossbar in the differential.

That last aspect get lost in the 2D Output however (even with extended typesetting level, I believe). And there are also brackets. So if you want only that form then you'd have to use 2D Math as input inlined and centered in a paragraph (on which you could of course still use dsolve via context-menus).

The very last operation below (dsolve) is injected by doing a right-click context menu action on the inlined 2D Math in the paragraph right above it. I used Ctl-t to get a text paragraph and then Ctl-r to switch to inlined 2D Math within that.


restart

alias(x = x(t)):

m*(diff(x, t, t)) = -k*x-b*(diff(x, t))

m*(diff(diff(x, t), t)) = -k*x-b*(diff(x, t))

(1)

dsolve(%);

x = _C1*exp((1/2)*(-b+(b^2-4*k*m)^(1/2))*t/m)+_C2*exp(-(1/2)*(b+(b^2-4*k*m)^(1/2))*t/m)

(2)

 

This is my DE:

 

 

m*(diff(x, t, t)) = -k*x-b*(diff(x, t))

 

dsolve(m*(diff(x, t, t)) = -k*x-b*(diff(x, t)), {x})

x = _C1*exp((1/2)*(-b+(b^2-4*k*m)^(1/2))*t/m)+_C2*exp(-(1/2)*(b+(b^2-4*k*m)^(1/2))*t/m)

(3)

``


Download aliasde2.mw

@Markiyan Hirnyk I think that it would have to be up to the person who wants such a display to decide whether to dice & wrap, versus trying to display a very wide sheet (which might in any case hit worksheet limitations).

One of the central purposes of what I'm discussing is ease of viewing. At a large enough dimension there will be no convenient yet clear explicit display of all elements, using any mechanism. For numeric data one might switch over to 2D numeric Arrays as images. It's a broad topic.

@jens14 Sorry, but I am seeing only many null bytes is all these zipped files (which is why thy compress so small, I suppose), and nothing to recover.

Can anyone detect anything in the file apart from a great many null bytes?

That's all I see, even if I try and force the encoding while reloading it into vim. (I was trying to check whether perhaps just the byte-order mark were missing from the start of the file...)

It's possible that there is nothing to recover from what you've attached. You might try to upload a zipped copy of what you have, just to see whether the mapleprimes uploaded is adding to the difficulty of recovery.

Do you have a backup copy? Was this downloaded at some point from an email attachment? What encoding do your other .mw worksheets usually have (ie. first line, when viewed as plaintext XML)?

acer

@tomleslie 

The OP asked specifically for a way "to input it as 2-D."

Sure, it is fastest and simplest to do it with 1D Maple Notation. But that's not what was asked.

Two ways to get the prettyprinted derivatives as 2D Math for input include using the palettes (very slow, and awkward) and using command completion (not nearly as slow, but awkward). I mention command completion because it is relatively faster than the palette approach previously discussed.

Your comments appear quite supercilious and hostile, Tom. But your criticisms do not follow logically. A person may have a need or wish to author a document using 2D Math input, for a variety of valid reasons all their own. The question of how to go about that in the easiest or fastest way is still a sensible thing to consider.

Take another point: the OP originally shows using a nested differentation, for where the 2nd derivative is wanted. It's terser to adjust the power of the `d` in the operator, to read as d^2/dt^2 , than to use nesting. That works, and was part of the context-menu method I suggested. Given that the OP wants 2D Input it can still be worthwhile to point out ways to improve the workflow.

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.]
First 329 330 331 332 333 334 335 Last Page 331 of 599