nm

9718 Reputation

19 Badges

12 years, 61 days

MaplePrimes Activity


These are questions asked by nm

I have number of worksheets open. I set each to use its own engine.

If I have one worksheet running a long loop that takes hrs to complete, or even if I have cmaple.exe running long script in command line, and then at same time I open new worksheet and type

             Physics:-Version(latest)

Then I always get this error

This is described here

It seems because Maple was busy running another worksheet. I never see this error if I am not running any other thing in Maple at the time. ( I actually try not to update Physics while running something else in Maple, but sometimes I do not notice that I have something else running).

When I wait for my other worksheet to finish, then close all of Maple and reopen Maple, I see the latest version is installed, at least this is what Physics:-Version() now says.

My question is:  Is it safe to do Physics:-Version(latest) even when Maple is busy running  computation in other separate worksheet or even running cmaple.exe from windows command line? Is there any concurrency/locking issue on the Physics library being updated while it is being open by another worksheet or another server.exe running in background?

All this is on windows 10 pro.

Why Maple returns y(x)=0 as solution to this ode when even odetest do not validate the solution? Solution satisfies the ode but not the given BC.

Is this a known bug?

I've updated the worksheet now to include few more examples, all using same ode but with different BC's. In all 4 examples, Maple gives solutions when there should not be solution and in one case gives solution which can not even be used for odetest. These are random BC's generated just for testing.
 

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1804. The version installed in this computer is 1802 created 2024, September 3, 11:35 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib\`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

#EXAMPLE 1

ode:=diff(diff(y(x), x), x) + 2*diff(y(x), x)/x - y(x) = 0;
IC:=y(-1)=0,D(y)(-infinity)=-1/exp(1);

diff(diff(y(x), x), x)+2*(diff(y(x), x))/x-y(x) = 0

y(-1) = 0, (D(y))(-infinity) = -1/exp(1)

maple_sol:=dsolve([ode,IC]);

y(x) = 0

odetest(maple_sol,[ode,IC])

[0, 0, -exp(-1)]

restart;

#EXAMPLE 2

ode:=diff(diff(y(x), x), x) + 2*diff(y(x), x)/x - y(x) = 0;
IC:=y(infinity)=0,D(y)(-infinity)=-1/exp(1);

diff(diff(y(x), x), x)+2*(diff(y(x), x))/x-y(x) = 0

y(infinity) = 0, (D(y))(-infinity) = -1/exp(1)

maple_sol:=dsolve([ode,IC]);

y(x) = 0

odetest(maple_sol,[ode,IC])

[0, 0, -exp(-1)]

restart

#EXAMPLE 3

ode:=diff(diff(y(x), x), x) + 2*diff(y(x), x)/x - y(x) = 0;
IC:=y(-infinity)=0,D(y)(-infinity)=-1/exp(1);

diff(diff(y(x), x), x)+2*(diff(y(x), x))/x-y(x) = 0

y(-infinity) = 0, (D(y))(-infinity) = -1/exp(1)

maple_sol:=dsolve([ode,IC]);

y(x) = signum((sinh(x)+cosh(x))/x)*infinity

odetest(maple_sol,[ode,IC])

Error, (in signum) signum is not differentiable at 0

#EXAMPLE  4

restart;

ode:=diff(diff(y(x), x), x) + 2*diff(y(x), x)/x - y(x) = 0;
IC:=y(-infinity)=0,D(y)(infinity)=-1/exp(1);

diff(diff(y(x), x), x)+2*(diff(y(x), x))/x-y(x) = 0

y(-infinity) = 0, (D(y))(infinity) = -1/exp(1)

maple_sol:=dsolve([ode,IC]);

y(x) = 0

odetest(maple_sol,[ode,IC])

[0, 0, -exp(-1)]

 


 

Download wrong_sol_dsolve_sept_10_2024.mw

Update sept 13, 2024

Here is one more example I found. In this ode, the IC given leads to division by zero in the solution. Yet Maple for some reason removes the offending part of the solution with that constant, and returns the rest. 

Is one allowed to do this? odetest also do not validate the solution. There should not be solution returned in this case, since it is not possible to find values for the constants of integration given these initial conditions. Right?

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

restart;

ode:=x^2*diff(y(x),x$2)+x*diff(y(x),x)-9*y(x)=0;
IC:=y(0)=1,D(y)(0)=0;
maple_sol_no_IC:=dsolve(ode);

x^2*(diff(diff(y(x), x), x))+x*(diff(y(x), x))-9*y(x) = 0

y(0) = 1, (D(y))(0) = 0

y(x) = c__1*x^3+c__2/x^3

maple_sol_with_IC:=dsolve([ode,IC]); #maple just removed the c2/x^3 part. Since at x=0 gives problem?

y(x) = c__1*x^3

odetest(maple_sol_with_IC,[ode,IC]); #shows solution does not verify

[0, 1, 0]

 


 

Download another_example_solution_given_when_none_exist.mw

 

 

I wanted to change  eq:= 1/2 * sqrt(-2*lambda)  to 1/2 %* sqrt(-2*lambda)  using a rule.

It works outside of rule ofcourse. But when I put %* in the RHS of the rule, maple hangs. It seems it is going into infinite loop.

I tried the trick of using '%*' but this gives syntax error.

Same problem happens when using %. and not just %*

Is there a workaround?

Attached worksheet. Make sure to save all work before trying it.
 

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1804. The version installed in this computer is 1802 created 2024, September 3, 11:35 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib\`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

eq:= 1/2 * sqrt(-2*lambda)

(1/2)*(-2*lambda)^(1/2)

eq:= 1/2 %. sqrt(-2*lambda); #no problem

`%.`(1/2, (-2*lambda)^(1/2))

eq:= 1/2 %* sqrt(-2*lambda); #no problem

`%*`(1/2, (-2*lambda)^(1/2))

restart;

eq:= 1/2 * sqrt(-2*lambda)

(1/2)*(-2*lambda)^(1/2)

applyrule(sqrt(x::anything)/y::anything = 1/y %. sqrt(x),eq); #why this hangs?

 

restart;

eq:= 1/2 * sqrt(-2*lambda)

(1/2)*(-2*lambda)^(1/2)

applyrule(sqrt(x::anything)/y::anything = 1/y %* sqrt(x),eq); #why this hangs?

 


 

Download maples_hangs_applyrule_sept_10_2024.mw

This is an excersise in one of Mathematica's tutorials. The problem is to find from all persumtations of [1,2,3,4] those lists which has 2 in them before 3.

But the idea is that 2 can be anywhere before the 3, with possibly zero or more numbers between.

Will show how to do this in that other software, and ask if there is a way using Maple pattern matching or better way to do this in Maple better than what I did.

L=Permutations[{1,2,3,4}]
Cases[L,{___,2,___,3,___}]

gives

{{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 4, 2, 3}, {2, 1, 3, 4}, 
{2, 1, 4,  3}, {2, 3, 1, 4}, {2, 3, 4, 1}, {2, 4, 1, 3}, 
{2, 4, 3, 1}, {4, 1,  2, 3}, {4, 2, 1, 3}, {4, 2, 3, 1}}

We see in all of the above, 2 is before 3.

In that other software, the ___ means there is zero or more things.  I could not find how to do this in Maple's pattern matching. So had to use has and then find the index of 2 and 3 in each list and check if the index of 2 is smaller than the index of 3. Which is kinda awakard and not as elegent as using a pattern, but it gives same result.

L:=combinat:-permute([1,2,3,4]);
map(X->`if`(has(X,2) and has(X,3) and ListTools:-Search(2,X)<ListTools:-Search(3,X),X,NULL) ,L);

Gives

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

Can you suggest a way using either patmatch or applyrules in Maple to do the same?  

Could this be done easier than what I did using evalindents without the need for pattern?

I find patterns easier to work with myself.

ps. converting each list to string, and then using regular expression or string matching, is not what I am looking for. 

ps. the check in Maple code of has(X,2) and has(X,3) is not really needed here, since we know each list will have 2 and 3 in them. But I kept these to make it more general for other type of problems where these extra checks might be needed.

applyrule is useful but seems limited. I can't do operation such as expand in the RHS of the rule.

For example, I wanted to applyrule that says to take sin(x::anything) and change it to cos(expand(x)), but it does not expand x. 

It seems because in the RHS of the rule, at the instance applyrule sees expand, x remains a symbol and not evaluated. So there is nothing to expand. It gets evaluated at later time, but by then too late for expand to do anything, it is gone. Just a guess.

But is there a trick to allow one to do more things in RHS of applyrule, such as expand or simplify? This would make applyrule much more useful. Otherwise, as it is, applyrule is of limited use. 

I know I can use evalindets ofcourse for this. 

#expand does not work in RHS of applyrule
e1:=sin(2*sqrt(a*b)*(t+mu));
applyrule( sin(x::anything) = cos(expand(x)), e1);

sin(2*(a*b)^(1/2)*(t+mu))

cos(2*(a*b)^(1/2)*(t+mu))

#but other operations worksheetdir
e1:=sin(2*sqrt(a*b)*(t+mu));
applyrule( sin(x::anything) = cos(x^2), e1);

sin(2*(a*b)^(1/2)*(t+mu))

cos(4*a*b*(t+mu)^2)

expand(2*sqrt(a*b)*(t+mu))

2*(a*b)^(1/2)*t+2*(a*b)^(1/2)*mu

#I could do this ofcourse
evalindets(e1,'specfunc'(sin),X->sin(expand(op(1,X))));

sin(2*(a*b)^(1/2)*t+2*(a*b)^(1/2)*mu)

 

 

Download apply_rule.mw


Using other software, there is no such problem using other operations on RHS of a rule

You see, expand worked on RHS of rule. 

I'd like to do same thing using applyrule in Maple. Is there a trick to allow this?

Maple 2024.1

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