MaplePrimes Questions

Groupings([a, b, ..., n], k)

Is there a built-in function in Maple that generates all possible groupings of the elements [a, b, ..., n] taken k at a time?

Example:

Groupings([a,b,c,d], 2)

Expected output:

[[[[a, b], c], d], [a, [[b, c], d]], [[a, [b, c]], d], [a, [b, [c, d]]], [[a, b], [c, d]]]

B12 := -6*(p1 + p2)/(p1 - p2)^2;
F2 := (theta1*theta2*p1^2 + (-2*p2*theta1*theta2 - 6)*p1 + theta1*theta2*p2^2 - 6*p2)/(p1 - p2)^2;

to..

F2 := theta1*theta2 + (-6*p1 - 6*p2)/(p1 - p2)^2
F2:= theta1*theta2 + B12  ( how to get this ?)

Should be very easy, but it is not 

For the NonlinearFit function in the Statistics package, how can I determine initial values that will allow it to solve and not diverge in this case: NonlinearFit((p1*x^2 + p2*x + p3)/(q1*x + x^2 + q2), Ycg, Sx, x) returns with:

"Warning, limiting number of iterations reached" and displays the coefficient values when it gave up. Clearly they were diverging and it was never going to find a solution. Here are values it stopped with:

[p1=583621.008503822, p2 = 59223.7407763244, p3 = 92888.8332296935, q1 =6192.35371505405, q2 = 230.127618843129]

If I give it good guesses, it finds the solution:

iv := [p1 = 494.8, p2 = -156, p3 = 12.45, q1 = -0.2884, q2 = 0.02548];
NonlinearFit((p1*x^2 + p2*x + p3)/(q1*x + x^2 + q2), Ycg, Sx, x, initialvalues = iv);

[p1=494.772354721411,p2=-155.993031307792, p3 = 12.4504112058999, q1 = -0.288444965762112, q2 = 0.0254838840984013]

The problem is, I got the initial values from the MATLAB Curve Fitting Toolbox. I would like be to use Maple alone and not need MATLAB for cure fitting. How can I compute initial values that will allow Maple to find a solution?

Did you intend on doing the diffetentiation elememtwise, ie. on each of the Matrix entriez?

Did you try,

   diff~(V, x)

or,

  map(diff, V, x)

?

I defined a 2×2 matrix V with entries involving operator-valued fields u(x,t), ω(x,t), and scalar function β(t). On macOS with Maple 2024.0, when I try to compute the derivative with respect to x using 

Vx := (diff, V, x);

Maple does not return a result. It just shows “Evaluating”

restart

kernelopts(version)

`Maple 2024.0, APPLE UNIVERSAL OSX, Mar 01 2024, Build ID 1794891`

(1)

with(LinearAlgebra)

with(Physics)

with(PDEtools); undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(2)

interface(showassumed = 0)

Setup(mathematicalnotation = true)

[mathematicalnotation = true]

(3)

quantumOperators := {omega, u}

{omega, u}

(4)

Setup(quantumoperators = quantumOperators)

[quantumoperators = {omega, u}]

(5)

assume(x::real); assume(t::real)

declare(u(x, t), omega(x, t), B(x, t), alpha(t), beta(t), v1(x, t))

u(x, t)*`will now be displayed as`*u

 

omega(x, t)*`will now be displayed as`*omega

 

B(x, t)*`will now be displayed as`*B

 

alpha(t)*`will now be displayed as`*alpha

 

beta(t)*`will now be displayed as`*beta

 

v1(x, t)*`will now be displayed as`*v1

(6)

V := -(1/2)*Matrix([[beta(t)*(diff(omega(x, t), t)), -(diff(u(x, t), t))], [-(diff(u(x, t), t)), -beta(t)*(diff(omega(x, t), t))]])/lambda

Matrix(%id = 36893488152030778900)

(7)

Vx := diff(V, x)

Download derivativve.mw

I created an image by a matrix 8x8:

M:=1/255*RandomMatrix(8,generator=0..255):
G:=convert(M,image):
Embed(G)

but the image dispayed is very small, of course. Is there a way to visualize the 8x8 pixel image larger, so I can see the pixels?

While solving for i1 encounter too many terms. How can I simplify it so that only " Pn,Pr and w" remain, with all other variables grouped into constants, so that the equation for the optimal i1​ becomes small and manageable?
 

restart

kernelopts(version)

`Maple 2019.1, X86 64 WINDOWS, May 21 2019, Build ID 1399874`

(1)

Pi1 := (w-i1)*(1/2+(i1-i2)/(2*tau))*(1-(Pn-Pr)/(1-delta))+(s-i1-Crr)*(1/2+(i1-i2)/(2*tau))*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)+Ce*rho0*(((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)*eta+1-(Pn-Pr)/(1-delta))

(w-i1)*(1/2+(1/2)*(i1-i2)/tau)*(1-(Pn-Pr)/(1-delta))+(s-i1-Crr)*(1/2+(1/2)*(i1-i2)/tau)*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)+Ce*rho0*(((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)*eta+1-(Pn-Pr)/(1-delta))

(2)

diff(Pi1, i1) = 0

-(1/2+(1/2)*(i1-i2)/tau)*(1-(Pn-Pr)/(1-delta))+(1/2)*(w-i1)*(1-(Pn-Pr)/(1-delta))/tau-(1/2+(1/2)*(i1-i2)/tau)*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)+(1/2)*(s-i1-Crr)*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)/tau+(s-i1-Crr)*(1/2+(1/2)*(i1-i2)/tau)*beta*upsilon/delta+Ce*rho0*beta*upsilon*eta/delta = 0

(3)

solve(%, i1)

-(1/3)*(Crr*beta*delta*upsilon-beta*delta*i2*upsilon-beta*delta*s*upsilon+beta*delta*tau*upsilon-Crr*beta*upsilon+beta*i2*upsilon+beta*s*upsilon-beta*tau*upsilon-delta*Pr+delta^2-(6*Ce*beta^2*delta^2*eta*rho0*tau*upsilon^2-12*Ce*beta^2*delta*eta*rho0*tau*upsilon^2+6*Ce*beta^2*eta*rho0*tau*upsilon^2+Crr^2*beta^2*delta^2*upsilon^2+Crr*beta^2*delta^2*i2*upsilon^2-2*Crr*beta^2*delta^2*s*upsilon^2-Crr*beta^2*delta^2*tau*upsilon^2+beta^2*delta^2*i2^2*upsilon^2-beta^2*delta^2*i2*s*upsilon^2-2*beta^2*delta^2*i2*tau*upsilon^2+beta^2*delta^2*s^2*upsilon^2+beta^2*delta^2*s*tau*upsilon^2+beta^2*delta^2*tau^2*upsilon^2-2*Crr^2*beta^2*delta*upsilon^2-2*Crr*beta^2*delta*i2*upsilon^2+4*Crr*beta^2*delta*s*upsilon^2+2*Crr*beta^2*delta*tau*upsilon^2-2*beta^2*delta*i2^2*upsilon^2+2*beta^2*delta*i2*s*upsilon^2+4*beta^2*delta*i2*tau*upsilon^2-2*beta^2*delta*s^2*upsilon^2-2*beta^2*delta*s*tau*upsilon^2-2*beta^2*delta*tau^2*upsilon^2+Crr^2*beta^2*upsilon^2+3*Crr*Pn*beta*delta^2*upsilon-2*Crr*Pr*beta*delta^2*upsilon+Crr*beta^2*i2*upsilon^2-2*Crr*beta^2*s*upsilon^2-Crr*beta^2*tau*upsilon^2+2*Crr*beta*delta^3*upsilon-3*Pn*beta*delta^2*s*upsilon+3*Pn*beta*delta^2*upsilon*w-Pr*beta*delta^2*i2*upsilon+2*Pr*beta*delta^2*s*upsilon+Pr*beta*delta^2*tau*upsilon-3*Pr*beta*delta^2*upsilon*w+beta^2*i2^2*upsilon^2-beta^2*i2*s*upsilon^2-2*beta^2*i2*tau*upsilon^2+beta^2*s^2*upsilon^2+beta^2*s*tau*upsilon^2+beta^2*tau^2*upsilon^2+beta*delta^3*i2*upsilon-2*beta*delta^3*s*upsilon-beta*delta^3*tau*upsilon+3*beta*delta^3*upsilon*w-3*Crr*Pn*beta*delta*upsilon+Crr*Pr*beta*delta*upsilon-4*Crr*beta*delta^2*upsilon+3*Pn*beta*delta*s*upsilon-3*Pn*beta*delta*upsilon*w+2*Pr*beta*delta*i2*upsilon-Pr*beta*delta*s*upsilon-2*Pr*beta*delta*tau*upsilon+3*Pr*beta*delta*upsilon*w-2*beta*delta^2*i2*upsilon+4*beta*delta^2*s*upsilon+2*beta*delta^2*tau*upsilon-6*beta*delta^2*upsilon*w+Crr*Pr*beta*upsilon+2*Crr*beta*delta*upsilon+Pr^2*delta^2-Pr*beta*i2*upsilon-Pr*beta*s*upsilon+Pr*beta*tau*upsilon-2*Pr*delta^3+beta*delta*i2*upsilon-2*beta*delta*s*upsilon-beta*delta*tau*upsilon+3*beta*delta*upsilon*w+delta^4-2*Pr^2*delta+4*Pr*delta^2-2*delta^3+Pr^2-2*Pr*delta+delta^2)^(1/2)+Pr-delta)/(beta*upsilon*(-1+delta)), -(1/3)*(Crr*beta*delta*upsilon-beta*delta*i2*upsilon-beta*delta*s*upsilon+beta*delta*tau*upsilon-Crr*beta*upsilon+beta*i2*upsilon+beta*s*upsilon-beta*tau*upsilon-delta*Pr+delta^2+(6*Ce*beta^2*delta^2*eta*rho0*tau*upsilon^2-12*Ce*beta^2*delta*eta*rho0*tau*upsilon^2+6*Ce*beta^2*eta*rho0*tau*upsilon^2+Crr^2*beta^2*delta^2*upsilon^2+Crr*beta^2*delta^2*i2*upsilon^2-2*Crr*beta^2*delta^2*s*upsilon^2-Crr*beta^2*delta^2*tau*upsilon^2+beta^2*delta^2*i2^2*upsilon^2-beta^2*delta^2*i2*s*upsilon^2-2*beta^2*delta^2*i2*tau*upsilon^2+beta^2*delta^2*s^2*upsilon^2+beta^2*delta^2*s*tau*upsilon^2+beta^2*delta^2*tau^2*upsilon^2-2*Crr^2*beta^2*delta*upsilon^2-2*Crr*beta^2*delta*i2*upsilon^2+4*Crr*beta^2*delta*s*upsilon^2+2*Crr*beta^2*delta*tau*upsilon^2-2*beta^2*delta*i2^2*upsilon^2+2*beta^2*delta*i2*s*upsilon^2+4*beta^2*delta*i2*tau*upsilon^2-2*beta^2*delta*s^2*upsilon^2-2*beta^2*delta*s*tau*upsilon^2-2*beta^2*delta*tau^2*upsilon^2+Crr^2*beta^2*upsilon^2+3*Crr*Pn*beta*delta^2*upsilon-2*Crr*Pr*beta*delta^2*upsilon+Crr*beta^2*i2*upsilon^2-2*Crr*beta^2*s*upsilon^2-Crr*beta^2*tau*upsilon^2+2*Crr*beta*delta^3*upsilon-3*Pn*beta*delta^2*s*upsilon+3*Pn*beta*delta^2*upsilon*w-Pr*beta*delta^2*i2*upsilon+2*Pr*beta*delta^2*s*upsilon+Pr*beta*delta^2*tau*upsilon-3*Pr*beta*delta^2*upsilon*w+beta^2*i2^2*upsilon^2-beta^2*i2*s*upsilon^2-2*beta^2*i2*tau*upsilon^2+beta^2*s^2*upsilon^2+beta^2*s*tau*upsilon^2+beta^2*tau^2*upsilon^2+beta*delta^3*i2*upsilon-2*beta*delta^3*s*upsilon-beta*delta^3*tau*upsilon+3*beta*delta^3*upsilon*w-3*Crr*Pn*beta*delta*upsilon+Crr*Pr*beta*delta*upsilon-4*Crr*beta*delta^2*upsilon+3*Pn*beta*delta*s*upsilon-3*Pn*beta*delta*upsilon*w+2*Pr*beta*delta*i2*upsilon-Pr*beta*delta*s*upsilon-2*Pr*beta*delta*tau*upsilon+3*Pr*beta*delta*upsilon*w-2*beta*delta^2*i2*upsilon+4*beta*delta^2*s*upsilon+2*beta*delta^2*tau*upsilon-6*beta*delta^2*upsilon*w+Crr*Pr*beta*upsilon+2*Crr*beta*delta*upsilon+Pr^2*delta^2-Pr*beta*i2*upsilon-Pr*beta*s*upsilon+Pr*beta*tau*upsilon-2*Pr*delta^3+beta*delta*i2*upsilon-2*beta*delta*s*upsilon-beta*delta*tau*upsilon+3*beta*delta*upsilon*w+delta^4-2*Pr^2*delta+4*Pr*delta^2-2*delta^3+Pr^2-2*Pr*delta+delta^2)^(1/2)+Pr-delta)/(beta*upsilon*(-1+delta))

(4)

simplify(%)

Error, (in simplify/do) invalid simplification command

 
 

``

Download Q_Simplify.mw

any idea what match fail on this example? is somethinbg wrong I am doing?

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

A:=2*y(3)^4+5;
match(A=k1*y(k2)^k3+k4,y,'la')

2*y(3)^4+5

false

patmatch(A,k1::anything*y(k2::anything)^(k3::anything)+k4::anything,'la');
la

true

[k1 = 2, k2 = 3, k3 = 4, k4 = 5]

Download why_match_fail_sept_21_2025.mw

Update:
I think match can only do it if the main "variable"   is a variable and not a "function". In this example y(.) is function, so that is why it failed to match. For example this works:

A:=2*y^3+4;
match(A=k1*y^k2+k3,y,'la')

And gives true, since "y" here is not a "function".

But this makes match not very useful to use for parsing. patmatch seems a little more practical to use.

in this method i don't know in most of short equation i try to find the parameter but is just evaluating and nothing come up i don't know my way is wrong or write but i think i am right  but parameter not coming out, beside this in this equation give  me a warning regarding the parameters which say number of solution is more than 100 and dint show me that , how i can find the solution better than this?

f-p-.mw

I want to convert an XYZ file into a hydrogen-depleted heavy-atom molecule in Maple. Since XYZ has only coordinates, I’ll infer bonds by comparing inter-atomic distances to the sum of covalent radii ± tolerance, then remove hydrogens and output a heavy-atom molecule with only these bonds. What tolerances are sensible, and is there any built-in way in Maple to do this? Kind help with a maple code to do this.

Why is maple so useless? It can't even display a simple matrix equation without hours of user/forum intervention. I've never had this problem in the past. How does anyone get any work done? See example and compare with screenshot below.   why_is_maple_so_useless.mw

The left hand side contains the correct information but won't display it when evaluated. I even tried disabling matrix scrolling.

The default font size in the code edit region box of my worksheet is too small. I would like to change it without changing font sizes outside of the code edit region. I would be glad if I could do this within an individual worksheet, but it would be better if I could make this global in Maple 2025.

There doesn't seem to be any obvious way of doing this?

Hi,

I am looking for an idea to build a mixed and randomized series on unit conversions (volumes, surface, capacity, areas) in the form of two tables (2 columns & 8 rows). The first table would contain the questions, and the second one the solutions, so that students can use it for self-assessment. Do you have any ideas to suggest? Thanks!

I installed the latest 2025 recently and I encountered this issue. I never encountered this issue in 2024.

I also reset the configuration and reinstalled maple flow but it didn't solve anything.

I wanted to check that the input  has the pattern   symbol(symbol), which will match any of   y(x), or f(x) or A(B) and so on.

But using patmatch does not work. Using patmatch(h(z),y::symbol(x::symbol),'la');  or even patmatch(h(z),'y'::anything('x'::anything),'la'); all return false. I know I can do patmatch(h(z),func::function(name),'la'); and this returns true, but this matches h(z,r) and matches h(z,r,t) and matches h(z,r,t,u) and so on. 

I wanted to match only   SYMBOL(SYMBOL), i..e. one symbol followed by "(" followed by one symbol followed by closing ")"

For reference, this is what I am looking for 

I know I can use other ways in Maple to do this (may be typematch and and others). But wanted to see if patmatch works on this and why it is failing.

Can this be done using patmatch?

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