28691 Reputation

29 Badges

17 years, 357 days
Ontario, Canada

Social Networks and Content at

MaplePrimes Activity

These are answers submitted by acer


Lm := (simplify(k*sqrt(L*L)) assuming (0 < L));


L1 := (factor(L - Lm) assuming (0 < L and 0 < Lm and 0 <= k));





Note what happens without the sort (I have to do it in a fresh session, since the sorted result in the session above is subsequently obtainable without it...).


Lm := (simplify(k*sqrt(L*L)) assuming (0 < L)):

L1 := (factor(L - Lm) assuming (0 < L and 0 < Lm and 0 <= k)):






ps. If you have more involved examples then please show them up front in your Question.

If you merely use single right-tick uneval quotes (As Carl's suggested) then subsequent full evaluation of the resulting plot structure can lead to inadvertant and undesirable evaluation of assigned names in the textplots.

That can include the scenario where you pass the textplot(s) to plots:-display as a subsequent programmatic merging with plots computed only later.

That can make merely using uneval quotes a somewhat problematic approach. Too few layers of quoting and your code might accidentally evaluate the quoted expressions. Too many layers and some quotes can undesirably appear in the rendering. Too tricky, and fragile if mixed with later revisions to the overall code.

Passing the resulting assigned textplot structure around as eval(P,1) is possible, but that too can get complicated and onerous -- depending on later code changes.

Instead, your could use Typesetting:-Typeset to get the textplots, with much better resistence to such unwanted subsequent evaluation. Basically, it's just going to be more robustly useful in such a case that you don't want any part of the "text" to be subsequently, accidentally evaluated. You only have to focus on its construction, and not on how you use/pass it later.

In the examples below, the green text survives as intended, while the red text goes wrong due to inadvertant evaluation.


with(plots): setoptions(size=[500,300]);


p,c := -2,5;

-2, 5

P := display(
  textplot([1,3,Typesetting:-Typeset(p<c)], color="Green"),
  textplot([1,2,':-p'<':-c'], color="Red"),


display(P, plot((x-4)^2,x=0..8));


nb. If your expression is first assigned to some name, eg.  foo:=expression , then you might need either,
etc, since Typesetting:-Typeset has special evaluation rules (to prevent automatic evaluation) on its first parameter.

A call like,

   DocumentTools:-GetProperty("ComboBox0", value);

will return the currently selected item in the Combo Box embedded component with that ID.

The command parse would turn that string into the global instance of a name (if valid as such).

There are examples of this kind of use of GetProperty on this Help page. (That page was the very first hit, when I entered ComboBox in the Help Browser's search field.)

The parse command is not specific to embedded components. You could also be more verbose with, say, convert(str,name), btw.

An even more typical scenario for such use of parse is getting user-supplied numeric values from a TextBox embedded component. In that case, the Help page's main example actually uses parse, which is helpful. In the case of a ComboBox any programmatic contextual switching could be string-based as well/easily as name-based, by which I mean that parsing to a name isn't so inherently useful because the choices were already hard-coded and known the code author.

I was able to recover the following. Please check it over.

There might be an equation or Matrix input missing after the line containing, "Til at starte med bestemmer vi", and another after the line beginning, "Vi kan bestemme". And I'm not sure whether the very first opening Section should contain all other Sections (you might need to adjust).

This kind of curruption problem seems to be less frequent with Maple 2023. You might want to try that upgrade, if available to you.

In any event, I suggest that you try to make regular backups -- even if that means saving to separate files, manually.

The z that is the named parameter of your procedure,
    v := z -> functionList[1]
has nothing to do with the global name z that is in the expressions in the set. That's why your attempt does not succeed; invoking that procedure does not replace the z in the expression.

Here are two ways, the second a correction to your procedure-building approach, and the first a simpler approach using eval.


functionList := {2 + z, z^2 - 3*z, -z^3 + 4}:

Easier way, IMO.

plot3d(Im(eval(functionList[1],z=x + y*I)), x = -1 .. 1, y = -1 .. 1);

v := unapply(functionList[1],z):

plot3d(Im(v(x + y*I)), x = -1 .. 1, y = -1 .. 1);

Note that the following produce the same result as each other,
and are both what can get passed straight to plot3d as its
first argument (if you were to use the second element of your set).

The first method is considerably simpler. It is unnecessary
extra effort to construct a procedure/operator v
and then to only call it once (merely to construct the argument
passed to plot3d).

Im(eval(functionList[2],z=x + y*I))


v := unapply(functionList[2],z):
Im(v(x + y*I));



Is this one of the kinds of animation of the curves that you mean?

See attachment for animation of t vs x(t), t vs y(t), with all three playable together and axes aligned. Adjust as wanted.

There seem to be quite a few "corner cases", what with automatic-simplification, GUI rendering quirks, etc.

(I did this quickly, without cleaning it up. Check for mistakes...)


H := proc(ee) local res;
  res := subsindets(combine(simplify(ee)),`*`^fraction,
                    end proc)
         assuming positive;
  subsindets(res, {name,name^integer}^fraction,
             proc(u) local p,r,res; uses ID=InertForm:-Display;
               p := iquo(numer(op(2,u)),denom(op(2,u)),'r');
               if denom(op(2,u))=2 then
               end if;
             end proc);
end proc:








0, "%1 is not a command in the %2 package", _Hold, Typesetting


0, "%1 is not a command in the %2 package", _Hold, Typesetting


a*b^2*c*%surd(a*b, 3)


a*surd(a, 3)*b^2*c


a*b^2*surd(c^3, 4)


a^2*b^2*%surd(a*c^3, 4)


0, "%1 is not a command in the %2 package", _Hold, Typesetting


0, "%1 is not a command in the %2 package", _Hold, Typesetting


a^2*surd(a, 4)*(b*c)^(1/2)


Your attempt to get the overall vertical min&max with,

   plottools:-getdata(A)[3][.., 2]

is faulty because you have multiple curves structures in the plot.

But rather that fix that approach (ie. get the min&max for each and then compare/combine) you could use the rangesonly option of getdata which will figure out the overall min&max in both directions. Ie,

   ymin, ymax := op(plottools:-getdata(P, rangesonly)[2])

If I plot the surface at a higher grid resolution, in only a narrow strip close to x=-1 then it appears that the surface is discontinuous along x=-1, for y>1.5.

Using implicitplot instead of contourplot seems to provide a useful mechanism for getting the contours to agree with the surface in that region.

I'll leave it to you to figure out whether the apparent discontinuities are (perhaps?) due in part to numeric roundoff issues due to the complicated scaling of factors (ie. exp calls, and very large/small coefficients). I don't see offhand how symbolic manipulation of the expression (even with exact rationals) sheds light there.


You seem to have omitted to supply a value for y.

For example,

UnivariateBarGraph(beta, [seq(0..1, 0.2)],
                                   [Q = 1.3015, lambda = 0.9989, x = 0, Br = 1, y=1/10], "Chartreuse");

Is this the kind of plot you had in mind?

Naturally, you can apply additional options and adjust the axis labels, etc.

@2cUniverse You can fix your problem with the first Button press by doing any of the following:

1) Move the calls to with(...) to before the use...end use, but keep them inside the Button's "click action" code.
This is somewhat inefficient since it calls with() each and every time the Button is pressed -- which is unnecessary since that's just an initialization step which only needs doing once per restart.

2) Move the with(...) calls outside of the Button altogether, to someplace else in the worksheet. Here I put it in the worksheet's Startup region, so that it's not visible when looking at the worksheet's body. (I'm guessing that you won't people being being distracted by the code, whether its outright visible or even just buried in some Code-Edit Region.)
For fun I've thrown in a call to randomize() here, which has the effect of making a different set of random values (and, here, plots) be generated after any restart or reopening of the sheet. This make the first plot be different from the previous session's first plot.

You could use the ParseTime command in the StringTools package.

For example,


str := cat("9/7/2023", "10:22");


G :=StringTools:-ParseTime("%m/%d/%Y%l:%M", str);

Record(calendar = "Gregorian", second = 0, minute = 22, hour = 10, monthDay = 7, month = 9, year = 2023, weekDay = 5, weekDayName = "Thursday", yearDay = 250, `dst?` = false)












Adjust as needed. (You could also add a separator between the year and the hour, or add more fields, etc.)

The axis labels part can be had by,

  labels=[`x `(InertForm:-Display(10%^8,inert=false)*Unit(m)),
                `t `(s)]

which gets upright Roman m, italic x,s,t, a space before the opening brackets, and 10^8 in upright Roman without automatic simplification to 100000000.

Using `10`^8 is shorter to type, but the concession is that the 10 is in italics. Alternatives which also show the 10 in upright Roman include,

The following solutions found by solve can be tested by resubstituting and simplifying.



u[1] := -(-2*p^3*sigma^3*y^4+4*k*p^2*sigma^2*y^3+4*p^2*sigma^2*y^3-3*k^2*p*sigma*y^2-4*q*sigma^3*y^2-6*k*p*sigma*y^2+k^3*y-3*p*sigma*y^2+3*k^2*y+3*k*y+y)/(8*sigma^3)+A*y+B

sols := simplify([solve({u[1] = 0, eval(u[1], sigma = -sigma) = 0}, explicit)])

[{A = A, B = 0, k = k, p = p, q = q, sigma = sigma, y = 0}, {A = A, B = -(1/4)*p^3*y^4-(1/2)*y^2*q-A*y, k = -1, p = p, q = q, sigma = sigma, y = y}, {A = A, B = -(5/32)*(((16/5)*q*y+(32/5)*A)*sigma^3+I*(k+1)^3)*y/sigma^3, k = k, p = ((1/2)*I)*(k+1)/(y*sigma), q = q, sigma = sigma, y = y}, {A = A, B = (5/32)*y*((-(16/5)*q*y-(32/5)*A)*sigma^3+I*(k+1)^3)/sigma^3, k = k, p = -((1/2)*I)*(k+1)/(y*sigma), q = q, sigma = sigma, y = y}]

seq(simplify(eval([u[1], eval(u[1], sigma = -sigma)], s)), s = sols)

[0, 0], [0, 0], [0, 0], [0, 0]


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