MaplePrimes Questions

I have a symbolic block matrix equation that I am trying to solve. Maple doesn't respect non-commutativity when solving.

I've tried to use 'Matrix' assumptions. I've also tried using the Physics package's Setup(noncommutativeprefix).

Both of these do not respect the order of multiplications (even using the dot operator for multiplication).

I've posted a minimal example below.

with(Physics)

Setup(noncommutativeprefix = {v, y})

[noncommutativeprefix = {v, y}]

(1)

NULL``

expr := y__xx.v__x = y__xu.y__uu.v__u

y__xx*v__x = y__xu*y__uu*v__u

(2)

soln := solve(expr, [v__u])

[[v__u = y__xx*v__x/(y__uu*y__xu)]]

(3)

op(rhs(soln[][]))

y__xx, v__x, 1/y__uu, 1/y__xu

(4)

NULL

Download noncommutative_example.mw

Does anyone know of a way to make this come out in a sensible fashion?
Thanks for the help!

Hello,

I would like to determine the level of nested lists within a list.

For example, given:

L := [[1, 2, 3], [], [[1, 2], [3, 4], [5, 6]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]];

I would like to compute:

nL := [1, 1, 2, 3];

That is, for each element in L, return the depth of nesting.

Additionally, I would like to write a procedure that takes L and returns a flattened version at the first non-empty list level:

L1 := [[1, 2, 3], [], [1, 2], [3, 4], [5, 6], [1, 2], [3, 4], [5, 6], [7, 8]];

Thank you in advance for your help!

Ed

hello:

Problem Background
   I am using Maple to perform a symbolic derivation for analyzing a coupled stripline directional coupler (as illustrated in the figure) The objective is to start from the known 4-port admittance matrix Y4 of a single coupled-line section(figure (a)) and derive the resulting 4-port admittance matrix Y_T for the composite structure shown in figure (b).

Diagram Explanation (Refer to Attached Figure)

  • Figure (a) represents a standard 4-port coupled-line segment, with admittance matrix Y4. The port ordering is labeled in green as (1,2,3,4).

  • Figure (b) shows a composite network constructed by combining two identical Y4 structures, where:

    • The right block are renumbered as red labels (5–8), which differ from the default Y4 port ordering.

      • The middle section includes two shorted node pairs that merge the internal connections:

        • Ports 2 and 6 are connected to form internal node A. so we get equtions:I2=-I6,V2=V6

        • Ports 4 and 8 are connected to form internal node B.so we get equtions:I4=-I8,V4=V8

Using a matrix-based linear algebra approach, I aim to compute the effective 4-port admittance matrix Y_T for the final structure shown in Figure (b), with the active ports being 1, 3, 5, and 7.

The even-mode and odd-mode responses are expressed symbolically. From these, the basic admittance elements are defined:

  • Y0, Ym1, Ym2, Ym3 using Yoe, Yoo, and θ.

Construct the 4×4 admittance matrix Y4 for the left-side coupled-line segment, using port ordering (1,2,3,4) as shown in Figure (a).

The Secondary (right-side) coupled-line block uses a different port order (Ports 5–6–7–8 correspond to the original 2–1–4–3).
Therefore, a permutation matrix P is introduced to reorder the ports as:

(1,2,3,4) → (2,1,4,3)
The reordered admittance matrix Y4_R is obtained via:

Y4_R := P . Y4 . Transpose(P)

Using BlockDiagonalMatrix or equivalent logic, we assemble the composite 8×8 admittance matrix Y8, representing:

[1 2 3 4 | 5 6 7 8]
The left half corresponds to Y4, and the right half to Y4_R.

According to the physical configuration:

  • Ports 2 and 6 are shorted to form Node A

  • Ports 4 and 8 are shorted to form Node B

We define a node-merging matrix S (6×8) to map the 8-port structure into a reduced 6-port structure using:

[1, 3, 7, 5, A(=2+6), B(=4+8)]
Apply the transformation:

Y6 := S . Y8 . Transpose(S)

From the reduced matrix Y6, extract:

  • External port indices: E = [1, 2, 3, 4] → Ports 1, 3, 7, 5

  • Internal node indices: I = [5, 6] → Nodes A, B

Perform Kron reduction to eliminate internal nodes and obtain the final reduced matrix:

Y_T := Y_EE - Y_EI . Inverse(Y_II) . Y_IE

When I try to execute:

Y8 := BlockDiagonalMatrix([Y4, Y4_R])
Maple does not return a usable or well-formed 8×8 matrix

 

  1. How to correctly construct the block-diagonal matrix Y8 := BlockDiagonalMatrix([Y4, Y4_R]) so that it's recognized as an 8×8 matrix in Maple?

  2. Validate whether the full logic flow from Y4 → port mapping → block matrix → merging → Kron reduction is mathematically sound and correctly implemented, and get the final 4 port Y parameter matrix.

  3. If possible, please suggest any more stable or simplified alternative matrix operations for symbolic Kron reduction involving port reordering and node merging.

here is the maple file:

Download CoupleLine_WH2.mw

thank in advance for your help.

Hello everyone,
When I try to calculate the derivative of (cx)/(1+x) in Maple, I get -cx/(1 + x)^2 as the result:

diff(cx/(1 + x), x)
When I do the calculation manually (see attached image), I get c/(1+x)^2 as the result.

Did I use the wrong command in Maple, or how can I explain the different result?

Thanks for your support,
Jan


How i can fix this issue ?
 

Download pdetest.mw

Is it possible to use the optimize option of CodeGeneration (or codegen) on a matrix/vector and get output for a matrix M like:
M[1,1]:=a*b*c*(d+e):

M[1,2]:=a*b*c-(d+e):

etc

output:
t1 = a*b*c
t2 = d+e
M(1,1) = t1*t2
M(1,2) = t1-t2
etc

Thank you.

I am trying to check if a matrix quailfies as being skew-symmetric. So I added it to it's transpose to get a matrix of zeroes. 

How do I check it  equals the ZeroMatrix?

restart

NULL

M := Matrix(3, 3, {(1, 1) = 0, (1, 2) = (40*sqrt(7)+140)/(560+sqrt(7)), (1, 3) = (80*sqrt(7)+35)/(560+sqrt(7)), (2, 1) = (-40*sqrt(7)-140)/(560+sqrt(7)), (2, 2) = 0, (2, 3) = (280-32*sqrt(7))/(560+sqrt(7)), (3, 1) = (-80*sqrt(7)-35)/(560+sqrt(7)), (3, 2) = (-280+32*sqrt(7))/(560+sqrt(7)), (3, 3) = 0})

Matrix(%id = 36893490078408578100)

(1)

mtest := simplify(M+M^%T)

Matrix(%id = 36893490078408571348)

(2)

LinearAlgebra:-ZeroMatrix(3)

Matrix(%id = 36893490078408566412)

(3)

is(mtest = LinearAlgebra:-ZeroMatrix(3))

false

(4)

NULL

Download 2025-05-30_is_Matrix_skew-symmetric.mw

Hello

I would like to write a process f(p,n) that returns the number of partions of a positive integer n into p parts. possible parts are only 0,1,4,6,8,9. these parts cn be used several times. the order is not important.

example

f(3,8)=3 because (0,0,8), (0,4,4), (1,1,6).

thanks for your help!

For some reason, I get dozens of ode's that fail to odetest when using method='laplace' with dsolve.

Yet, all the solutions are correct. These are from textbooks.

I tried giving odetest assumptions but nothing worked so far. So I am thinking of just ignoring result of odetest when laplace method is used and to assume it is correct each time. Otherwise, I will get false negative all the time on these.

Thought to ask if someone knows why this happens and if there is some universal trick to use when calling odetest on such solutions.

Here is worksheet with few examples where odetest do not verify the solutions (even though they are "correct", when solving these ode's by hand). 

May be if odetest was told that the solution was generated using method='laplace' it will help it, but there is no such option (as in the case with 'series' option). 

Btw, if method='laplace' is not used on these examples, then odetest have no problem verifying the solutions and gives zero on all of them.

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1873 and is the same as the version installed in this computer, created 2025, May 18, 21:44 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 21 and is the same as the version installed in this computer, created May 28, 2025, 23:36 hours Eastern Time.`

restart;

ode:=diff(x(t),t$2)+4*diff(x(t),t)+13*x(t) = f(t):
ic:=x(0) = 0, D(x)(0) = 0:
sol:=dsolve([ode,ic],x(t),method='laplace');
odetest(sol,[ode,ic]);

x(t) = (1/3)*(int(f(_U1)*exp(-2*t+2*_U1)*sin(3*t-3*_U1), _U1 = 0 .. t))

[-(1/6)*(-(26*I)*(Int(f(_U1)*sinh(-(3*I)*t+(3*I)*_U1)*exp(2*_U1+(3*I)*t), _U1 = 0 .. t))-(13*I)*exp((6*I)*t)*(Int(exp((2-3*I)*_U1)*f(_U1), _U1 = 0 .. t))+(13*I)*(Int(exp((2-3*I)*_U1)*f(_U1)*exp((6*I)*_U1), _U1 = 0 .. t)))*exp((-2-3*I)*t), 0, 0]

ode:=diff(diff(x(t),t),t)+4*x(t) = Dirac(t)+Dirac(t-Pi):
ic:=x(0) = 0, D(x)(0) = 0:
sol:=dsolve([ode,ic],x(t),method='laplace');

odetest(sol,[ode,ic]);

x(t) = (1/2)*sin(2*t)*(1+Heaviside(t-Pi))

[-Dirac(t), 0, -1]

ode:=diff(diff(x(t),t),t)+4*x(t) = Dirac(t):
ic:=x(0) = 0, D(x)(0) = 0:
sol:=dsolve([ode,ic],x(t),method='laplace'):
odetest(sol,[ode,ic]);

[-Dirac(t), 0, -1]

ode:=diff(diff(x(t),t),t)+4*diff(x(t),t)+8*x(t) = f(t):
ic:=x(0) = 0, D(x)(0) = 0:
sol:=dsolve([ode,ic],x(t),method='laplace'):
odetest(sol,[ode,ic]);

[-2*(-(2*I)*(Int(f(_U1)*sinh((2*I)*_U1-(2*I)*t)*exp(2*_U1+(2*I)*t), _U1 = 0 .. t))+2*(Int(f(_U1)*cosh((2*I)*_U1-(2*I)*t)*exp(2*_U1+(2*I)*t), _U1 = 0 .. t))+I*(Int(exp((2-2*I)*_U1)*exp((4*I)*_U1)*f(_U1), _U1 = 0 .. t))-I*exp((4*I)*t)*(Int(exp((2-2*I)*_U1)*f(_U1), _U1 = 0 .. t))-(Int(exp((2-2*I)*_U1)*exp((4*I)*_U1)*f(_U1), _U1 = 0 .. t))-exp((4*I)*t)*(Int(exp((2-2*I)*_U1)*f(_U1), _U1 = 0 .. t)))*exp((-2-2*I)*t), 0, 0]

 


 

Download how_to_odetest_laplace_solution_may_29_2025.mw

 

I used Maple’s odetest to check the validity of 36 exact solutions.

About half of them return zero, meaning they satisfy the ODE correctly. But the other half don’t — odetest gives nonzero expressions.

My question is:

Could there be a mistake in my assumptions, or are some of these solutions only valid under specific conditions?

I’d appreciate any clarification or suggestions.

ode-test-36.mw

Respected sir,

I sincerly apologize to take your valuable time.

kind help with construction of function for the question in the word file attached.

Kind help please it may be simple too.

Kind_help.pdf

Hello!

I use Maple to calculate a variety of physiology questions. But i keeps using the standardized SI unites and not the ones i plug in. Is there a way to get maple to behave differently? Ive added a screenshot of an example. It comes out in m3/s when i just want it in ml/min. 

GFR = (18.2*Unit(('mg')/('ml')))*1.5*Unit(('ml')/('min'))/(0.201*Unit(('mg')/('ml')));
 = 
                                            / 3\
                                            |m |
                GFR = 0.000002263681592 Unit|--|
                                            \s /

With the update of Maple 2025, I'm finding that every time I open a saved Maple worksheet (from say my desktop or File Explorer), Maple creates a new window rather than opening the worksheet in a previously opened window (as previous versions of Maple have done). 

Is there a way to prevent this? For context, I'm running Windows 11. 

I've been debugging this for 20 hrs and finally able to make an example.

I noticed that solve() suddenly no longer works and times out.

First time calling solve() works. Second time it I see message

               Warning, solve may be ignoring assumptions on the input variables.

And it hangs.  Same exact code.   It has to do with calling odetest before and using Physics:-Setup('assumingusesAssume' = false):

i.e. this works
  
     odetest(...) assuming integer
     solve(....) #no hang
     odetest(....) assuming positive

     odetest(...)  assuming integer
     solve(....)  #no hang


But this does not work

     odetest(...) assuming integer
     solve(....) #no hang
     Physics:-Setup('assumingusesAssume' = false):
     odetest(....) assuming positive
     Physics:-Setup('assumingusesAssume' = true):

     odetest(...) assuming integer
     solve(...)   #HANGS
     

Here is worksheet showing the problem. If I remove first call to odetest, solve do not hang.

Also removing Physics:-Setup('assumingusesAssume' = false):, solve also works OK. (ie. does not hang)

So it has to do with some internal caching which causes solve to stop working.

Can others reproduce this and can cause it and how to fix it so solve do not hang second time?

The input used below is not important. It is just what I found to cause this. One would expect solve() to work same way for same input all the time.

Also, same problem happens when using PDEtools:-Solve instead of solve. It hangs second time.

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1873 and is the same as the version installed in this computer, created 2025, May 18, 21:44 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 20 and is the same as the version installed in this computer, created May 23, 2025, 23:34 hours Eastern Time.`

restart

DEFINE input

 

ode:=y(x)*sqrt(1 + diff(y(x), x)^2) - a*y(x)*diff(y(x), x) - a*x = 0:
sol:=-_C4^2 + (-y(x)*sqrt(_C4^2/y(x)^2) + a*x)^2/a^2 + y(x)^2 = 0:
ode_to_test:=y(x)*(1+diff(y(x),x)^2)^(1/2)-a*y(x)*diff(y(x),x)-a*x = 0:

FIRST TIME solve works

 

    try
        timelimit(30,(odetest(sol,ode,y(x)) assuming integer));
    catch:
        NULL;
    end try:

    try
        timelimit(30,[solve(ode_to_test,diff(y(x),x))]);
        print("SOLVE worked");              
    catch:
        print("WHY TIMED OUT??");              
    end try:

    Physics:-Setup('assumingusesAssume' = false):
    try
        timelimit(30, (odetest(sol,ode,y(x)) assuming positive) );
    catch:
        NULL;
    end try:
    Physics:-Setup('assumingusesAssume' = true):

"SOLVE worked"

 

 

RUN SAME CODE AS ABOVE again, now it does not work

 

    try
        timelimit(30,(odetest(sol,ode,y(x)) assuming integer));
    catch:
        NULL;
    end try:

    try
        timelimit(30,[solve(ode_to_test,diff(y(x),x))]);
        print("SOLVE worked");              
    catch:
        print("WHY TIMED OUT??");              
    end try:

    Physics:-Setup('assumingusesAssume' = false):
    try
        timelimit(30, (odetest(sol,ode,y(x)) assuming positive) );
    catch:
        NULL;
    end try:
    Physics:-Setup('assumingusesAssume' = true):

Warning, solve may be ignoring assumptions on the input variables.

"WHY TIMED OUT??"

 

 

 

 

Download why_solve_stops_working_maple_2025_may_28_2025.mw

This worksheet below shows that by removing Physics:-Setup('assumingusesAssume' = false): now solve works OK second time. (I turn on/off Physics:-Setup('assumingusesAssume' since I found sometimes it can help with odetest to turn it off in some other cases. But now I am scared of touching this setting as it seems to have side effects internally)

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1873 and is the same as the version installed in this computer, created 2025, May 18, 21:44 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 20 and is the same as the version installed in this computer, created May 23, 2025, 23:34 hours Eastern Time.`

restart

DEFINE input

 

ode:=y(x)*sqrt(1 + diff(y(x), x)^2) - a*y(x)*diff(y(x), x) - a*x = 0:
sol:=-_C4^2 + (-y(x)*sqrt(_C4^2/y(x)^2) + a*x)^2/a^2 + y(x)^2 = 0:
ode_to_test:=y(x)*(1+diff(y(x),x)^2)^(1/2)-a*y(x)*diff(y(x),x)-a*x = 0:

FIRST TIME solve works

 

    try
        timelimit(30,(odetest(sol,ode,y(x)) assuming integer));
    catch:
        NULL;
    end try:

    try
        timelimit(30,[solve(ode_to_test,diff(y(x),x))]);
        print("SOLVE worked");              
    catch:
        print("WHY TIMED OUT??");              
    end try:

    try
        timelimit(30, (odetest(sol,ode,y(x)) assuming positive) );
    catch:
        NULL;
    end try:

"SOLVE worked"

 

 

RUN SAME CODE AS ABOVE again, now it does not work

 

    try
        timelimit(30,(odetest(sol,ode,y(x)) assuming integer));
    catch:
        NULL;
    end try:

    try
        timelimit(30,[solve(ode_to_test,diff(y(x),x))]);
        print("SOLVE worked");              
    catch:
        print("WHY TIMED OUT??");              
    end try:

    try
        timelimit(30, (odetest(sol,ode,y(x)) assuming positive) );
    catch:
        NULL;
    end try:

"SOLVE worked"

 

 

 

 

Download why_solve_stops_working_maple_2025_may_28_2025_V2.mw

2 3 4 5 6 7 8 Last Page 4 of 2420