nm

8552 Reputation

19 Badges

12 years, 355 days

MaplePrimes Activity


These are questions asked by nm

For the last hr, I've been trying to find out why Maple solve was hanging inside one module in my .mla when called.

I would try the same code in new worksheet, no hang. I had timelimit on it. Same exact code as in the module.

I go back to the other worksheet, do restart, call the module (after loading the library by setting libname) which calls solve(), and it hangs. Each time.

I tried may be 10 times. No difference between the code in the mla and the other worksheet where I had copy of the solve command. All other settings are the same. 

ONLY after I closed Maple, and restarted Maple, and opened the worksheet where the call used to hang, and called the module again, now it did not hang and solve completed.

This is not the first time I've seen such a strange thing. Sometimes Maple will hang for hrs (I start  a test, go to sleep,. wake up hrs later, and see maple hanged for hrs from the time stamp).

Closes Maple, start the test from where it was hanging, and now no hang. It runs OK from then on.

This tells me that doing just restart from the worksheet do not clean everything. (I use the command restart, not by pressing the restart button in the menu, not sure if these are different, they should be the same  I would think).

I've seen this problem before. sometimes the test just hangs. No matter how many time I do restart from the worksheet, it just hangs. When I restart Maple, it works from same place it was hanging.

My question is, what could possibly make Maple not hang when starting fresh. vs. using the restart command?  I am using the same worksheet, and I have "create new engine for each document" selected in options.

The hang used to happen in solve, in here

#this is inside a function inside a module inside .mla library
#

eq:=x = 1/2/(p^2+2)^(1/8)*2^(1/2)*((1+(-4*p^2+1)^(1/2))/(1/(4*p^2-1)*p^2)^(1/2)/(-4
*p^2+1)^(1/2))^(3/4)/(((-4*p^2+1)^(1/2)+3)/(p^2+2)^(1/2))^(1/4)*_C1*p^(1/4);

        try               
            sol_p:=timelimit(20,[:-solve(x=rhs(eq),p)]);
        catch:
           return [];
        end try;
#hangs here. Never completes. Only when starting Maple the hang is gone. 

#trace below
......
Main: polynomial system split into 1 parts under preprocessing
Main: using RegularChains based methods
SolverVariableOrder: using the variable order  _S000008 > _S000011 > _S000009 > _S000006 > _S000005
TriangularDecomposition: using deterministic algorithm for decomposition
<<<< HANGS HERE EACH TIME >>>>

Again, only when I restarted Maple, did the hang go away. it is one equation solving for one variable.

So now, I get into the habit of closing all of Maple and starting it again when I get a hang. I do not trust restart command any more to clear everything.

Any idea why this happens? Memory not cleared somewhere? Cache problem? Does the frontend itself stores something that could cause this? does restart use new mserver.exe each time or same mserver.exe process as last time?

if restart does not actually terminate the mserver.exe that the worksheet was talking to, but only sends request to mserver.exe to clear its own memory, this could explain things.

It is possible that mserver.exe which is attached to that worksheet does not fully clear all its own memory and something remain there which affects why it hangs in same place each time, even though restart was issued each time, and only when restarting Maple itself will clear this and the hangs goes away.

 

 

When asking dsolve to use specific ode type to solve an ode, in particular, dAlembert type, which typically generate complicated solutions, sometimes dsolve solution shows up using parameter T.

But odetest gets confused by this expression it seems. I am not able to figure if I am doing something wrong in using odetest, or may be odetest does not know how to handle such form of a solution.

Here is an example. This ode

is of these types:

restart;
ode:=diff(y(x), x) = (y(x)^3 + 2*x*y(x)^2 + x^2*y(x) + x^3)/(x*(y(x) + x)^2);
DEtools:-odeadvisor(ode);

By default, dsolve was smart to use homogeneous type to solve the ODE, as this gives the simplest solution. 

One can force dsolve to use the other types. When using dAlembert, odetest gives an error trying to verify any one of the solutions returned from dsolve due to the way the solution is returned. Here is the result

restart;
ode:=diff(y(x), x) = (y(x)^3 + 2*x*y(x)^2 + x^2*y(x) + x^3)/(x*(y(x) + x)^2);
sol:=[dsolve(ode,y(x),[homogeneous])];

No problem here for odetest. it can verify any of the above 3 solutions with no error generated.

odetest(sol[1],ode)

          0

Lets compare using dAlembert type

restart;
ode:=diff(y(x), x) = (y(x)^3 + 2*x*y(x)^2 + x^2*y(x) + x^3)/(x*(y(x) + x)^2);
sol:=[dsolve(ode,y(x),[dAlembert])]: #solution too complicated to show here
odetest(sol[1],ode)

 

It looks like odetest does not know how to handle the form of the solution as returned by dsolve for this case. The problem is that each solution is actually made up of two parts, not just y(x) as normally is the case. One part defines something called X(T_) and the next part which is the solution y(x) uses this X(T) in it. 

Did I do something wrong, or is there a way around this, or is this by design?

Maple 2020.2

restart;
f:=(x,y)-> x*y^3-x^2/y^3;
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y));
lis:=[]:
for tmp in op(eq) do
    if has(tmp,alpha) then
       lis:=[op(lis),op(2,simplify(select(has,tmp,alpha)))];
    fi;
od;
lis;
PDEtools:-Solve(lis[1]=lis[2],p)

This method happend to work for this example, but it does not work in general. This is because the function can be anything. Here is a second example

restart;
f:=(x,y)-> -2/3*x+1/3*(x^2+3*y)^(1/2);
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y));

We see by inspection if p=2 then we can write the above as, by setting p=2 as 

But the Maple code I had above does not work on this

restart;
f:=(x,y)-> -2/3*x+1/3*(x^2+3*y)^(1/2);
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y));
lis:=[]:
for tmp in op(eq) do
    if has(tmp,alpha) then
       lis:=[op(lis),simplify(select(has,tmp,alpha))];
    fi;
od;
lis;

The problem is finding all powers of alpha in each term and setting up an equation to find p such that all terms have same numerical value.

So I abandoned this method as too messy to program (it works well for hand solution, this is an example where solving something by hand is easier than on the computer) and then tried solve directly, like this (on the first example)

restart;
f:=(x,y)-> x*y^3-x^2/y^3;
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y))- alpha^r*f(x,y)=0;

And here is where I am stuck. I need to ask Maple if it can find alpha, r that are rational numbers, such that the above equation is solved.

PDEtools:-Solve(eq,[p,r])

But we know from above that p=1/6 and r=3/2 is solution

simplify(subs([p=1/6,r=3/2],eq))

             0=0

The question is: Can Maple solve such an equation for  p,r? I remember now reading something about parameteric solver in Maple. I need to look that up to see if it helps. I tried SolveTools:-SemiAlgebraic on this, but it did not help.

Are there better methods to determine in Maple if function is isobaric and to find the index p and r?

Reference: book

Notice, some places define isobaric function as one in which we can find p such that

But this is not correct. I've seen it on 2 pages on the net. The correct definition is 

Also note: When p=1 isobaric function becomes a homogeneous function which is special case of isobaric and r is now called the degree of homogeneity 

But for isobaric, p do not have to be 1. This is the main difference.

f(x,y) will always be a function of x,y.  I will add more examples of isobaric functions to test against.

edit. Simplified question is restated below

After looking more into this. I found I actually wanted to solve the simpler problem, which is

So please ignore the general case of isobaric where r<>p-1 which is harder. 

I only need to look at this case where r=p-1 which is actually simpler. It turned out this is what I need for my solver and not the general case.

I will now give my solution to this and show where the problem I am having.

I am using Maple solve to find p. So no r any more. Only solving for one variable. But Maple solve fails sometimes. And this is the problem.

The problem is that solve can find p for many cases, but fails on some, where there is clearly a solution. I will show 5 examples below.

#example 1. WORKS
restart;
f:=(x,y)-> 3*sqrt(x*y);
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y))- alpha^(p-1)*f(x,y)=0;
PDEtools:-Solve(eq,p) assuming alpha>0;

#example 2. WORKS
restart;
f:=(x,y)-> 4*(x*y)^(1/3);
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y))- alpha^(p-1)*f(x,y)=0;
PDEtools:-Solve(eq,p) assuming alpha>0;

#example 3. WORKS
restart;
f:=(x,y)-> (-3*x^2*y-y^2)/(2*x^3+3*x*y);
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y))- alpha^(p-1)*f(x,y)=0;
PDEtools:-Solve(eq,p) assuming alpha>0;

#example 4 WORKS
restart;
f:=(x,y)-> (-(x*y)/2+sqrt(x^2*y^2-4*y)/2)*y;
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y))- alpha^(p-1)*f(x,y)=0;
PDEtools:-Solve(eq,p) assuming alpha>0;

And here is the one that does not work

#Example 5. Does not work. How to make it work?
restart;
f:=(x,y)-> -2*x/3+sqrt(x^2+3*y)/3;
eq:= subs([x=alpha*x,y=alpha^p*y],f(x,y))- alpha^(p-1)*f(x,y)=0;
PDEtools:-Solve(eq,p) assuming alpha>0;

There is a solution for this. p=2 works. Why solve did not find it? I mean, it gives RootOf, which does not help me decide if this is isobaric or not. Why it did not find the solution p=2?

simplify(subs(p=2,eq)) assuming alpha>0

                 0=0

Using Mathemtica, it found p=2 solution. How to make Maple find this solution is my question.

Sorry for the long question. I first thought I needed the general isobaric case, but found later i needed the simpler one.

 

 

This might be something basic. But looking at help I do not see it now.

why has(expr,sqrt) do not give true?  is something special about sqrt function?

restart;
mysol :=sin(x);
has(mysol,sin); #works

mysol :=ln(x);
has(mysol,ln);  #works

mysol :=sqrt(x);
has(mysol,sqrt);  #does not work
hasfun(mysol,sqrt);  #does not work

Just wondering why, that is all. Only this worked

hastype(mysol,sqrt)

                true

I am sure there is a good reason for this. sqrt seems to be special function.

Maple 2020.2

all in real domain, sqrt(A)*sqrt(B) can be combined to sqrt(A*B) when both A,B are non-negative.

Is there a way in Maple to  find the conditions when sqrt(A)*sqrt(B)=sqrt(A*B) ? i.e. the conditions on A,B where this is true?

A,B will only be functions of x,y.   

An example will make things clear.

restart;
expr1:=sqrt(x^2*y - 4)*sqrt(x^2*y);
expr2:=sqrt(  (x^2*y - 4)*(x^2*y));

By looking at the above, we see that expr1 = expr2 when  x^2*y-4>=0 and x>0 or x^2*y-4>=0 and x<0. Actually I think only x^2*y-4>=0 is needed, since x is being squared anyway.

How to make Maple show this? I can't get Maple to show this

solve(expr1=expr2,[x,y]) assuming real;

But this is wrong. it says it is true for all x and all y?.   Mathematica can do it using Reduce command

I know I can force the combination by using the command

combine(expr1,sqrt,symbolic);

ps. Maple took the x outside the sqrt. So x>0 is assumed here.

pps. I do not understand why simplify(expr1,symbolic) did not work here, and neither  simplify(expr1,symbolic,size=false) worked. Only combine worked.

But I wanted to see if Maple could tell the condition when this is allowed, so I can write these down.

It would be nice if the command above would also tell the conditions under which it combined the sqrts. But this information is not given.

This is all done non-interactive in a program without being able to look at the screen and decide what to do. Only thing I know is that if an expression has sqrts and functions of x,y.

Is there a way in Maple to have tell conditions when expr1=expr2?

Maple 2020.2

First 61 62 63 64 65 66 67 Last Page 63 of 164