acer

32313 Reputation

29 Badges

19 years, 316 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

In a closely related followup Question of yours (appearing a day or so after this Question) you mentioned that you were substituting initial conditions into a candidate ode solution using the subs command.

A plain subs call is generally an ill-advised way to do that, and generally inferior to using the eval command. Unevaluated syntactic/structural substituion is not the same as mathematical evaluation at a point. (Now, there may be some examples for which limit is a better choice for doing that substitution. But that's another story.)

Consider the following example, using something akin to your followup example.

restart;

proc() local tmp_1, f;
  f:=1 = 5/4*exp(a)+1/4*piecewise(a <= 1,-1,1 < a,exp(b));
  tmp_1:=subs([a=0,b=-2],f);
  lprint(tmp_1);

  is(tmp_1),
  is(simplify(tmp_1)),
  is((rhs-lhs)(tmp_1)=0),
  is(simplify((rhs-lhs)(tmp_1)=0)),
  evalb(simplify((rhs-lhs)(tmp_1)=0)),
  is(expand(tmp_1));
end proc();

1 = 5/4*exp(0)+1/4*piecewise(0 <= 1,-1,1 < 0,exp(-2))

              FAIL, FAIL, FAIL, FAIL, false, true

It should not come as a surprise to you that subs does not evaluate, following the substitution. (There are a few other advantages to using eval rather than subs here, but evaluation is the main one.) It should also not come as a surprise to you that assigned locals get only 1-level evaluation inside a procedure body. I know that you've seen both of those things before, in the many years you've been asking questions on this forum.

restart;

proc() local tmp_1, f;
  f:=1 = 5/4*exp(a)+1/4*piecewise(a <= 1,-1,1 < a,exp(b));
  tmp_1:=eval(f,[a=0,b=-2]);
  lprint(tmp_1);

  is(tmp_1),
  is(simplify(tmp_1)),
  is((rhs-lhs)(tmp_1)=0),
  is(simplify((rhs-lhs)(tmp_1)=0)),
  evalb(simplify((rhs-lhs)(tmp_1)=0)),
  is(expand(tmp_1));
end proc();

1 = 1

               true, true, true, true, true, true

You suppressed the output of the assignment to tmp_1 in your standalone top-level example, by terminating the statement with a full colon. That's not prudent here. If you hadn't then you might have noticed that it wasn't actually testing the identical expression that you saw in the debugger.

restart;

tmp_1 := 1 = 5/4*exp(0)+1/4*piecewise(0 <= 1,-1,1 < 0,exp(-2));

                      tmp_1 := 1 = 1

is(tmp_1),
is(simplify(tmp_1)),
is((rhs-lhs)(tmp_1)=0),
is(simplify((rhs-lhs)(tmp_1)=0)),
evalb(simplify((rhs-lhs)(tmp_1)=0)),
is(expand(tmp_1));

           true, true, true, true, true, true

@nitins Sorry, I do not have time to answer this. Someone else might.

Please don't post it as a separate Question thread, which may be flagged as a Duplicate and deleted.

@luthfiirsyad26 I see, thanks. So it seems as if my guess lambda=0.01..0.1, a=0.1 ..2.1 for the ranges was not way out.

@luthfiirsyad26 You didn't answer: what are known ranges for parameters `lambda` and `a`? 

Please put your followup expositions here, instead of as separate threads with repetitive variations.

If you have a followup question about this example then please add it here in a comment, instead of posting a separate Question thread and splitting the content.

Also possibly worth mentioning:

restart;

kernelopts(version);

   Maple 2021.1, X86 64 LINUX, May 19 2021, Build ID 1539851

ode_orginal:=1/3*(-2*x^(5/2)+3*y(x)^(5/3))/x^(3/2)*diff(y(x),x)/y(x)^(5/3)
             +1/2*(2*x^(5/2)-3*y(x)^(5/3))/x^(5/2)/y(x)^(2/3) = 0:

dsolve(expand(ode_orginal),y(x));

                          (3/2)
              y(x) = _C1 x     

Here is a result. Let us know if it's acceptable. (I made up ranges for lambda and a, as parameters.)

WB_Fractional_Derivative_ac.mw

 

@luthfiirsyad26 Thanks for that.

I changed your Question from Maple 2018 to Maple 18, since that is the version in which your attachment was last saved.

Do you have candidate ranges for lambda and a, which I suppose are your parameters?

@mapleatha The animate command passes a float to the plotting command (according to the current frame number and the numeric range). That is what happens. It doesn't have special behavior for the special case that that all such values happen to be integers.

You can also utilize a larger value for the frames options, and you could also utilize ceil or floor instead of trunc. It depends on on what kind of effect you want.

The key thing is that -- when the animating parameter theta gets instantiated with a numeric value -- the index is valid (ie. a natural number).

[edit] A simple alternative, for your example, is to utilize plots:-display of a sequence of plots generated directly from the list. Eg,

plots:-display(seq(F(theta), theta=L), insequence);

As yet another alternative, the Explore command allows for a sequence of integers to be passed, without need for trunc (or an other mechanism to convert from float to integer, to make a valid index into the list). Eg, for comparison,

restart;
F := theta -> plot(sin(x*theta), x=0..2*Pi,
                   caption=typeset("theta =",theta)):
L := [seq(sqrt(i),i=1..20)]:

plots:-animate(F, [L[trunc(i)]], i=1..nops(L),
               paraminfo=true, frames=nops(L));

Explore(F(L[i]), i=1..nops(L), numframes=nops(L), animate);

or even,

Explore(F(theta), theta=L, animate, placement=bottom);

or,

Explore(F(theta), parameters=[[theta=L, controller=slider]],
        animate, numframes=nops(L), placement=bottom);

You could show us what you have got so far. You can upload (and attach a link!) your worksheet using the green up-arrow in the Mapleprimes editor.

@Rouben Rostamian  I see now, thanks.

I'll file the examples below, and also yours using setoptions up front.

Fwiw, you may be able to get by with " " the single black space. You could also use `` the empty name, but since that isn't protected it would more safely be used as ':-``' though even that can get accidentally evaluated. The empty string case is more robust, terse, and ideally would work.

In the following (without any setoptions call in an initialization file) the first two look wrong.

restart;

plots:-display(plot(x^2, x=-1..1),
               labelfont=[TIMES,16], labels=["",""]):
indets(%,specfunc(anything,AXESLABELS));

   {AXESLABELS(x, "", FONT(TIMES, 16))}

plots:-display(plot(x^2, x=-1..1),
               labels=["",""], labelfont=[TIMES,16]):
indets(%,specfunc(anything,AXESLABELS));

   {AXESLABELS(x, "", FONT(TIMES, 16))}

plots:-display(plot(x^2, x=-1..1),
               labels=["",""]):
indets(%,specfunc(anything,AXESLABELS));

         {AXESLABELS("", "")}

plots:-display(plot(x^2, x=-1..1),
               labelfont=[TIMES,16], labels=[``,``]):
indets(%,specfunc(anything,AXESLABELS));

   {AXESLABELS(``, ``, FONT(TIMES, 16))}

plots:-display(plot(x^2, x=-1..1),
               labels=[``,``], labelfont=[TIMES,16]):
indets(%,specfunc(anything,AXESLABELS));

   {AXESLABELS(``, ``, FONT(TIMES, 16))}

plots:-display(plot(x^2, x=-1..1),
               labels=[``,``]):
indets(%,specfunc(anything,AXESLABELS));

         {AXESLABELS(``, ``)}

ps. These examples are supposed to work without need of overrideoption. That is intended to force clobbering of options which get set "locally" inside plotting substructures which designate curves, surfaces, etc. The AXESLABELS substructure is "global" in the sense that it gets uniquified within the whole plotting structure, and it exists outside the plotting substructures which designate curves, surfaces, etc. I suppose that you were demonstrating merely that it did not help here.

@mapleatha You're very welcome. I'm sorry that I didn't think of the discrepency until I saw your followups.

(I suspect that Kitonum realized what the problem was, and gave his working equivalent, before I did.)

@mapleatha In Maple 13 the plots:-animate command did not automatically (graciously) invoke plots:-display in your case that the animating procedure returned a sequence of plotting structures.

Try this,

restart;

F := proc(t)
plots:-display(
plottools[line]([-2,0], [cos(t)-2, sin(t)], color=blue,thickness=3),
plottools[line]([cos(t)-2, sin(t)], [t, sin(t)], color=blue,thickness=3),
plot(sin(x), x=0..t, view=[-3..7, -5..5],thickness=3));
end proc:

plots:-animate(F,
               [theta],theta=0..2*Pi,
               background=plot([cos(t)-2,sin(t),t=0..2*Pi],thickness=3),
               scaling=constrained,axes=none);

Note that the example on the Online Help webpage is designed for current Maple. Hence it does not contain the (now unnecessary, in Maple 2021) extra call to plots:-display. But if you look at the example in Maple 13.01 it actually contains this variant,

with(plots):
# followed further by the following...

F := proc(t)
     plots[display](
plottools[line]([-2,0], [cos(t)-2, sin(t)], color=blue),
plottools[line]([cos(t)-2, sin(t)], [t, sin(t)], color=blue),
plot(sin(x), x=0..t, view=[-3..7, -5..5])
     );
end proc:
animate(F,[theta], theta=0..2*Pi,
        background=plot([cos(t)-2, sin(t), t=0..2*Pi]),
        scaling=constrained, axes=none);

So it appears that you may have mistakenly copied the example from the Online Help instead of from your Maple 13's own Help page.

@mapleatha Please upload and attach the worksheet which reproduces the problem.

Your last Reply contained a typo. That may not be the cause  but it's a hint that it's not productive to guess what code you are actually executing.

First 130 131 132 133 134 135 136 Last Page 132 of 591