acer

32333 Reputation

29 Badges

19 years, 318 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@vs140580 Do you mean something like these?

restart;

f := 72.7*x-24.5*y;

plots:-implicitplot(f, x=-2..2, y=-5..5,
                    rangeasview, labels=[x,y], axes=box);

plot([solve(f,y)], x=-2..2,
     view=-5..5, labels=[x,y], axes=box);

@Idontcare I really think that you should not use the approach of entering 3 or more expressions separated by =, in 2D Input mode.

The 2D Parser turns something that looks like this,

   -a*b + a*c = -a*b + a*c = a*(c - b)

into the following (Maple plaintext code),

   -a*b + a*c = -a*b + a*c and -a*b + a*c = a*(c - b)

That lowercase and makes Maple test each of those equations in the same way that evalb works, including this second one,

   -a*b + a*c = a*(c - b)

and that returns false because the lhs and rhs are not numeric and also not the identically same symbolic expression. They are the same mathematically, but not structurally. That's why evalb is not the appropriate mechanism for you. See my examples above in my original Answer.

I think that entering such conjoined multiple `=` statements in 2D Input mode is a very poor approach. I think that you would be much, much better off using the approach of assigning single equations (two expressions on either side of an = sign) to various new variables, and then testing them in one of the successful ways that I showed above in my original Answer.

In the long run, you will be much better off learning commands, and learning Maple as a plaintext programming language. I also suggest you consider using 1D Maple (plaintext) notation inside Execution Groups of a Worksheet instead of the (default, sigh) 2D Input mode in a Document.

@mmcdara You're welcome.

Here is a slight revision in which the radio-buttons both set a value of a module local, which denotes the adding/removing mode's status (ie. a boolean). One advantage of this approach is that it makes it easier to test the action code separately from any button/plot clicking. In some advanced applications that can sometimes be convenient.

sketch_ac2.mw

Let us know if you plan on creating a procedure that build/inserts this whole assembly, using DocumentTools:-Layout/Components. In that case there are a few tricks that make it possible to embed multiple instances of the application (on the fly in the same worksheet) which each utilize the same Bez module runtime but whose buttons/plots act independently of each other.

ps. I didn't mention that a full sort is higher computational complexity than necessary for determination of the position in the point-list of the closest match. I'm sure you know that already, and only wanted a short snip of code that made the example work. The embedded component programming is the question here.

@tomleslie You wrote, "Unfortunately the 'size' option is not available for 3D plots:-("

But support for the size option for 3D plots was introduced in Maple 2020. The plot3d and plots:-display command now accept it.

 

@Idontcare I can't say for sure because you still haven't shown us your explicit example  so I don't know what exact commands you're using and how.

You can upload and attach a worksheet here using the green up-arrow in the Mapleprimes editor.

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);
First 130 131 132 133 134 135 136 Last Page 132 of 591