Maple 2020 Questions and Posts

These are Posts and Questions associated with the product, Maple 2020

Hello,

I was wondering if it is possible to write a 1st order differential equation in differential form?

So,

Instead of writing the diff eq in 

ode:=diff(y(x),x)=x^2+x*y(x)

is it possible to to write something like

ode: -(x^2+x*y(x))*D(x)+ (1)*D(y(x))=0

?

I've asked about this 5 years ago

 

https://www.mapleprimes.com/questions/203628-Maple-2015-No-Longer-Autoscroll-As

And according to the reply there at the time, this is supposed to have been fixed in Maple 2015.1:

It appears that the scrolling issue has been fixed in the next version of Maple

But ever since then, whenever I use Maple, the worksheet do not auto-scroll as the program runs and prints outout to the screen. I have to keep using the mouse to move the bar down to see the latest prints.

Not only that, the bar itself (on the right side) shrinks in size as more outpout is printed.

It becomes smaller and smaller with time, and becomes very hard to grab it with the mouse since it become so thin.  Once all the output is deleted, the bar become long again.

So I think there is an option to enable autoscrolling somewhere.

But I am not able to find it. I looked at options, display, general and interface and see nothing there to turn it on.

Sometimes I get the feeling that the folks at Maplesoft do not use Maple interface the way we users use it, becuase this is such a basic interface problem and any one who uses Maple interface for more than one day must see these problems all the time.

So how come these are still not fixed?  Here is a screen shot showing the bar on the right after long print out, and showing how it was before.

I use only worksheet mode, not document mode. On windows 10.

 

 

 

 

Whay the command:  123! + 1 takes significantly more time than 123! only??? Moreover time(123!+1) and time(123!) are very similar and fast.

I am using Worksheet GUI.

I do not understand what I am doing wrong. I have an Object, with private variable call hint. This private variable can be seen only by other proc's inside the object as expected.

Now inside one of those other proc's, I nested a small local proc inside it.

What I want is to access the object private variable from inside this small local proc nested inside.

But not able to. I tried different combinations and nothing is working.  Here is one of many attempts. 

restart;
module my_class()
   option object;
   local hint::string:="X"; #private variable to the object
 
   export foo::static:=proc(o::my_class) #can be seen from outside
      local boo; #local proc inside proc foo

      boo:=proc(o::my_class) #local proc
          print("inside boo()");
          print(o:-hint);
      end proc;

      print("in foo(), calling local proc boo()");
      print("hint is ",o:-hint); #works OK
      o:-foo:-boo(o); #tried also o:-boo(o) and boo(o)
   end proc;
end module;

called it as

o:=Object(my_class);
o:-foo(o)

Error, (in my_class:-foo) module `my_class` does not export `boo`
 

Also tried different combinations but so far nothing worked. For example, I tried making the nested proc static, but that did not help:

restart;
module my_class()
   option object;
   local hint::string:="X"; #private variable to the object
 
   export foo::static:=proc(o::my_class) #can be seen from outside
      local boo; #local proc inside proc foo

      boo::static:=proc(o::my_class) #local proc, static
          print("inside boo()");
          print(o:-hint);
      end proc;

      print("in foo(), calling local proc boo()");
      print("hint is ",o:-hint); #works OK
      boo(o);
   end proc;
end module;

o:=Object(my_class);
o:-foo(o)

Error, (in boo) module `my_class` does not export `hint`
 

But this error do not show up, when I made boo local to the object itself (vs. local to the proc). As follows, where the nested boo() proc is moved one level higher.

restart;
module my_class()
   option object;
   local hint::string:="X"; #private variable to the object
 
   export foo::static:=proc(o::my_class) #can be seen from outside     
      print("in foo(), calling local proc boo()");
      print("hint is ",o:-hint); #works OK
      o:-boo(o);
   end proc;

   local boo:=proc(o::my_class) #local proc to the object
      print("inside boo()");
      print(o:-hint);
   end proc;
end module;

now

o:=Object(my_class);
o:-foo(o)

works. No problem and no error.

How does one call a local proc to an object? Similar to how one does it in normal non-object proc's? 

Are local proc's inside object proc's allowed? Or for an Object, only one level of nesting is allowed?

Maple 2020.1

 

 

 

In Maple, an expression of type `*` can have many operands. I need to break it to product of two operands only.

For example given, expr:=A*B*C, I want first_part to be A and second_part to B*C

The way I do it now is clumsy.

I first check if expression is of type `*`, then use first_part :=op(1,expr) to find the first term, then divide the expression by that first term to find the second part. second_part:=expr/first_part

second_part:=op(2..nops(expr)) does not exaclty works, since it gives me B,C instead of B*C.

What would be a good way to do this? Notice that expr:=-A is actually a `*`, where first_part:=-1 and second_part:=A. Which is OK.

restart;
expr         := A*B*C;
first_part   := op(1,expr);
second_part  := expr/first_part;

Hello

Maple is dangerously close to using all available memory on my Linux machine by doing a calculation using  Grid:-Seq (Map, ..).   Is there a way to control the amount of memory used? Is numcpus a good option?   Or tasksize? 

I expect that Maple will use a large amount of memory since the calculations are performed over a rather large list of sets.  

Many thanks.

Ed

[Moderator's note: The original version of this Question mentioned using both Grid and Threads. The following 5 Replys will not make sense without knowing that Threads was mentioned.

Ed: Editing your Questions is fine, but please don't remove information that is necessary to understand the Replys and/or Answers that are already posted.--Carl Love]

it took a while to track this. When I run these 3 ode's in this sequence, Maple gives 

Error, (in Engine:-Dispatch) too many levels of recursion

and it has to be this sequence.  I also found I might have to run the code 2 or 3 times to get this error if it does not show first time. 

Will show a movie below also.

Here is the code

restart;
ode1:=cos(y(x)) - x*sin(y(x))*diff(y(x), x) = sec(x)^2:
ode2:=y(x)*sin(x/y(x)) + x*cos(x/y(x)) - 1 + (x*sin(x/y(x)) - x^2*cos(x/y(x))/y(x))*diff(y(x), x) = 0:
ode3:=x/(x^2 + y(x)^2) + y(x)/x^2 + (y(x)/(x^2 + y(x)^2) - 1/x)*diff(y(x), x) = 0:

func:=y(x);
the_ic:={};
the_time_limit:=60;

advisor:=timelimit(the_time_limit,DEtools:-odeadvisor(ode1)):
solution_by_CAS := timelimit(the_time_limit,:-dsolve([ode1,y(0)=0],func,singsol=all)):
result_of_ode_test := timelimit(the_time_limit,:-odetest~([solution_by_CAS],ode1)):

advisor:=timelimit(the_time_limit,DEtools:-odeadvisor(ode2)):
solution_by_CAS := timelimit(the_time_limit,:-dsolve([ode2,y(0)=0],func,singsol=all)):
result_of_ode_test := timelimit(the_time_limit,:-odetest~([solution_by_CAS],ode2)):

advisor:=timelimit(the_time_limit,DEtools:-odeadvisor(ode3)):
solution_by_CAS := timelimit(the_time_limit,:-dsolve([ode3,y(1)=0],func,singsol=all)):
result_of_ode_test := timelimit(the_time_limit,:-odetest~([solution_by_CAS],ode3));


And here is a movie (this time it happend on second run) sometimes it happens on first run. so it is random.

 

Maple 2020.1

Why does it happen and is there a work around?

Noticed few errors generated on some ode's. I do not know if these are expected or known, I thought may be someone might want to check them.

restart;
ode1:=(a^2*x+y(x)*(x^2-y(x)^2))*diff(y(x),x)+x*(x^2-y(x)^2) = a^2*y(x);
ode2:=x^7*y(x)^2*diff(y(x),x)^3+(1-3*x^6*y(x)^3)*diff(y(x),x)^2+3*x^5*y(x)^4*diff(y(x),x)-x^4*y(x)^5 = 0;
ode3:=diff(y(x),x)^4+x*diff(y(x),x)-3*y(x) = 0;

sol:=timelimit(60,:-dsolve(ode1,y(x))):

Error, (in dsolve) numeric exception: division by zero
 

sol:=timelimit(60,:-dsolve(ode2,y(x))):
timelimit(60,:-odetest([sol][5],ode2))

Error, (in IntegrationTools:-Indefinite:-AlgebraicFunction) argument is not an algebraic
 

sol:=timelimit(60,:-dsolve(ode3,y(x))):
timelimit(60,:-odetest(sol[1],ode3));
timelimit(60,:-odetest(sol[2],ode3))

Error, (in odetest) received not an ODE w.r.t x(_T)
Error, (in odetest) received not an ODE w.r.t y(_T)
 

This last one is only due to how the solution is given. So I do not think it is a real problem.

Maple 2020.1, Physics 708

windows 10



Maple Worksheet - Error
Failed to load the worksheet /maplenet/convert/check.mw .
 

Download check.mw

Hello,

I tried to solve an inequality involving factorials using solve, but I failed. The code is 

solve(1/(n+1)!<0.0001,n)

n should be 7.

Maple returns me "Warning, solutions may have been lost" message. 

How can I solve an inequality like this using solve?

I worked around this with a for loop testing the value of the expression for every increasing value of n against the criteria. Is there a "magical" keyword that will help with solve? 

 

 

sqrt(4) gives 2 in CAS systems, since the principal root is returned by default. 

Is there an option to have Maple return all roots? Which in this case 2,-2?

I'll explain the context why I need this.

When I solve an ODE, I get a solution that I need to solve for constant of integration C from initial conditions. For an example assume the ODE becomes, after replacing initial condition the following  eq:=4^(1/2) = -2+_C1;

So now when solving for _C1  in maple and then calling simplify, gives one solution which _C1=4 (case root=2) which when replaced back into the general solution gives the particular solution.

But this means the second solution is lost, which is when _C1=0  (case root=-2) which could have been obtained from the non-principal root of 4^(1/2)

eq:=4^(1/2) = -2+_C;
solve(eq,_C);

gives 

And I would like to get {4,0} instead.

In practice, this becomes important.

Here is an actual ODE, which should have 2 solutions. Mathematica gives both solutions, and Maple gives one solution.  This is due to the above.

ode:=diff(y(x),x)-y(x)=x*y(x)^(1/2);
ic:=y(0)=4;
dsolve([ode,ic])

In Mathematica

ode=y'[x]-y[x]==x*y[x]^(1/2);
ic={y[0]==4};
sol=DSolve[{ode,ic},y[x],x]

The second solution above came from when constant of integration is zero. The first solution is the one Maple  gave (when expanded).

When I worked the solution by hand, I tracked this to issue with sqrt(4) giving 2 and not +2,-2 when doing solve() to solve for C at the end.

I could ofcourse leave C=sqrt(4)  and not call simplify  on it  and that works.

But I thought to ask here to see if there is some option in Maple, so that when it sees (n)^m to return all m roots when calling solve() and not just the principal one. Even for m=2. 

I looked at root and tried allsolutions=true but they did not help. Looked at solve/details and did not spot something. I tried only few of the options there, as there are so many.

Any suggestions what to try?

 

Hello,

How can I use assmptions in partial differential equations?

For example consider the following differential equation

pde:=diff(u(x,t),t)+alpha*diff(u(x,t),x)=0
sol:=pdsolve(pde,build) assuming alpha=0

This gives me the same solution if alpha!=0

I also tried this

assume(alpha=0)
pde:=diff(u(x,t),t)+alpha*diff(u(x,t),x)=0
sol=pdsolve(pde,build)

I again got the same result as if alpha!=0. Except this time there was a tilde on the right side of alpha (to my knowledge that means there are assumptions on alpha)

How do you apply assumptions in PDEs? 

 

 

How find one curve fitting exponential  equation (or any other curve fitting) for the points:

X := [-0.012, -0.010, -0.004, -0.002, -0.001, -0.0001, 0.0001, 0.001, 0.002, 0.004, 0.010, 0.012];
Y := [-0.695, -0.7, -0.74, -0.825, -0.95, -1.0, 1.0, 0.95, 0.825, 0.74, 0.7, 0.695];
 

I tried, but it wasn't. Look:

X := [-0.012, -0.010, -0.004, -0.002, -0.001, -0.0001, 0.0001, 0.001, 0.002, 0.004, 0.010, 0.012];
Y := [-0.695, -0.7, -0.74, -0.825, -0.95, -1.0, 1.0, 0.95, 0.825, 0.74, 0.7, 0.695];


f := c + exp(-b*x);
                       f := c + exp(-b x)


Statistics*[NonlinearFit](f, X, Y, x);


Statistics [NonlinearFit(c + exp(-b x), [-0.012, -0.010, -0.004,  -0.002, -0.001, -0.0001, 0.0001, 0.001, 0.002, 0.004, 0.010, 

  0.012], [-0.695, -0.7, -0.74, -0.825, -0.95, -1.0, 1.0, 0.95, 0.825, 0.74, 0.7, 0.695], x)]

The Maple not find the curve.

I should get a curve like that (exemple):


 

I can't understand why select(has,3*C,x) returns 1  and select(has,3+C,x) returns 0

I was expecting to get NULL or {}. But when doing select(has,[3*C],x) and select(has,[3+C],x)  now both return [ ] as expected

Where did 1 and 0 come from in the above examples? I looked at help page, but do not see it.

restart;
select(has,3*C,x)

restart;
select(has,3+C,x)

or the same:

restart;
select(z->has(z,x),3*C);
select(z->has(z,x),3+C)

 

The select function selects the operands of the expression e which satisfy
the Boolean-valued procedure f, and creates a new object of the same type
as e. Those operands for which f does not return true are discarded in the
newly created object.

 

The above is the same as if one typed

select(x->false,3+C);
       0

select(x->false,3*C);
       1

 

I am trying to learn how do somethings without using pattern matching and it is a struggle so far for me.

For an example, now I want to ask Maple to tell me if C[1] (which is a constant) exist in expression, as long as C[1] does not occur as argument to exp(....)

I'll explain why I want to do this and show small example and show how I ended solving it and ask if there is better way.

Given this expression (this can be result of dsolve for example. Made up here)

I just need to determine if the expression has C[1] anywhere, which is NOT an argument to exp(). In the above example, there is one.

The reason I want to find this, is that this is the constant of integration for first order ODE, and I want to repalce exp(C[1]) by constant C[1], but as long as there is no C[1] allready anywhere in expression on its, otherwise I need to introduce new constant C[2], which I do not want to do (since first order, should have only one constant of integration) and in this case will leave the expression as is and not try to simplify it.

But indets tells one that C[1] is there, not where. This is what I tried

restart;
expr:=1/exp(z)*arcsinh(x*exp(C[1]))+x*C[1]*sin(exp(x))+3*exp(C[1]*y)*sqrt(sin(exp(3*C[1])));
indets(expr, specfunc(exp));

Now I can find if C[1] is argument to exp(....) from the above or not by more processing. (using applyrule or subsindets, etc...)

But first I still need to to determine if there is C[1] that exist anywhere else, as long it is not inside exp(.....).  If I do 

indets(expr, C[1]);

But this does not tell me the information I want. It just says expression has C[1] somewhere.

I looked at evalindets and looked at applyrule and do not see how to use these to do what I want.

Basically I want to tell Maple this

     indets(expr,C[1], conditional( C[1] is not anywhere inside exp(.....) ))

I can solve this using pattern matching. But I fnd Maple pattern matching awkaward to use sometimes and trying to learn how to do things without it.

So this is how I ended solving it. I replace all the C[1] inside exp(....) with ZZZ. Then use indets again to check if C[1] still there or not. This tells me what I want. 

restart;
expr:=1/exp(z)*arcsinh(x*exp(C[1]))+x*C[1]*sin(exp(x))+3*exp(C[1]*y)*sqrt(sin(exp(3*C[1])));
new_expr:=subsindets(expr, specfunc(exp), ()-> ZZZ);
if indets(new_expr, C[1])<>{} then
   print("C[1] exist outside exp()");
else
   print("C[1] does not exist outside exp()");
fi;

"C[1] exist outside exp()"

And

restart;
expr:=1/exp(z)*arcsinh(x*exp(C[1]))+x*sin(exp(x))+3*exp(C[1]*y)*sqrt(sin(exp(3*C[1])));
new_expr:=subsindets(expr, specfunc(exp), ()-> ZZZ);
if indets(new_expr, C[1])<>{} then
   print("C[1] exist outside exp()");
else
   print("C[1] does not exist outside exp()");
fi;

"C[1] does not exist outside exp()"

is there a better way to do this?

Hello again

I need to find the position of the elements of one list in another list.  Here it is a simple example

L1:=[837, 526, 283, 216, 93, 512, 161, 202, 76, 851, 503, 437, 147, 36, 922];
L2:=[526, 283, 202, 437, 922, 865, 879, 804, 473, 325];
remove(has,map(x->ListTools:-Search(x,L1),L2),0)

the position of the elements in list L1 is [2, 3, 8, 12, 15].   

For huge lists, this solution is not efficient.  Can that be done faster and less memory demanding? (Threads or Grid safe?).

Many thanks.

Ed

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