MaplePrimes Questions

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, 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], 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

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

I'm optimizing a function with constraints, meaning the decision variable has both a lower and an upper bound. When I use the  (MAX) syntax in Maple, it returns the lower bound as the optimal value (Pc) along with the corresponding function value. However, when I plot the graph, it shows that the function actually reaches its maximum at the upper bound. What could be causing this discrepancy

Sheet:Q_result_1.mw

Should solution to a first order ode with IC not have any constant of integration in it? This is what the teacher said at school.

But Maple in this example returns a solution to first order Riccati ode with c1 still in the solution even though it is given IC.

How is this possible? This is problem from Differential equations and their applications, 3rd ed., M. Braun, Section 1.10. Page 80, problem #5

If dsolve was not able to resolve c1 from IC for some reason, should it not have returned any solution in this case? 

btw, I could not verify the solution on the ode itself using odetest, but may be assumptions are needed. Will try and see...

restart;

interface(version);

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

SupportTools:-Version();

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

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.`

restart;

libname;

"/home/me/maple/toolbox/2025/Physics Updates/lib", "/home/me/maple/toolbox/2025/Maple Customer Support Updates/lib", "/home/me/maple2025/lib"

ode:=diff(y(x),x)=1+y(x)+y(x)^2*cos(x);
IC:=y(0)=0;
maple_sol:=dsolve([ode,IC]);

diff(y(x), x) = 1+y(x)+y(x)^2*cos(x)

y(0) = 0

y(x) = -(1/2)*csgn(sin((1/2)*x))*(MathieuS(-1, -2, arccos(cos((1/2)*x)))*csgn(sin((1/2)*x))*c__1+4*MathieuS(-1, -2, arccos(cos((1/2)*x)))*cos(x)*c__1-MathieuSPrime(-1, -2, arccos(cos((1/2)*x)))*csgn(sin((1/2)*x))*c__1-c__1*MathieuS(-1, -2, arccos(cos((1/2)*x)))+c__1*MathieuSPrime(-1, -2, arccos(cos((1/2)*x)))-MathieuCPrime(-1, -2, arccos(cos((1/2)*x)))*csgn(sin((1/2)*x))+MathieuC(-1, -2, arccos(cos((1/2)*x)))*csgn(sin((1/2)*x))+4*MathieuC(-1, -2, arccos(cos((1/2)*x)))*cos(x)+MathieuCPrime(-1, -2, arccos(cos((1/2)*x)))-MathieuC(-1, -2, arccos(cos((1/2)*x))))/((c__1*MathieuS(-1, -2, arccos(cos((1/2)*x)))-c__1*MathieuSPrime(-1, -2, arccos(cos((1/2)*x)))-MathieuCPrime(-1, -2, arccos(cos((1/2)*x)))+MathieuC(-1, -2, arccos(cos((1/2)*x))))*cos(x))

lprint(maple_sol);

y(x) = -1/2*csgn(sin(1/2*x))/(c__1*MathieuS(-1,-2,arccos(cos(1/2*x)))-c__1*
MathieuSPrime(-1,-2,arccos(cos(1/2*x)))-MathieuCPrime(-1,-2,arccos(cos(1/2*x)))
+MathieuC(-1,-2,arccos(cos(1/2*x))))*(MathieuS(-1,-2,arccos(cos(1/2*x)))*csgn(
sin(1/2*x))*c__1+4*MathieuS(-1,-2,arccos(cos(1/2*x)))*cos(x)*c__1-MathieuSPrime
(-1,-2,arccos(cos(1/2*x)))*csgn(sin(1/2*x))*c__1-c__1*MathieuS(-1,-2,arccos(cos
(1/2*x)))+c__1*MathieuSPrime(-1,-2,arccos(cos(1/2*x)))-MathieuCPrime(-1,-2,
arccos(cos(1/2*x)))*csgn(sin(1/2*x))+MathieuC(-1,-2,arccos(cos(1/2*x)))*csgn(
sin(1/2*x))+4*MathieuC(-1,-2,arccos(cos(1/2*x)))*cos(x)+MathieuCPrime(-1,-2,
arccos(cos(1/2*x)))-MathieuC(-1,-2,arccos(cos(1/2*x))))/cos(x)

 

 

Download why_c_in_solution_may_23_2025.mw

Update

Looked up the textbook, it says solution exist and unique over 0<=x<=1/3, using these now Maple verifies the ode itself, but does not verify the IC (because c__1 is there). Here is updated worksheet. The bottom line, I think the solution is wrong as it should not have any constant of integration in it. Textbook also does say what the solution should be.

restart;

interface(version);

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

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 20. The version installed in this computer is 19 created May 21, 2025, 13:44 hours Eastern Time, found in the directory /home/me/maple/toolbox/2025/Maple Customer Support Updates/lib/Maple`

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.`

restart;

libname;

"/home/me/maple/toolbox/2025/Physics Updates/lib", "/home/me/maple/toolbox/2025/Maple Customer Support Updates/lib", "/home/me/maple2025/lib"

ode:=diff(y(x),x)=1+y(x)+y(x)^2*cos(x);
IC:=y(0)=0;
maple_sol:=dsolve([ode,IC]):
simplify(maple_sol) assuming x>=0 and x<=1/3;

diff(y(x), x) = 1+y(x)+y(x)^2*cos(x)

y(0) = 0

y(x) = (2*c__1*MathieuS(-1, -2, (1/2)*x)+2*MathieuC(-1, -2, (1/2)*x))/(c__1*MathieuSPrime(-1, -2, (1/2)*x)-c__1*MathieuS(-1, -2, (1/2)*x)+MathieuCPrime(-1, -2, (1/2)*x)-MathieuC(-1, -2, (1/2)*x))

odetest(%,[ode,IC]);

[0, -2/(c__1-1)]

 

 

Download why_c_in_solution_may_23_2025_v2.mw

Suppose we have two equations, and all parameters involved are assumed to be positive. Is there a systematic way or syntax to determine whether C1>C2​ or vice versa? Additionally, can we derive specific conditions under which C1>C2​ holds

Sheet: Q_greater.mw

I have just started to use Maple workbook (*.maple). In the workbook, there are 4 worksheets: "main.mw","calc1.mw","calc2.mw","calc3.mw". In "main.mw", I plot variables saved from "calc?.mw". This works. However, when I make changes in one of the worksheet "calc?.mw" and get the new expressions for the variables, they are not updated in "main.mw". I deleted the variables being changed but "main.mw" still run and show the old expressions of these variables.

How do I refresh so that "main.mw" will show the updated variables from "calc?.mw"?

Thanks.

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