acer

33166 Reputation

29 Badges

20 years, 194 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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.

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

@EdmondR Does this edit of your first .flow file do any better, or does it open all blank?

Statik_ac01.zip

(There seems to be a corrupted `MapleFlow-Image` substructure in your first file, which I've removed; if we're lucky then that is enough to make the rest of the document accessible.)

And here's an edited version of your second .flow file (again, with a corrupted `MapleFlow-Image` substructure removed):

Statik_ac02.zip

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.

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