MaplePrimes Questions

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

I'm looking for a flatten procedure for matrices (without first having to convert the matrix to a list, flatten it, and finally convert it back).
In this example, I am trying to generalize the matrix R to higher dimensions (here a 3 by 3 matrix, denoted as A, is used). I'm using a function, denoted as g, to construct a matrix. Obviously, the function applies to each cell and therefore, each cell contains a matrix in the resulting matrix. A flatten command would solve the problem. As a work-around I reconstruct the matrix In this example, but that is hard to generalize to more dimensions (or not?)

restart; kernelopts(version); interface(version); with(LinearAlgebra); with(combinat); interface(rtablesize = 16)

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

 

`Standard Worksheet Interface, Maple 2024.2, Windows 11, October 29 2024 Build ID 1872373`

 

[10, 10]

(1)

Antidiagonal := proc (n) local Q, r, c; Q := Matrix(n, n); seq(seq(`if`(r+c = RowDimension(Q)+1, assign('Q[r, c]', 1), assign('Q[r, c]', 0)), r = 1 .. RowDimension(Q)), c = 1 .. ColumnDimension(Q)); return Q end proc

A := Matrix(3, 3, symbol = a)

R := `<,>`(`<|>`(Adjoint(A([2, 3], [2, 3])), -Adjoint(A([1, 3], [2, 3])), Adjoint(A([1, 2], [2, 3]))), `<|>`(-Adjoint(A([2, 3], [1, 3])), Adjoint(A([1, 3], [1, 3])), -Adjoint(A([1, 2], [1, 3]))), `<|>`(Adjoint(A([2, 3], [1, 2])), -Adjoint(A([1, 3], [1, 2])), Adjoint(A([1, 2], [1, 2]))))

Matrix(%id = 36893490582445267772)

(2)

U := choose(3, 2)

[[1, 2], [1, 3], [2, 3]]

(3)

g := proc (r, c) options operator, arrow; Adjoint((eval*A^%T)(U[c], U[r])) end proc

proc (r, c) options operator, arrow; LinearAlgebra:-Adjoint((eval(A^%T))(U[c], U[r])) end proc

(4)

Q := Matrix(3, g)

Matrix(%id = 36893490582395297788)

(5)

Q := Antidiagonal(3).Q.Antidiagonal(3)

Matrix(%id = 36893490582401641396)

(6)

U := `<,>`(`<|>`(Q[1, 1], Q[1, 2], Q[1, 3]), `<|>`(Q[2, 1], Q[2, 2], Q[2, 3]), `<|>`(Q[3, 1], Q[3, 2], Q[3, 3]))

Matrix(%id = 36893490582412939004)

(7)

R-Matrix(6, 6, [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, -1, 0, 0, 0], [0, 0, 0, -1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]).U^%T.Matrix(6, 6, [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, -1, 0, 0, 0], [0, 0, 0, -1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]])

Matrix(%id = 36893490582417081876)

(8)


Download Flatten_a_matrix.mw

Hi everyone, I have an old worksheet created back with Version 5 and I recently open it using the latest version of Maple and I am aware of the many upgrades since then but I can't get my program to work in the new application. Can anyone help me out? I put an extract of the code which I hope will work for everyone suggestion. 

restart:with(tensor):
coord := [t, r, p, q]:
g_compts := array(symmetric,sparse, 1..4, 1..4): g_compts[1,1] := -1: g_compts[1,2]:= 0:
g_compts[1,3]:= 0: g_compts[1,4]:= 0: g_compts[2,2]:= H(t,r,p,q)^2:
g_compts[2,3]:= 0:
g_compts[2,4]:= 0:
g_compts[3,4]:= 0:
g_compts[3,3] := F(t,r,p,q)^2: g_compts[4,4] := F(t,r,p,q)^2: g := create( [-1,-1], eval(g_compts));

ginv := invert( g, 'detg' ):
D1g:=d1metric( g, coord ): D2g:=d2metric( D1g, coord ):
Cf1 := Christoffel1 ( D1g ):
Cf2 := raise(ginv,Cf1,3): RMN := Riemann( ginv, D2g, Cf1 ):
RICCI := Ricci( ginv, RMN ):
RS := Ricciscalar( ginv, RICCI ): WEYL := Weyl( g, RMN, RICCI, RS):
Estn := Einstein( g, RICCI, RS ): Eup := raise(ginv,Estn,1): Ein:= get_compts(Eup): simplify(Ein[1,1]);

displayGR('Weyl', WEYL);

Hello,

I'm using CodeGeneration:-C in Maple to translate the coefficients of a dynamical model into C++ code. However, I'm running into an issue when trying to assign the output in a way that matches the format of the coef vector used in the main C++ file (which is set up to simulate any 3D quadratic model).

For context, ans is a Maple vector containing all 30 coefficients.
Taking ans[12] as an example:

ans := [0, -sigma, xi[1, 2], xi[1, 3], 0, 0, 0, 0, 0, 0, 0, -sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*rho*sigma/(2*xi[1, 2]) + sigma*rho/(2*xi[1, 2]), -sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*beta/2 + sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)/2 - beta/2 - 1/2, -sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*beta*xi[1, 3]/(2*xi[1, 2]) + sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*xi[1, 3]/(2*xi[1, 2]) + beta*xi[1, 3]/(2*xi[1, 2]) - xi[1, 3]/(2*xi[1, 2]), 0, xi[2, 5], -sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)/(2*xi[1, 2]^2) + xi[1, 3]*xi[2, 5]/xi[1, 2] + 1/(2*xi[1, 2]^2), 0, 0, 0, 0, sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*rho*sigma/(2*xi[1, 3]) + sigma*rho/(2*xi[1, 3]), sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*beta*xi[1, 2]/(2*xi[1, 3]) - sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*xi[1, 2]/(2*xi[1, 3]) + beta*xi[1, 2]/(2*xi[1, 3]) - xi[1, 2]/(2*xi[1, 3]), sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)*beta/2 - sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)/2 - beta/2 - 1/2, 0, -xi[1, 2]*xi[2, 5]/xi[1, 3] - sqrt(-4*xi[1, 3]^2*xi[1, 2]^2 + 4*xi[1, 2]*xi[1, 3]*xi[2, 5] + 1)/(2*xi[1, 3]^2) - 1/(2*xi[1, 3]^2), -xi[2, 5], 0, 0, 0]

When I run the command:

CodeGeneration:-C(ans[12],resultname="coef21");

the output is:

coef21 = -0.1e1 / (double) xi[0][1] * sqrt((double) (-4 * xi[0][2] * xi[0][2] * xi[0][1] * xi[0][1] + 4 * xi[0][1] * xi[0][2] * xi[1][4] + 1)) * rho * sigma / 0.2e1 + 0.1e1 / (double) xi[0][1] * sigma * rho / 0.2e1;

This is syntactically fine, but what I actually need is an assignment to coef[21] instead of coef21, to be consistent with the structure in my C++ code.

To clarify, the resultname must reflect an offset: ans[12] should become coef[12 + 9], ans[1] becomes coef[1 + 9], and so on. I realize this isn’t ideal, but the current C++ code has been working reliably for years, and adapting it would require unnecessary refactoring.

Do you have any suggestions on how to direct CodeGeneration:-C to generate the assignment with coef[21] as the left-hand side?

Many thanks in advance!

Ed

P.S. Using CodeGeneration:-C(ans[i], resultname = sprintf("coef%d", i + 9)) displays the coefficients on the screen as needed, but they still require some additional editing.

Hi everyone,

I've encountered something odd while working with Maple's pdetest function. When I manually evaluate my proposed solution using eval() followed by simplify(), I get the expected identity 0 = 0, which suggests the solution satisfies the PDE. However, when I test the same solution using pdetest, it doesn't return zero. This inconsistency has left me unsure whether my solution is actually valid or if I'm missing something.

Has anyone else experienced this kind of discrepancy? Could this be due to how pdetest handles derivatives or symbolic simplification internally?

Any insights or suggestions would be greatly appreciated!

Download pde-test.mw

Hi,

I try to creat an activity on Statistics, and I'm stuck on the bar chart, ( in the last part of my worksheet) with xi on the x-axis (Ox) and ni on the y-axis (Oy). I'm using the BarChart command, but it's not giving the expected result.

Ideas?

S4_Statistiques_Descriptives_AxeTravail_Complet.mw

restart;

with(Physics);
with(Vectors);

Given

Ket(i) = alpha*Ket(u) + beta*Ket(d);
Ket(o) = gamma*Ket(u) + delta*Ket(d);
and using

<o|u><u|o> =1/(2)
<o|d><d|o> =1/(2)

 <i|d><d|i> =1/(2);
 <i|u><i|o> =1/(2);

Prove that
                     "alpha^*alpha = 1/2"

and the same for the rest of the unknowns

If you could help me start using them because later I will have a lot to check.

Thank you in advance for your help.

Mario

3 4 5 6 7 8 9 Last Page 5 of 2421