acer

33193 Reputation

29 Badges

20 years, 215 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

This is not a venue for that kind of query.

You could use this web form.

Or you could send email to  support@maplesoft.com

See also phone numbers and details at the bottom of this page.

The commands CoefficientList and CoefficientVector from the PolynomialTools package share a single Help page.

The following is an example on that page,

    PolynomialTools:-CoefficientVector(5*x^1000000000 + 1, x, storage = sparse);

The result of that command is the following:

    Vector[column](1000000001,{1=1, 1000000001=5},datatype=anything,
                             storage=sparse,order=Fortran_order,shape=[])

In your Maple 2025, that seems to cause a (Java memory resource) problem when pretty-printed as 2D Output using the "Scrollable Matrices" feature new in Maple 2024.

If you issue that command in a worksheet then that worksheet Tab/Window may become frozen and unusable. That command also prevents the CoefficientList Help page from being displayed.

There is now a bug report against this. (I don't recall seeing such a report earlier. It's helpful to use the form to submit such a bug report, when posting; better two reports than none.)

If I change the relevant line to,
    ScrollableMathTableOutput=true
in my Maple 2026 GUI Preferences file then I can get that Help page to display in my Maple 2026.0. The commands mentioned above then get the output pretty-printed ok, as well.

Could you utilize the useunits option of the plot command?

I did the following in Maple 2025, but you could try it in your Maple Flow 2025.
 

B := (4.*10^(-6))*Unit('m'*'kg'/('A'*'s'^2))/I__gap

 

plot(B, I__gap = 0 .. .1*Unit('mm'), y = 0 .. .5, gridlines, useunits = [mm, T])

Related example, with the independent range being supplied in
meters, with the specification that the plot show it for mm.
Ie, with unit conversion for the x-axis also.

plot(B, I__gap = 0 .. 0.1e-3*Unit('m'), y = 0 .. .5, gridlines, useunits = [mm, T])


Download bagraara_1_ac.mw


nb: Units in expressions get rendered on this site within double-braces. That's done by the Mapleprime's very old back-end. In the actual products Maple & Maple Flow the units get rendered as usual, ie. in upright Roman font and without double-braces.

Your objective expression is an integral that contains the name r as a dummy variable-of-integration. The Minimize command can get confused by its presence in the objective expression. This can be clarified for Minimize by specifying the names over which to optimize, using its variables option.

It's also a good idea to use inert Int rather than active int (you don't want Maple to attempt symbolic integration for every numeric set of values for s,t,u,v.

restart

with(Optimization)

"term(a,b,c,d,r):=(exp(sin(r))-(a∗sin(b∗r+c)+d));"

proc (a, b, c, d, r) options operator, arrow, function_assign; exp(sin(r))-a*sin(b*r+c)-d end proc

Minimize(term(s, t, u, v, r)^2, {-100 <= s, -100 <= t, -100 <= u, -100 <= v})

[0.443734259186819141e-30, [r = HFloat(0.8573907336951694), s = HFloat(1.0651237756780674), t = HFloat(0.9373750940497176), u = HFloat(0.9414213728272717), v = HFloat(1.0810520913486565)]]

Minimize(abs(term(s, t, u, v, r)), {-100 <= s, -100 <= t, -100 <= u, -100 <= v})

[0.206279437975354085e-12, [r = HFloat(0.8598182185084339), s = HFloat(1.0763500233776817), t = HFloat(0.9650602699090793), u = HFloat(0.9650599306574976), v = HFloat(1.0839652198942415)]]

"term1(a,b,c,d):=Int((term(a,b,c,d,r))^(2),r=0..2*Pi):"

Minimize(term1(s, t, u, v), [], s = -1 .. 2, t = -1 .. 2, u = -1 .. 2, v = -1 .. 2, variables = [s, t, v, u])

[.236863805171295988, [s = HFloat(1.135097446580192), t = HFloat(1.0082336929148168), v = HFloat(1.2660536931610444), u = HFloat(-0.024551890862007708)]]

Minimize(term1(s, t, u, v), [s >= -100, t >= -100, u >= -100, v >= -100], variables = [s, t, v, u])

[.236863805171299013, [s = HFloat(1.135097426582723), t = HFloat(1.0082336959143356), v = HFloat(1.2660536793966521), u = HFloat(-0.024551920976264435)]]

NULL

Download test_AlfredF_2_ac.mw

Note also that Minimize does local optimization, in general, for multivariable problems. The result may be only locally optimizal wrt s,t,u,v. That might not be the global optimum for which you're searching. If that's the case then you could consider the DirectSearch v.2 package (available from the Maple Cloud or Application Center).

It does not make much convenient sense to use the writeto command in this context. That's more for things like getting all input & output echoed to a file, rather than storing an expression purely for convenient re-use. (It could be done, but it'd be somewhat awkward. It's not a natural way to do this task.)

You can accomplish your stated task most simply by using the save and read commands, and efficiently using Maple's .m (dotm) format. For example,

restart;

p := randpoly(x,degree=10,dense);

-7*x^10+22*x^9-55*x^8-94*x^7+87*x^6-56*x^5-62*x^3+97*x^2-73*x-4


So here you are, with a polynomial, assigned to some name.

Now you can store it to a file, for later re-use and efficient direct access, with
a single command.
 

save p, "pfile.m";


And that's all you have to do to store it. Now you can read it into any other session,
with a single other command.
 

restart;

read "pfile.m";


And that's all you need to do, to get that same stored polynomial, assigned to the same
name `p`, in your new sessions.

p;

-7*x^10+22*x^9-55*x^8-94*x^7+87*x^6-56*x^5-62*x^3+97*x^2-73*x-4

Download save_read_ex.mw

You could, of course, use a full path to the file, in the string above. Please ask, if you don't know how to construct such.

An alternative would be to use fprintf to write your polynomial to a text file. For a very large polynomial that might be measurably slower. You might prefer this way if you think that you'd ever want to access the polynomial using some program other than Maple (ie. as plaintext source). Here below are two variants on that, which differ slightly. The first example reads and evaluates from the text file, but doesn't assign -- though it shows that as a second step, with your choice of variable name. The second example reads from the text file and (always) assigns to name p.

restart;

p := randpoly(x,degree=10,dense):

fprintf("pfile.txt", "%a;", p):


And that's all you have to do to store it in plaintext. You can open that
file with your favorite editor program.

And now you can read it into any other session.
 

restart;

read "pfile.txt";

-7*x^10+22*x^9-55*x^8-94*x^7+87*x^6-56*x^5-62*x^3+97*x^2-73*x-4

p := %;

-7*x^10+22*x^9-55*x^8-94*x^7+87*x^6-56*x^5-62*x^3+97*x^2-73*x-4


In that variant it didn't assign the polynomial to any name, merely by
reading it in. The assignment to a name happens in its own statement.

In the next variant it always assigns, and always to name `p`,
when read in.
  

restart;

p := randpoly(x,degree=10,dense):

fprintf("pfile.txt", "p := %a;", p):

 

restart;

read "pfile.txt":

p;

-7*x^10+22*x^9-55*x^8-94*x^7+87*x^6-56*x^5-62*x^3+97*x^2-73*x-4

Download fprintf_read_ex.mw

ps. There is no Plots package, with a capital P, in stock Maple 2026. It's unclear what you were trying to convey about that.

If that's the first time you're doing it in Maple 2026.0 then, yes, it is a known thing.

That manual installation using PackageTools:-Install (from the Maple cloud) should get you the first one for Maple 2026.0. And that should contain an update of SupportTools itself, so that SupportTools:-Update would work for subsequent updates.

See the Comment here, for a note on that.

You can get that error message if you are assigning the result to a name, and the statement ends with a semicolon.

Perhaps the easiest remedy for that is to terminate the assignment statement with a full colon, and then evaluate the name in another line.

Eg,

  P := plots:-implicitplot(...):
  P;

If that's not the issue, then upload and attach your worksheet using the green up-arrow in the toolbar of the Mapleprimes editor.

@Honigmelone I don't understand what you mean by, "However I found that I inject e^(...) at some point." Are you saying that action is not something under your control and which you cannot avoid doing, and that you simply want to undo it before calling invlaplace?

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

expr := e^(-s*a_pos)/(b*s^2 + c);

e^(-s*a_pos)/(b*s^2+c)

lprint(expr);

e^(-s*a_pos)/(b*s^2+c)

new := subsindets(expr, identical(e)^anything, u->exp(op(2,u)));

exp(-s*a_pos)/(b*s^2+c)

lprint(new);

exp(-s*a_pos)/(b*s^2+c)

inttrans[invlaplace](new, s, t) assuming a_pos>0;

Heaviside(t-a_pos)*sin((c/b)^(1/2)*(t-a_pos))*(c/b)^(1/2)/c

Download Honigmelone_1_ac.mw

Is this the kind of thing you're after?

I'm taking your mention of "convert" as a hint that you might be trying to change the units by which to interpret DO2i, with a corresponding rescaling. You could accomplish that directly using plots:-pointplot. Or you could accomplish that by constructing a new list with the desired (converted) units, and then using ScatterPlot.

Below, I did a couple of variants, as I'm not sure whether you want to see the names DO2i and Hb in the axes labels, or not.

Also, if you utilize Units(g/dL), etc, in the useunits or labels options, then Maple will render them in upright Roman font, as opposed to the double-braces that this site shows them with. Of course you are also free to utilize just the plain names instead. I've done a mix, so you can see your choices.

restart; with(Units); with(Statistics)

Automatically loading the Units[Simple] subpackage
 

cte := 1.34*Unit('mL'/'gram')

SaO2 := .99

Hb := [seq(i*Unit('g'/'dL'), i = 4 .. 12)]NULL

[4*Units:-Unit(g/dL), 5*Units:-Unit(g/dL), 6*Units:-Unit(g/dL), 7*Units:-Unit(g/dL), 8*Units:-Unit(g/dL), 9*Units:-Unit(g/dL), 10*Units:-Unit(g/dL), 11*Units:-Unit(g/dL), 12*Units:-Unit(g/dL)]

SvO2 := .75

Q := 3.4*Unit('L'/'min')

BSA := 1.8*Unit('m'^2)

DO2i := elementwise(cte*Hb*SaO2*Q/BSA)

[0.1670533333e-5*Units:-Unit(m/s), 0.2088166667e-5*Units:-Unit(m/s), 0.2505800000e-5*Units:-Unit(m/s), 0.2923433334e-5*Units:-Unit(m/s), 0.3341066667e-5*Units:-Unit(m/s), 0.3758700000e-5*Units:-Unit(m/s), 0.4176333334e-5*Units:-Unit(m/s), 0.4593966667e-5*Units:-Unit(m/s), 0.5011600000e-5*Units:-Unit(m/s)]

plots:-pointplot(`<|>`(`<,>`(Hb), `<,>`(DO2i)), useunits = [g/dL, mL/(:-min*m^2)], gridlines, size = [700, 450])

plots:-pointplot(`<|>`(`<,>`(Hb), `<,>`(DO2i)), useunits = [g/dL, mL/(:-min*m^2)], gridlines, size = [700, 450], labels = [InertForm:-Display('Hb')*Unit(g/dL), InertForm:-Display('DO2i')*Unit(mL/(min*m^2))])

new := `~`[convert](DO2i, units, mL/(:-min*m^2))

[100.2320000*Units:-Unit(mL/(min*m^2)), 125.2900000*Units:-Unit(mL/(min*m^2)), 150.3480000*Units:-Unit(mL/(min*m^2)), 175.4060000*Units:-Unit(mL/(min*m^2)), 200.4640000*Units:-Unit(mL/(min*m^2)), 225.5220000*Units:-Unit(mL/(min*m^2)), 250.5800000*Units:-Unit(mL/(min*m^2)), 275.6380000*Units:-Unit(mL/(min*m^2)), 300.6960000*Units:-Unit(mL/(min*m^2))]

ScatterPlot(Hb, new, gridlines, size = [700, 450], labels = [InertForm:-Display('Hb')*Unit(g/dL), InertForm:-Display('DO2i')*Unit(mL/(min*m^2))])

``

NULL

Download PlotQuestionMaplePrimes_ac2.mw

 

ps. The InertForm:-Display calls use used so that the names DO2i and Hb (if you use them in the labels) wouldn't evaluate to the lists assigned to them, if you were to assign the actual plots to names and then later pass them around and get them re-evaluated.

There is a bullet-point in the Description section of the ExpressionTools:-Compare Help-page, that explains that it uses the uneval procedure parameter modifier. That bullet point states:

   Compare uses the uneval parameter modifier. Providing the evaluate option
   tells Maple to fully evaluate expression1 and expression2 before computing
   and displaying their differences.

And here is that option working with the OP's example:

restart

ode := diff(diff(y(x), x), x)+sin(y(x)) = 0; IC := y(infinity) = Pi; sol := [dsolve([ode, IC])]

sols := dsolve([ode, y(x__IC) = y__IC])

y(x) = RootOf(-(Int(1/(2*cos(_a)+RootOf(-(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC))+x__IC+c__2))^(1/2), _a = 0 .. _Z))+x+c__2), y(x) = RootOf(Int(1/(2*cos(_a)+RootOf(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC)+x__IC+c__2))^(1/2), _a = 0 .. _Z)+x+c__2)

(1)

ExpressionTools:-Compare(sol[1], (y(x) = RootOf(-(Int(1/(2*cos(_a)+RootOf(-(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC))+x__IC+c__2))^(1/2), _a = 0 .. _Z))+x+c__2), y(x) = RootOf(Int(1/(2*cos(_a)+RootOf(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC)+x__IC+c__2))^(1/2), _a = 0 .. _Z)+x+c__2))[1], evaluate)

y(x) = RootOf(-(Int(1/sqrt(2*cos(_a)+RootOf(-(Int(1/sqrt(2*cos(_a)+_Z), _a = 0 .. Pi))+_a+c__2)), _a = 0 .. _Z))+x+c__2)

 

y(x) = RootOf(-(Int(1/sqrt(2*cos(_a)+RootOf(-(Int(1/sqrt(2*cos(_a)+_Z), _a = 0 .. y__IC))+x__IC+c__2)), _a = 0 .. _Z))+x+c__2); "_noterminate"

(2)

Download Compare_and_indexing_output_ac0.mw
 

note: You don't need to use a distinct pair of statements, in order to do it in some other way. Here are two other ways that each handle your example with just a single statement.

restart

ode := diff(diff(y(x), x), x)+sin(y(x)) = 0; IC := y(infinity) = Pi; sol := [dsolve([ode, IC])]

sols := dsolve([ode, y(x__IC) = y__IC])

y(x) = RootOf(-(Int(1/(2*cos(_a)+RootOf(-(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC))+x__IC+c__2))^(1/2), _a = 0 .. _Z))+x+c__2), y(x) = RootOf(Int(1/(2*cos(_a)+RootOf(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC)+x__IC+c__2))^(1/2), _a = 0 .. _Z)+x+c__2)

(1)

eval(('ExpressionTools:-Compare')(sol[1], (y(x) = RootOf(-(Int(1/(2*cos(_a)+RootOf(-(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC))+x__IC+c__2))^(1/2), _a = 0 .. _Z))+x+c__2), y(x) = RootOf(Int(1/(2*cos(_a)+RootOf(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC)+x__IC+c__2))^(1/2), _a = 0 .. _Z)+x+c__2))[1]))

y(x) = RootOf(-(Int(1/sqrt(2*cos(_a)+RootOf(-(Int(1/sqrt(2*cos(_a)+_Z), _a = 0 .. Pi))+_a+c__2)), _a = 0 .. _Z))+x+c__2)

 

y(x) = RootOf(-(Int(1/sqrt(2*cos(_a)+RootOf(-(Int(1/sqrt(2*cos(_a)+_Z), _a = 0 .. y__IC))+x__IC+c__2)), _a = 0 .. _Z))+x+c__2)

(2)

(proc (e1, e2) options operator, arrow; ExpressionTools:-Compare(e1, e2) end proc)(sol[1], (y(x) = RootOf(-(Int(1/(2*cos(_a)+RootOf(-(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC))+x__IC+c__2))^(1/2), _a = 0 .. _Z))+x+c__2), y(x) = RootOf(Int(1/(2*cos(_a)+RootOf(Int(1/(2*cos(_a)+_Z)^(1/2), _a = 0 .. y__IC)+x__IC+c__2))^(1/2), _a = 0 .. _Z)+x+c__2))[1])

y(x) = RootOf(-(Int(1/sqrt(2*cos(_a)+RootOf(-(Int(1/sqrt(2*cos(_a)+_Z), _a = 0 .. Pi))+_a+c__2)), _a = 0 .. _Z))+x+c__2)

 

y(x) = RootOf(-(Int(1/sqrt(2*cos(_a)+RootOf(-(Int(1/sqrt(2*cos(_a)+_Z), _a = 0 .. y__IC))+x__IC+c__2)), _a = 0 .. _Z))+x+c__2); "_noterminate"

(3)


Download Compare_and_indexing_output_ac.mw

It happens that simplify does not always find constructions like completing-the-square.

Of course, the following is example-specfic (ad hoc) and not general, since it depends on the choice of variables supplied to collect and CompleteSquare. But, fwiw, using Maple 2026.0,

restart;

interface(showassumed = 0):

#assume(a>=0, b>=0, c>=0);

#assume(x::real, y::real,z::real);

S := sqrt(x^2+(a+sqrt(y^2+(b+sqrt(z^2+c^2))^2))^2);

(x^2+(a+(y^2+(b+(c^2+z^2)^(1/2))^2)^(1/2))^2)^(1/2)

E := expand(S);

(x^2+a^2+2*a*(y^2+b^2+2*b*(c^2+z^2)^(1/2)+c^2+z^2)^(1/2)+y^2+b^2+2*b*(c^2+z^2)^(1/2)+c^2+z^2)^(1/2)

collect(E,[x,y],u->Student:-Precalculus:-CompleteSquare(u,[a,b]));

(x^2+(a+(y^2+(b+(c^2+z^2)^(1/2))^2)^(1/2))^2)^(1/2)

Download rad_ex1.mw

One difficulty, AFAICS, is that every character in your .txt file is separated by a zero-byte null instance. I got rid of those using a Linux command in a terminal shell.

Your criteria for where your regions began/ended are rather vague and hazy, so I just used small values like 0.1,0.3.

I make a list from the 2nd column, and then search that for the positions where your described changes happen.

Links to file attachments are at the end.

restart;

# After removing all zero-byte null instances.
# I did that in Linux with:     tr -d '\0' < F12_1.txt > foo.txt

M := ImportMatrix("foo.txt"):

 

# retain only rows with only numeric and nonnegative entries.
newM:=M[[seq(`if`(andmap(type,M[i],And(numeric,nonnegative)),i,NULL),i=1..op([1,1],M))]]:

 

# number of rows and columns
op(1,newM);

6045, 5

plot(newM[..,[1,2]],size=[700,300]);

L2 := convert(newM[..,2],list):

p1 := ListTools:-SelectFirst(1,(u->u>0.1),L2,output=indices)[1];

158

p2 := p1 + ListTools:-SelectFirst(1,(u->u<0.1),L2[p1+1..],output=indices)[1];

4716

plot(newM[p1..p2,[1,2]],
     view=[0..newM[p2,1]*1.1, default], size=[700,300]);

p3 := p2 + ListTools:-SelectFirst(1,(u->u>0.3),L2[p2+1..],output=indices)[1];

4886

p4 := p3 + ListTools:-FindMaximalElement(L2[p3+1..], position)[2];

5958

# slope
(newM[p4,2] %- newM[p3,2]) %/ (newM[p4,1] %- newM[p3,1]);
value(%);

`%/`(`%-`(83.760, .32737), `%-`(73.53, 65.58))

10.49467044

plot(newM[..,[1,2]],size=[700,300],
     axis[1]=[tickmarks=[[newM[p1,1],newM[p2,1],newM[p3,1],newM[p4,1]],rotation=Pi/4]]);


Download FDS_ERT_01ac.mw

foo.txt

Projection mapping of an image onto a sphere can be done.

For example (since Maple 18), see here. That old Post started out as code to do it through various Array and plotting structure programming techniques. But these days it can be done directly with the command plot3d and its image option.

You don't have to scale down the imported image, but its manual rotation, etc, in the GUI can get sluggish, if the image is large. If you don't want to scale it then you could simply pass that URL string as the value for plot3d's image option.

raw:=ImageTools:-Read("https://www.evl.uic.edu/pape/data/Earth/512/PathfinderMap.jpg"):
img:=ImageTools:-Scale(raw,1..201):

plot3d(1,th=0..2*Pi,p=-Pi..0,image=img,coords=spherical);

Are you trying to get the AI to cough up ExpressionTools:-Compare ?

I suspect that a start to improving your prompt is to not use the word "new", as in "new command", since that's a bit like an open invitation for it to invent a new name for an as-yet nonexistent command. But even without the presence of the word "new", it may hallucinate.

For example, even without using the word "new" and "highlight" I got it to invent the nonexistent,
    ExpressionTools:-HighlightDifferences

[edit] I got it to suggest ExpressionTools:-Compare with the prompt, "What is an existing, actual Maple command that shows in 2D-Output the differences between two expressions". That was my third prompt.

The indexing/selection notation is reliable and documented, and not new.

It's also very commonly used.

By the way, you typo'd in the alternative syntax that you wrote that you'd usually go for.

u := [a,b,c,d];

[a, b, c, d]

u[2..-1];

[b, c, d]

u[2..];  # the -1 is implied

[b, c, d]

[op(2..-1),u];  # syntax the OP mentioned

[2, -1, [a, b, c, d]]

[op(2..-1, u)];  # likely intended

[b, c, d]

Download ind_ex.mw

ps. Apart from its terseness (on top of its commonness and efficiency) this indexing/selection notation has another advantage over using op. With square-bracket indexing the notation also works for Vectors and Matrices. Sometimes this adds the convenience that the same code can handle either Vector/Matrix as well as list, or do so with only minor adjustment.

I'm a bit pressed to think of situations in which using op like that would be preferable, except for the rare (for me) situation where I was trying to prep for a subsop call, and was double-checking/forming my op call's details.

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