Maple Questions and Posts

These are Posts and Questions associated with the product, Maple


Although the worksheets provided here have been developed under Maple 2015, they should work correctly with newer versions, except perhaps for commands that use the 'op' function ('piecewise' mainly).

In the sequel the acronym 'pdf' stands for 'probability density function'.



CONTEXT

This post originates from a recent question by @JoyDivisionMan and the ensuing discussion. 

In a few words, the OP noticed Maple 2025 failed to return a result and asked why. In his reply, @acer identified a code regression somewhere in between Maple 2023 and Maple 2025.
Indeed Maple 2023 (which I do not have) provided an answer, just so "my" Maple 2015 did... but thee problem was that Maple 2015's answer was wrong (What is worse? Admit one cannot find an answer or provide a wrong answer?)
.

 

In this post I explain how we can calculate the result by hand (only elementary maths required), why Maple 2015 (and likely newer versions) returns an incorrect result, why Maple generally fails in returning a result, and finally provide several examples to illustrate that even mathematically simple, the construction of the pdf often requires human intervention (unless a sophisticated AI-driven algorithm is used... at lest in my opinion).

To be clearer, let
X some continuous univariate random variable (CURV) and 𝟇 a real valued function from to (in the most general sense). Let Y the random variable defined by Y =  𝟇(X).

Here is the main claim: unless very specific situations, you must consider that Maple cannot correctly build the pdf of 
𝟇(X) if 𝟇 is not a monotone function (and even sometimes a strictly monotone function).

A few noticeable exceptions are

X any CURV𝟇 : xx2  (correct solution even if 𝟇 is not monotone)

X ~ Uniform(-1, 1)𝟇 : xarctanh(x)  (no result returned even if 𝟇 is strictly monotone).


In @JoyDivisionMan's original question it is only by chance that Maple provided the correct result for the non monotone function 𝟇 = cosine ... but it failed for sine function, which motivated the question.




A GOOD DRAWING WORTH A THOUSAND WORDS

Here is a picture to help understand how to get the pdf of Y =  𝟇(X) for a non monotone function 𝟇 (the case of a monotone function directly comes from this latter).

In this illustration 
X ~ Uniform(0, 2𝜋)𝟇 : xsine(x).
To ease the explanation, I write 
X as a mixture of three uniform random variables X1, X2, X3, whose supports are the intervals of the three branches of 𝟇. More formally, X  = (1/4)∙X1 + (1/2)∙X2 + (1/4)∙X3.
The restrictions  of
𝟇 to these three branches are denoted 𝟇1, 𝟇2, 𝟇3.



The large rectangles below the horizontal axis represent the pdf of X1, X2, X3  and the blue curve the 𝟇 function.
The image of the 
interval [y-dy, y+dy]  by the inverse functions 𝟇1(-1) and 𝟇2(-1) of 𝟇1 and 𝟇2  are represented by the vertical rectangles [x1-dy, x1+dy] and [x2-dy, x2+dy] .
These two intervals bring a contribution to the pdf of 
(light gray blue on the right) represented by the horizontal violet rectangle on the right side of the picture.

T
he probability Prob(Y  [y-dy, y+dy]) that Y belongs to the interval [y-dy, y+dy]) is simply the sum 
                 Prob(
Y  [y-dy, y+dy])  = Prob(X1  𝟇1(-1)([y-dy, y+dy]))  + Prob(X2  𝟇2(-1)([y-dy, y+dy]))

Let
𝟇'b(-1)(y) denote the derivative of 𝟇b(-1)(y).
Making 
dy tends to 0 gives
                pdf(
Y y)  =  pdf(X1 𝟇1(-1)(y)) ×  𝟇'1(-1)(y) |pdf(X2 𝟇2(-1)(y)) ×  𝟇'2(-1)(y) |

As I said before there is truly no big math behind this, Except maybe those absolute values?
To understand where they come from zoom in on the rectangle 𝜔 = [
x1-dx, x1+dx] ╳ [y-dy, y+dy] and denote X𝜔 and Y𝜔 the restrictions of X1 and Y to 𝜔.
Locally 
Y𝜔 is proportional to A+B∙X𝜔 where constant B = 𝟇'(x1) and the value of constant does not matter here.
So the pdf of 
Y𝜔 is (a classical result)  pdf(Y𝜔 y) = pdf(X𝜔 (y-A)/C) / |C|.
Few details can be found Here.


MAPLE FAILURES AND WEAKNESSES

So why did Maple, at last some versions, produce a wrong result and why some versions are not even capable to return one?
The reason is that there is no big math only at first sight...because determining the inverse function of 
𝟇 can be quite tricky as soon as 𝟇 is not one-to-one map, for instance when 𝟇 is not strictly monotone.
When it is so
 𝟇(-1) must be defined for all the branches whose definition intervals intersect the support of X.

I spent a lot of time debugging the procedure Statistics:-PDF to understand why it either fails or produces incorrec results.
The 
sine_debug_nodebugoutput.mw  worksheet presents the "X ~ Uniform(0, 2𝜋)𝟇 : xsine(x)" case (as Mapleprimes stubbornly refuses to upload the worksheet containing the debugger trace, I convert it to sine_debug.pdf to help you see this trace). 
To orient the core development team correcting this procedure (assumming they care), the critical procedures are

Statistics:-RandomVariables:-PDF:-Univariate:-GetValueTab[anything]
and  Statistics:-RandomVariables:-GetInverse
 

At the very end it is this second procedure which is truly responsible of Maple failing to provide a result or returning an incorrect on, because it does not correctly build the inverse functions 𝟇b(-1)  for all the branches b which matter.
 

I wrote above that "it is only by chance that Maple provided the correct result for the non monotone function 𝟇 = cosine". Indeed Statistics:-PDF returns a wrong result when X ~ Uniform(z, z+2𝜋) and z is not a multiple of 𝜋/2 (see cosine.mw).

Other important situations where Maple fails returning a result are those where
𝟇 is a polynomial function with different zeros located in the support of X.
I did not trace them but it seems that
Statistics:-PDF does not know how to build the 𝟇b(-1) in this case (even though it is quite simple, see "Polynomial" examples below).



A SELECTION OF EXAMPLES

Here is a selection of examples to demonstrate that even in rather complex cases the pdfs of 𝟇(X) can be constructed quite easily (note that Maple either fails to compute them or to provide a correct result):



OPEN QUESTION

Tracing Statistics:-PDF reveals an already complex algorithm designed to handle a broad variety of "canonical" situations. Even this the algorithm fails in almost all non-toy-problem such as this compilation proves Maple_failures.mw.
At first sight, there seems to be a contradiction between the (apparent?) simplicity with which one can obtain, by hand in sometimes in an ad hoc way, the expression of pdf(𝟇(
X)), whether it is exact or truncated, and the complexity of the Statistics:-PDF algorithm, which results in failure in all non trivial cases.

This observation leads to the important question "Is it possible to rewrite Statistics:-PDF in order to enlarge its domain of success?".
I have the feeling that this means designing an algorithm which focuses more on mimicing the human reasoning than identifying "canonical" situations (as it is done today). 
An AI-driven algorithm maybe?

I repeat here that the maths are very simple, and all the more simple if you represent the random variable 
X as a mixture of components X1, ... XBboth having the same (truncated) distribution than X, and whose supports identify to the intervals of definition of the B branches of 𝟇 over the whole support of X.
The only difficulty lies in the identification of these branches and in the construction of the functions 
𝟇b(-1) over the supports of each Xb.

I have no answer to this question.

These are the original set up to solve for second order partial differetial equations:

E := 1.456*10^11;
rho := 7900;
a := sqrt(E/rho);
L := 0.03639;

f0 := 1/(2*L)*a;
f := f0 - 50;
A0 := 11.75*L/2*10^(-6);

d := 0.8*1000;
T0 := 5/f;
NULL;
PDE := diff(u(x, t), t, t) = a^2*diff(u(x, t), x, x) - d*diff(u(x, t), t);
IBC := {u(x, 0) = A0*cos(Pi*x/L), D[1](u)(0, t) = 0, D[1](u)(L, t) = 0, D[2](u)(x, 0) = 0};
pds := pdsolve(PDE, IBC, numeric, timestep = 2*10^(-7));

 I know it solves properly because I can plot it using pds:-plot without problem.  The question is how to extract the value at specific x and t.  I started to try some of the more intuitive way such as u(0,0) without getting an answer.  I tried a number of eval expression such as eval(pds,[x=0,t=0]), eval(u(x,t),[x=0,t=0]) and so on without success.  

Then I tried using :-value as mentioned in an example from the internet, also resulting in an error.

val:=pds:-value(x=0,t=0)

It seems to be simple.  I guess I am too new with maple so be gentle.  Thank you.

Hi,

My student licence  expired yesterday mar1. According to the description of my student licence it renews automatically. So I did not get active. But apparently it did not occur automatically. When starting Maple I get the message that my licence expired yesterday. To check whether the automatic renewal applies but did not work or whether I have to purchase a new licence for the next 12 months I tried to contact the customer support through online form. 

I do not see any other channel to contact customer support by mail or phone, what can I do ?

Manfred

When I solve for Pr and q simultaneously using Maple, I obtain a solution that differs from my manual derivation. I suspect there may be an issue with the solve function or the way it is specified. Could anyone please suggest how this can be corrected?
Manually solving q* = (Cv-Cd+Ce*tau-Ci)/(4Cr-t) which is different from maple results.

Sheet:Question_1.mw

Hello Friends,

I have a function f(t) which I would like to convolve with itself.  I have no problem doing that typically, but my function contains two elliptic integrals (EllipticE and EllipticK), which clearly complicates matters.

My work in included.  As you can see, the plot on the (0,2) interval is continuous, and the area under the curve sums to unity via numerical integration.

with(Statistics)

f := proc (t) options operator, arrow; piecewise(t <= 0, 0, 0 < t and t < 2, (4/3)*t*((4+t^2)*EllipticE(sqrt(1-4/t^2))-8*EllipticK(sqrt(1-4/t^2)))/Pi^2, 2 <= t, 0) end proc

proc (t) options operator, arrow; piecewise(t <= 0, 0, 0 < t and t < 2, (4/3)*t*((4+t^2)*EllipticE(sqrt(1-4/t^2))-8*EllipticK(sqrt(1-4/t^2)))/Pi^2, 2 <= t, 0) end proc

(1)

plot(f(t), t = 0 .. 2)

 

evalf(int(f(t), t = 0 .. 2))

1.000000000+0.*I

(2)

Download CircleDerivation2.mw

Are there any sort of transformations that I can employ which will permit me to convole this function with itself?  I realize a closed-form solution is probably not likely, but something approaching closed-form would be nice.  Via simulation, I have learned that the self-convolved function will have a continuous boundary on the (0, 2*sqrt(2)) interval.

nans:=dsolve({(-y^4+y^2)*diff(U(y),y,y)+(-2*y^2+14.2)*diff(U(y),y)*y-15.2*U(y)*(U(y)-1)*(U(y)+1) = 0, DU(.99999) = -.3401375821,U(.99999)= 0.3000034013},numeric);
Error, (in dsolve/numeric/process_input) invalid specification of initial conditions, got DU(.99999) = -.3401375821

I use  

Typesetting:-Unsuppress('all'):
Typesetting:-Settings(prime=t,'typesetprime'=true):

to make the math easier to read. (also the latex looks better this way).

But it has no effect when on the plot title. Here is screen shot and code

In this below, I get same title if I use   plot(t,'title'=typeset(the_title));   or plot(t,'title'=the_title);  Instead of dy/dt,  I wanted it to show as y'(t) like it does in worksheet.

Is there a way to make the title of the plot show the math in the nicer format shown in the worksheet automatically? It looks like Typesetting:-Settings does not extend to plots, which is too bad.


code

the_title:=diff(y(t),t$2)+c*diff(y(t),t)+k*y(t)=0;
Typesetting:-Unsuppress('all'):
Typesetting:-Settings(prime=t,'typesetprime'=true): #this says to use y'(t) instead of dy/dt    

plot(t,'title'=typeset(the_title),size=[300,300]);

#or

plot(t,'title'=the_title,size=[300,300]);

Is this a Maple bug? I do not see what I am doing wrong:

restart;

interface(version);

`Standard Worksheet Interface, Maple 2025.2, Windows 10, November 11 2025 Build ID 1971053`

Explore( plots:-textplot([0,0," CRITICAL DAMPING"],'axes'=none),
   initialvalues=[c=1,k=.1],
   parameters=[[c=0..10],[k=0..10]]
   );

 

 

Moving any slider gives the internal error.  Why?

Download internal_error_explore_feb_28_2026.mw

Here is a small movie

To help debug things, and to make it easier to add more logic such as if then else and so on, I moved the main body of Explor to a separate proc where the plot is made after doing some checking.

So instead of writing

Explore(plot(.....), 
 parameters=[  
   [c=0..10,....],
   [k=0..10,...]]
)

It now became

foo:=proc(c,k}
.....#some debug print messages added here, and some checking...
   plot(....)
end proc;

Explor( foo(c,k), 
  parameters=[  
    [c=0..10,....],
    [k=0..10,...]]
)

Two problems. 

1) My print lines inside foo() do not print to worksheet. Only the initial time they do. When I mean initial time, it is when Explore starts and does initalization. I see the print lines only then.

But after that, as I change the slider, which should make a call to foo(), I see nothing printed on the screen in my worksheet any more.

It is as if Explor stopped calling my foo().  But at same time, I see do see in the the display of Explore itself that it is calling foo as expected, since the call it display is changes and the result of the call changes as slider is changed. So call is being made. 

This is what shows inside Explore...

foo(5,2)=10
foo(3,2)=6
and so on

Why then the print messages from foo() are not printed in the worksheet any more? Where are the print message going to then?

2) How to make Explor only show the _result_ of calling foo() and not show the call itself as it does now? 

ie. instead of showing foo(5,2)=10  I just wanted to see the result of foo, which is 10 in this example.

Doing rhs(foo(c,k)) did not work

Here is worksheet to see yourself.

restart;

foo:=proc(c,k)
   print("c=",c," k=",k);
   c*k;
end proc:

Explore(foo(c,k),
   initialvalues=[c=1,k=.1],
   parameters=[
     [c=0..10,'controller' = 'slider','minorticks'=1,
      'snaptoticks'=true, 'label' = "Damping c",'showlabels'=false],
     [k=0..10,'controller' = 'slider','minorticks'=1,
      'snaptoticks'=true, 'label' = "Stiffness k",'showlabels'=false]]
   );

"c=", 10, " k=", 10

"c=", 0, " k=", 0

"c=", 1, " k=", .1

 

 

Download explore_feb_28_2026.mw

Here is small movie

ps. I am thinking now Explore only works with "plot" as its first argument. But help says expr can be anything.

Goal: to make a 3D parametric plot of a complex function u(x,t) obtained by pdsolve.  I tried to follow one example of a plot of a complex expression/function.  I was unable to get any plot.  I got some warning and error.  Please let me know what have I done wrong.

I follow this example so that I can get a 3D parametric plot of a complex function u(x,t) for a fix x:

with(plots);

complexplot(exp(t*I), t = 0 .. 2*Pi, scaling = constrained);

plot([cos(t), sin(t), t = 0 .. 2*Pi], scaling = constrained);

z := t -> exp(t*I);

spacecurve([Re(z(t)), Im(z(t)), t], t = 0 .. 4*Pi, axes = normal, labels = ["Re", "Im", "t"]);

It was successful.  With the following pde, I obtain an analytical solution using pdsolve.

a := 3;
L := 2*Pi;
d := 0.5;
T0 := 2*Pi;
PDE := diff(u(x, t), t, t) = a^2*diff(u(x, t), x, x) - d*diff(u(x, t), t);
IBC := u(x, 0) = cos(Pi*x/L), D[2](u)(x, 0) = 0, D[1](u)(0, t) = 0, D[1](u)(L, t) = 0;
pds := pdsolve({IBC, PDE}, u(x, t));

It fail 2D plotting using the following:

with(plots);
complexplot(u(0, t), t = 0 .. 6);

So I break down the pds with the following:

RP := Re(pds);
IP := Im(pds);
RP0 := eval(RP, x = 0);
RP0t := unapply(RP0, t);
IP0 := eval(IP, x = 0);
IP0t := unapply(IP0, t);

And I was hopeful as the following give me real numbers when I approximate them:

RP0t(1);
                             "(->)"


                     Re(u(0, 1)) = 0.20248

RP0t(2);
                             "(->)"


                     Re(u(0, 2)) = -0.57765

But it fails in both 2D and 3D plot:

plot([RP0t(t), t = 0 .. 6])

spacecurve([RP0t(t), IP0t(t), t], t = 0 .. 6, axes = normal)

Dear sir,

i want to draw velocity and temperature plots for fluid and dust phases. but getting error in that showing 12 BC need only 8 
i have tried with 8 Bc also but showing different error how to rectify it

dust_phase_work_error.mw 

I have two equations developed in different ways and I want to compare them.
The first is a development done using maple, while the second is an algebraic analysis.

I need to find out if both are identical and, therefore, if the subtraction would be equal to zero.

How should I proceed?

I had thought about simplifying the first and comparing it with the second; is that a good approach?

 

restart

with(plots)

H0 := -S1^2*eta1-S2^2*eta2-S1*gamma1-S2*gamma2

-S1^2*eta1-S2^2*eta2-S1*gamma1-S2*gamma2

(1)

NULL

Z0 := exp(-beta*H0)

exp(-beta*(-S1^2*eta1-S2^2*eta2-S1*gamma1-S2*gamma2))

(2)

Z0 := add(Z0, S1 = [-2, -1, 0, 1, 2])

Z0 := add(Z0, S2 = [-2, -1, 0, 1, 2])

G0 := -ln(Z0^((1/2)*N))/beta

G01 := -ln((2*exp(4*beta*eta1)*cosh(2*beta*gamma1)+2*exp(beta*eta1)*cosh(beta*gamma1)+1)^((1/2)*N)*(2*exp(4*beta*eta2)*cosh(2*beta*gamma2)+2*exp(beta*eta2)*cosh(beta*gamma2)+1)^((1/2)*N))/beta

-ln((2*exp(4*beta*eta1)*cosh(2*beta*gamma1)+2*exp(beta*eta1)*cosh(beta*gamma1)+1)^((1/2)*N)*(2*exp(4*beta*eta2)*cosh(2*beta*gamma2)+2*exp(beta*eta2)*cosh(beta*gamma2)+1)^((1/2)*N))/beta

(3)

Teste := G0-G01

NULL

Download TESTE_MAPLE.mw

my question is a little bit long but is not complicated, i want find thus  unkown but  realy i am don't know how apply on it by maple, i have two best paper which explain very well i just want to find thus dimensional Lie algebra which is be invariant or not satisfy condition or not which i have to used or which i have not to use it also the importan part how find them in paper 1 first , for equation fisher 
How find eq(29) which is i think is two -dimensional Lie algebra of equation, also the best part is reduction which by apply this we can change PDE to ode but i don't know how apply eq(31) or even find it yet  is related to eq(27-28)  and by replacing equation eq(34) we can get our ode i am just loking for the ode, for the eq(76) and eq(85) have same procedures,  i will mention the paper link too 

Lie.mw

paper-1

paper-2

given

ode:=x^2*diff(y(x),x)+cos(2*y(x)) = 1; 
ic:=y(infinity) = 5/4*Pi; 
mysol:=cot(y(x))=2/x+1;

the above solution is verified against the ode, but Maple do not give zero for the IC part. It gives 

                                 [0, -Pi*_Z6 + Pi]

But we can see the IC are verified also

limit(eval(mysol,y(x)=5/4*Pi),x=infinity)

Gives

                                    1 = 1

my  code checks if the entry in the result of odetest is zero or not. Hence for -Pi*_Z6 + Pi it thinks now the solution is wrong because it is not zero.   Ofcourse looking at it on the screen, we see that for _Z6=1 then it becomes zero.  

The question, why Maple odetest do not return zero for the IC part?

eq:=cot(y)=-A;
solve(eq,y)

eq:=cot(y)=A;
solve(eq,y)

I would expect solution to first to be arccot(-A) and for second to be arccot(A) but Maple likes to write the solution for the first one as Pi-arccot(A).

Of course Maple solution is correct. But why make it so complicated? Why not just give arccot(-A) as solution?  A is just a symbol.

I tried 4 different cas systems and they all give arccot(-A) for first one, except Maple gives Pi-arccot(A)

Is there some subtle reason why Maple gives solution like this instead of the simpler one? 

And is there a way to tell Maple not to do this? This seems to be something hardcoded internally in its automatic trig simplifications? I just do not see the point of writing it this way. May be someone knows why.

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