27003 Reputation

29 Badges

17 years, 61 days

Social Networks and Content at

MaplePrimes Activity

These are replies submitted by acer

@DJJerome1976 I didn't intend any offense, and sorry if I expressed it poorly.

What I meant was that the target expression you mentioned is not equal to the explicit result from dsolve for all values of t (...if done without assumptions). You didn't bring that up in your Question.

I showed one formulation (with a simplification ignoring branch distinctions) that had just a single radical -- one aspect that you mentioned wanting.

@tomleslie The OP wrote, "I try to find the value of the highest peak..."

There appear to be no other local maxima in the ranges x=-5..5,t=-5..5 that the OP used for plotting, except along the boundaries x=-5 and x=5 (and those are part of ridges, not peaks).

The likeliest explanation may be that the OP was misled by the apparently finite heights of the peaks in the plot -- a consequence of plot3d's sampling methodology.

@mmcdara This person has been posting short questions here (many puzzle-like) for over ten years. It doesn't seem like homework. There are a few regular submitters of math problems here who appear to be motivated by interest alone.

@emersondiaz You're very welcome.

I've just updated the download link in my previous Reply.

It should now run quite a bit faster.

I also removed the global, and typeset the Greek letters.

@emersondiaz Before I was simply fixing up the Maple code that you provided in your .mw attachment, w.r.t. how you could use NLPSolve's results to get numeric values. I wasn't even looking at the Matlab code in the .pdf file.

Here is a different translation of that Matlab code in your .pdf file, and a plot that obtains:

By the way, in your .pdf file the Matlab code uses an integrand like,

    sqrt(x)/(exp((x - y)/t) + 1)

But in your Maple code in this Question you appear to have used something like a polylog form with for integrand more like,

     sqrt(x)/(exp(x - y)/t + 1)

Those two expressions are not the same; the bracketing in the denominators are importantly different. That is why the earlier plot wasn't correct.

@zenterix For unassigned names i and x there's no important difference here between,

   plot(x, x=1..5)


   plot(i, i=1..5)

There's no implicit type aspect where the name `i` is integer valued and `x` is continuously valued. They're both just names.

@romanrieme I had already mentioned that I'd intended [F2(t), F3(t)] instead of display(F1(t), F3(t)) inside the `if`.

Your F1,F2,F3 procedures are nicely behaved and return unevaluated when passed just the symbolic name t, so that premature evaluation problems can be avoided in these examples. You can program p1 similarly.

As I mentioned earlier you could nest `if` calls, for handling more that two cases, but you could also use piecewise which becomes simpler as you load on more conditions. (You could also write a master procedure, accepting parameter t/tau, returning unevaluted for symbolic t/tau, and assembling any single frame using a single if..then..else according to the your various conditions. I won't bother.)

The following attachment shows both the nested `if` as well as the piecewise approaches I just mentioned.


note: This is not advanced programming. Several of the followup solutions involve simple logical extensions from the previous coding examples in the thread.

@zenterix You haven't explained in any way what you expected your second attempt to mean. 

@romanrieme Sorry, I was rushing out the door earlier, and my fingers didn't type what was in my mind.

What I meant was that you could use [F2(t),F3(t)] in the `if`, instead of say just F2(t).


    animate(display, [`if`(t < 0, F1(t), [F2(t), F3(t)]), scaling = constrained],
                  t = -1 .. 1, frames = 141)

note: In your followup comment you wrote, "F1(t) from -1 to 0", but in your worksheet your F2 appears in the subsection captioned, "t from -1 to 0". In any case I feel sure you can work out which you want where.

note: I am not so keen on the following, since two back-to-back frames are displayed each with t=0.
   display([animate(F2, [t], t = -1 .. 0), animate([F1, F3], [t], t = 0 .. 1)], insequence)

note: My earlier suggestion display(F2(t),F3(t)) was a mental slip. It should be obvious why it would not work: t is just a name and F2(t) returns unevaluated which is useful elsewhere but not good for the display call. Read my correction here.

@romanrieme Just display(F2(t),F3(t)) in the `if`.

Please put your close followup queries here, instead of in a wholly separate and new Question thread. (At the very least, you could Branch off from this Question...)

@zenterix What will be the next changes in the task, after this?

I'd prefer to save time and accomodate a few of the coming requirement changes in one shot.

Tom's toy example saves and reads back in reasonably quickly.

This is simply save, and read.

Below I call save on the result of display of all the frames together (with `insequence`). But you could just as easily save/read a mere list of the sequence of frames, in case say you want eventually to display together frames saved from different Grid processes.

It's easier than exporting just the numeric data (which will involve lots more work if it's supposed to also store receive additional information about color, style, etc, and even more if it has to support reassembling CURVES, GRID (and POINTS, and MESH?) structures, arrows, and so on...)



odesys:=[diff(x(t),t) = x(t) - x(t)*y(t),
         diff(y(t),t) = x(t)*y(t) - y(t)]:
tv:= Array([seq(j, j=0..10,0.1)]):

ics:=[x(0)=k1, y(0)=k2]:

sol:=[seq([dsolve([odesys[], eval(ics, [k1=j, k2=1])[]],
                  numeric, output=tv)[2,1][..,2..3],
           dsolve([odesys[], eval(ics, [k1=j, k2=2])[]],
                  numeric, output=tv)[2,1][..,2..3]][],

plt1:=plottools:-circle([1,1], 1, thickness=4):
Anim:=display([seq(display([plt1, listplot(sol[j], color=red),
                           seq(listplot(sol[k], color=blue),k=2..j+1,2)]),

save Anim, cat(kernelopts(homedir),"/mapleprimes/testanim.m");


read cat(kernelopts(homedir),"/mapleprimes/testanim.m");



This is simply save, and read.

It seems to me that the main question is whether this gets undesirably slow, as the size and number of the animations increases. If it doesn't, then extracting/exporting the numeric data (and all that potential work cobbling each frame's elements back together) seems unnecessarily complicated and onerous.

@AHSAN You can suppress the label on a particular axis by using the empty string formed by a pair of double-quotes.

You can color between two (or more) colors of your choice, through the colorspace of your choice. The key "xgradient" makes it vary with the value in the axis[1] direction, "ygradient" makes it vary with the value in the axis[2] direction (unrelated to your variable name y), and "zgradient" makes it vary with the value in the axis[3] direction.

For example, coloring in hue by the values of Q,

       y = 0 .. 1, Q = 0. .. 0.7,
       labels = [y, "", "u"], orientation = [0, 90, 90],
       colorscheme = ["ygradient",[red,blue],colorspace="HSV"]);

@zenterix This is quite different from what you originally described in your Question.

Perhaps there are still more key details that matter.

Do you need maximal efficiency because, say, you're going to be reading the results back in later? How much delay can you bear, for export/import?

What happens if you assign the computed plot structures (whole), to either individual .m files or to key names within .mla files? Is the save&read too expensive and slow?

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