acer

33141 Reputation

29 Badges

20 years, 189 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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.

A Vector is a mutable data-structure, and its entries can be changed in-place.

That's not true of lists. (in-place replacement into a list "fakes" the in-place aspect, and actually creates a new list in memory.)

You could assign Vectors to names A and B  and they might happen to have the same entries at some moment. But they are still two different containers, whose entries might later change.

You could instead compare the two Vector instances with, say, EqualEntries.

This is not a bad question; variants have been asked many times before. Here's a good one.

And here's some fun, with is,

restart;

V1 := [a, b];

[a, b]

V2 := [a, b];

[a, b]

V3 := [sqrt(a^2), b];

[(a^2)^(1/2), b]

EqualEntries(V1, V2);

true

andmap(is, V1-V2, 0);

true

andmap(is, V1-V3, 0);

false

andmap(is, V1-V3, 0) assuming a::positive;

true

Download Vec_andmap.mw

Is there a reason for you to not use the Calendar package?

For example (and you can tweak this in various documented ways  including which hour on the reference date, how many finer-level fields you pick out, etc.),

restart;


(I don't know whether you might want another reference date, eg. November 24, 4714 BCE)

F := jd->parse(Calendar:-VariantFormat(
                 Calendar:-AdjustDateField(Date(-4712,1,1,12),
                                           "date",jd),
"%Y,%m,%d" )):

 

Calendar:-JulianDayNumber( 2026, 4, 5 );

2461136

F(%);

2026, 4, 5

 

Calendar:-JulianDayNumber( 1911, 12, 25 );

2419396

F(%);

1911, 12, 25

Download Calendar_ex.mw 

 

Without using parse and a format, you could also pick off values using static exports of the constructed Date object, eg, using a procedure such as,

     jd -> [':-Year',':-Month',':-DayOfMonth'](
                  Calendar:-AdjustDateField(Date(-4712,1,1,12),"date",jd))[]:

Perhaps the simplest way would be something like,

    seq(11 .. 234, 11)

I describe it as simple because it uses only your original values of 11 and 234, and doesn't require that you also know how to come up with the extra value of 21 which is iquo(234,11) .

But read on for others, some close to your attempt, some also simple, etc.

You could read the help-page for the iquo and irem commands, and utilize those. (There are many ways to proceed, and for your very small example the efficiency differences will be small.)

(This site isn't showing the full results from this do-loop; but they show in Maple itself.)

Here are five ways, starting with an edited variant of what you were trying with a loop.

1st: Something like the OP's original
for a from 3 to 234 do if irem(a, 11) = 0 then print(a, "yay", (1/11)*a) end if end do

231, "yay", 21

2nd: Similar to the above.
seq(ifelse(irem(a, 11) = 0, a, NULL), a = 3 .. 234)

11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231

iquo(234, 11)

21

3rd
seq(11*i, i = 1 .. iquo(234, 11))

11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231

4th
seq(i, i = 11 .. 234, 11)

11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231

NULL

5th
for a from 11 by 11 to 234 do print(a, "yay", (1/11)*a) end do

231, "yay", 21

NULL

Download if_question_i.mw


The third way does,
   seq(i*11, i=1 .. 21)
but it also shows you how that value of 21 can be obtained, using iquo(234,11) .

The fourth way just calls seq, using 11 for the increment.

You could compare the efficiency of doing a single iquo call, versus using irem (or your other divisibility test) for multiple values. The 5th way illustrates (analogously to the 4th way) that if you get your loop increment right then you don't need a divisibility test for each value of the loop index.

Here is one way,

restart;

kernelopts(version);

`Maple 2026.0, X86 64 LINUX, Mar 05 2026, Build ID 2001916`

eq:=x^2+2*x+1=0;

x^2+2*x+1 = 0

PDEtools:-Solve(eq, x, 'dropmultiplicity'=false);

x = -1, x = -1


Download PDEtools_solve_march_28_2026_ac.mw

Most all type's can also be used like a property. (See second bullet point on the ?property Help page)

But many properties do not match any type, and those cannot be used as a type.

NonZero is a property, but not a type.

Non(0) is a type specification, and can be used like a property check.


ps. The Help page for ?property states that Not can be used as a synonym for Non, which means that they can be used in a similar manner (ie. for their primary purpose of property-checks, and, as it happens, for type-checks). It doesn't state that they are existentially identical.

pps. You mentioned that you can "combine" properties. With a similar kind of effect, for types,
   And(integer,Non(0))
   Or(posint,negint)

It is unclear (to me) what your full requirements are.

The explanation seems incomplete. You could provide a comprehensive set of different input and their desired outputs (just as data, not with calls to the procedure). The guess work is awkward.

Here's one guess:

restart

Test:=overload([
proc(l1::{`+`,`*`,`=`, `symbol`,procedure,not(list)},
     l2::And({`+`,`*`,`=`, `symbol`,procedure,not(list)},
             satisfies(u->not type(u,identical(:-point)=list))) )
  option overload;
  print("1st proc ",l1," ",l2);
  return NULL;
end proc,

proc(l1::{`+`,`*`,`=`, `symbol`,procedure,not(list)},
     {point::list:=NULL})
  print("2nd proc",l1,"point",point);
end proc
]):

 

l:=3*x+4*y-5;
h:=4*x-8*y = 5;
P:=[3,5]

3*x+4*y-5

4*x-8*y = 5

[3, 5]

Test(l,h)

"1st proc ", 3*x+4*y-5, " ", 4*x-8*y = 5

Test(l,point=P)

"2nd proc", 3*x+4*y-5, "point", [3, 5]

 

Test(h,point=[2,7])

"2nd proc", 4*x-8*y = 5, "point", [2, 7]

Test(l,P)

"2nd proc", 3*x+4*y-5, "point"

Download 2026-02-28_Q_Test_proc_Line_point_inputs_ac.mw

Even though your equations might not have an explicit solution for x in terms of r (except say x=4 when r=0 or something trivial), you could still get a black-box thing like an unevaluated procedure call -- that evaluates to a float upon substitution.

For example, (and this can be tweaked in a few ways, but first let's see if it'd serve...)

restart;

f := x -> (9/10*log10(x-4))*r;

proc (x) options operator, arrow; (9/10)*log10(x-4)*r end proc

g := x -> (1-exp(x-4*r/(3/2)))*r/(3/2);

proc (x) options operator, arrow; (2/3)*(1-exp(x-(8/3)*r))*r end proc

#plots:-implicitplot(f(x)/r=g(x)/r, x=4..10, r=0..10);

# compute x from a given numeric r value
T:=unapply('fsolve(eval(f(x)/:-r=g(x)/:-r, :-r=R),x=4..10)',R,numeric):

T(3);

6.978587592

evalf[20](T(8.2));

9.5047496372174023605

evalf[30](T(40));

9.50478980785497098814747169324

#plot([T(r),r,r=1..10],smartview=false);

# compute r from a given numeric x value
Q := unapply('fsolve(f(x)/:-r=g(x)/:-r, r=1..infinity)',x,numeric):

Q(6.978587592);

3.000000000

evalf[20](Q( T(8.2) ))

8.1999999999999996005

evalf[50]( Q( evalf[50]( T(40) ) ) );

39.999999994124002183861923002652983811493695639841

evalf[100]( Q( evalf[100]( T(40) ) ) );

39.99999999999999999999999999999999999999999999999999999999989026667140350885315187449238910215763468

evalf[20]( T( evalf[100]( Q(5.7) ) ) );

5.7000000000000000000

Q(x);

Q(x)

T(r);

T(r)

expr := Q(x) + sin(x);

Q(x)+sin(x)

eval(expr, x=5);

1.875000000+sin(5)

eval(expr, x=5.0);

.9160757253

Download bbox_ex1.mw

If you think that kind of thing won't suffice then you should explain clearly and in full what it is that you'd hope to do with an explicit formula.

ps. I changed the floats in your originals to exact rationals, so that there wouldn't be up-front loss of precision. It's nicer to be able to see these procedures scale up with Digits.

In Maple 2025.2 (but not Maple 2026.0, for some reason) the following attains from solve with its allsolutions option passed,

restart;

kernelopts(version);

`Maple 2025.2, X86 64 LINUX, Nov 11 2025, Build ID 1971053`

S:=solve(x^Pi=Pi^x, x, allsolutions);

exp(-LambertW(_Z3, -(ln(Pi)+(2*I)*Pi*_Z4)*exp(-(2*I)*_Z1)/Pi)-(2*I)*_Z1)

S2:=simplify(S);

-Pi*LambertW(_Z3, -(ln(Pi)+(2*I)*Pi*_Z4)*exp(-(2*I)*_Z1)/Pi)/(ln(Pi)+(2*I)*Pi*_Z4)

V := indets(S,suffixed(_Z)):

map(getassumptions,V);

{{_Z1::integer}, {_Z3::integer}, {_Z4::integer}}

G := [seq(seq(seq([[a,b,c],evalf(eval(S,[V[1]=a,V[2]=b,V[3]=c]))],
                  a=-1..1),b=-1..1),c=-1..1)]:

H := sort(G,key=(u->u[2])):

map(print,H):

[[0, 0, 0], 2.382179085]

[[0, -1, 0], 3.141592654]

[[1, 1, 1], -3.309169741-1.233783823*I]

[[-1, -1, -1], -3.309169741+1.233783823*I]

[[-1, 1, 1], -2.236894072-.8433058782*I]

[[1, -1, -1], -2.236894072+.8433058782*I]

[[0, 1, 1], -1.344981162-.4160801868*I]

[[0, -1, -1], -1.344981162+.4160801868*I]

[[-1, 0, -1], -.6541516770-0.8849459564e-1*I]

[[1, 0, 1], -.6541516770+0.8849459564e-1*I]

[[1, 0, 0], -.5129851761-.6518680141*I]

[[-1, 0, 0], -.5129851761+.6518680141*I]

[[1, 0, -1], -.1312239018-.4040885036*I]

[[-1, 0, 1], -.1312239018+.4040885036*I]

[[0, 0, -1], .3488068895-.3884928435*I]

[[0, 0, 1], .3488068895+.3884928435*I]

[[-1, 1, -1], 1.047180350-.1618339307*I]

[[1, -1, 1], 1.047180350+.1618339307*I]

[[1, 1, -1], 2.142072723-0.9371241989e-2*I]

[[-1, -1, 1], 2.142072723+0.9371241989e-2*I]

[[0, -1, 1], 3.141592654-0.5641875567e-9*I]

[[0, 1, -1], 3.141592654+0.5641875567e-9*I]

[[-1, 1, 0], 6.368931094-7.945243820*I]

[[1, -1, 0], 6.368931094+7.945243820*I]

[[1, 1, 0], 7.716675056-14.74223466*I]

[[-1, -1, 0], 7.716675056+14.74223466*I]

[[0, 1, 0], 8.504164459-20.47402463*I]

Download s_ex.mw

restart;

kernelopts(version);

`Maple 2026.0, X86 64 LINUX, Mar 05 2026, Build ID 2001916`

TM := module()
  export Cartline,Parmline;
  local Parmvars:=[:-alpha,:-beta,:-rho],Cartvars:=[:-x,:-y,:-z];

  Cartline := proc(p1::list,p2::list,{vars::list:=TM:-Cartvars})
    local l;
    l := (p2[2]-p1[2])*vars[1]+(p1[1]-p2[1])*vars[2]
         -p2[2]*p1[1]+p1[2]*p2[1];
    return l;
  end proc;

  Parmline := proc(p1::list,p2::list,{varp:=TM:-Parmvars})
    local l;
    l := p1+~varp[1]*<p2-p1>;
    return l;
  end proc;
end module:

 

TM:-Cartline([4,3],[-8,4]);

x+12*y-40

TM:-Cartline([4,3],[-8,4],vars=[s,t]);

s+12*t-40

TM:-Parmline([4,3],[-8,4]);

Vector(2, {(1) = 4-12*alpha, (2) = 3+alpha})

TM:-Parmline([4,3],[-8,4],varp=[Lambda]);

Vector(2, {(1) = 4-12*Lambda, (2) = 3+Lambda})


2026-03-26_Q_Module_Generic_Variables_ac.mw

 

nb. I don't know what kinds of indexable structure you might want to use to pass the "variables". So, in the procedure's parameter specification, you could utilize varp::list:=TM:-Parmvars or varp::list(name):=TM:-Parmvars (or several of variants) rather than just varp:=TM:-Parmvars.  I don't know how restrictive you might want to make it.

The discont=true option can work if the fallback value for the piecewise is undefined instead of [] the empty list.

Using Maple 2026.0,

plot_piecewise_march_25_2026_ac.mw

 

Maple 2025.2 and Maple 2026.0 return true (and 0) for these, without any conversion.

You're not doing something wrong; it's a bug, that has since been improved.

restart

kernelopts(version)

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

is(convert(exp(u)/(1+exp(u))^2 = 1/(4*cosh((1/2)*u)^2), exp))

true

simplify(convert(exp(u)/(1+exp(u))^2-1/(4*cosh((1/2)*u)^2), exp))

0

NULL

Download test1_ac.mw

In Maple 2024.2 you could also convert to trigh (ie. change the lhs rather than the rhs).

I've submitted a report on this in the past. But it couldn't hurt (and might help) if you'd like to submit your own bug report against it.

The font used (and possibly also that Component's spacing) is not the same on all of the Windows/Linux/Mac OS's. On my Maple 2024.2 for Linux I can fit 16 numerals into a TextArea with "Visible Character Width" set to 10.

On Linux (at least) the font used for TextArea components is not a fixed-width font, so it matters which characters are used. It's unclear what is meant by "Visible Character Width" in such a context. See lowercase "i" vs uppercase "W".

[edit]
Best solution: fixed-width font that has same size and appearance on all three OS (and if that can't be done in Java, then... oof).
Worst solution: same fonts as now, but a component that adjusts visible width according to its running content.

The SupportTools version shipped in Maple 2026.0 has a flaw that interferes with its Update command.

But it's possible to update the original SupportTools in Maple 2026, from the the MapleCloud via GUI login, or with the Maple command

    PackageTools:-Install(4797495082876928);

And that contains not just the first set of its Library fixes for 2026 but also a fix for SupportTools itself.

ps. I copied this from a response in the Beta users forum.

In 2D Input mode you can get that combination is a few different ways.

You can get it by using command-completion. For example, in 2D Input mode (the default for new users), simply type the keystrokes   Delta   and then hit the Escape key. And then once you have the Greek letter shown you can type Q, etc.

You can also get it in 2D Input mode by selecting the typeset Greek Delta from the palettes. It's available from the Greek palette. And if you'd like you can produce it alone as an output and then select&drag that to your Favorites palette.

Either of those two approaches could be used to produce the following,

Q+`&Delta;Q`

Q+`&Delta;Q`

Download Q.mw

In 1D Input mode (not the default for new users) you could enter that combination as the plaintext code,

    `&Delta;Q`

and you'd see the typeset Greek letter in the output.

ps. I'm not sure what you intend on the left-hand side of your assignment statement. Be careful about using Q followed by an apostrophe unless you right-click on it in the input and turn it into an Atomic Identifier (a mere name). Otherwise you might get it interpreted as a call to diff, ie. diff(Q(x),x), from the prime notation in calculus; and you wouldn't want to assign to that.

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