Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

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.

In Optical-Illusion--Impossible-Prisms, mcarvalho provides a Maple Learn worksheet to illustrate an intriguing optical illusion.  Here I do that illustration in Maple, and in 3D! 

The graphics below shows 4 bars.  Or is it 3 bars?

Download the worksheet, stare at the graphics for short while to grasp the nature of the optical illusion, and then rotate the 3D graph with the mouse and see the illusion fall apart.

optical-illusion.mw

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

Geometrical entertainment in the form of rolling without slipping, now inside a torus.
You can also print out the corresponding equations - these graphs are # in the text, but it is better to do this separately from the geometric animation, because textplot3d takes up a lot of resources.

Please consider it not as a Maple program, but simply as an idea for a corresponding algorithm.
for_TORUS_IN_TORUS_for.mw
 

Should maple have given solution to x as zero in the following?

solve(x^n=0,x)

What if n is zero? what if n is negative?  

Another program I tried this on gives

Maple 2025

Hello,

I am working with the following overdetermined system of nonlinear equations in Maple and attempting to solve it for the unknowns xi[3] and xi[8].

 [sqrt(beta*rho*xi[8]^2 - beta*xi[8]^2)/xi[8] = sqrt(beta*rho - beta), (-rho + 1 + sqrt(beta*rho*xi[8]^2 - beta*xi[8]^2))/(xi[3]*xi[8] - 1) = sqrt(beta*rho - beta), -(-rho*xi[3]*xi[8] + sqrt(beta*rho*xi[8]^2 - beta*xi[8]^2) + xi[3]*xi[8])/(xi[8]*(xi[3]*xi[8] - 1)) = rho - 1]

Maple returns the following solution:

{xi[3] = (-rho + sqrt(beta*(rho - 1)) + 1)/sqrt(beta*(rho - 1)), xi[8] = -(-rho + sqrt(beta*(rho - 1)) + 1)/(rho - 1)}

However, when I substitute the solution back into the original equations, the left-hand side should equal the right-hand side. Yet, using simplify(subs(solution, equation)) does not reduce the expression sufficiently to verify the equality.

Am I missing something in the simplification process?

Many thanks,

Ed

We can say, a test example. Probably a continuation of this topic.
An equation with one variable X, and let 0<X. To try to find such a largest value of X, in the neighborhood of which not a single solution will be missed in the amount of at least 50 solutions in a row. And in this case, the residual value of the equation discrepancy will be no more than 10^-7 .

f :=0.995-cos(0.25*x)*sin(x^3);

Purely for fun, of course.

I am working on a script (attached sheet) where I use a FOR loop to iterate over different values of varepsilon. Within each iteration, I perform the following steps:

  1. I optimize the function R_out and obtain a result, denoted as Pc

  2. I then substitute Pc into another function, L_out and optimize it to find the values of p1,p2, and the corresponding function value.

I follow a similar procedure for a second case as well.

However, I'm encountering an issue: I'm unable to successfully substitute the result from R_out into L_out within the loop. This is causing an error in execution.

Finally, I intend to generate a plot with varepsilon  on the x-axis and certain result variables on the y-axis in a single plot (as indicated at the end of the sheet).

Sheet: Question_New.mw

Can someone help me:

  1. Fix the substitution error in the loop, and

  2. Provide the correct syntax for generating the desired plot?

Hello,

i try to create a quiz. Is it possible to set a comlex math expression like the first expression in my document for a choice? In the Helppage I did not see the oppertunity to use an Integral expression for example. Or is it posssible to use 2D Math Input for the choices ? 

int(diff(u, t), s = A .. E)+(1/2)*u__E^2"+(&int;)[A]^(E)(1)/(`&varrho;`)(&DifferentialD;)/(&DifferentialD; s)p &DifferentialD;s+`&varphi;__E`=(1)/(2)(`u__A`)^(2)+`&varphi;__A`;"

Error, (in int) wrong number (or type) of arguments: invalid options or option values passed to definite integration.

 

Error, (in int) wrong number (or type) of arguments: invalid options or option values passed to definite integration.

 

with(Grading)

A := Array()

A(1) := Grading:-Quiz("Welche der folgenden Varianten der Bernoullischen Gleichung sind korrekt?", 3, ["A", "B", "C"], 'style' = multiplechoice, 'output' = `module`)

Grading:-Quiz(A, numberformat = lowercaseroman, numberprefix = "Frage 1.", border = true)

 

``

Download 1.mw

4 5 6 7 8 9 10 Last Page 6 of 2212