Maple 2020 Questions and Posts

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

I gave odetest some confusing long candidate solution to check for me. It gave an internal error

restart;
ode:=3*y(x)*cos(x)+4*x*exp(x)+2*x^3*y(x)+(3*sin(x)+3)*diff(y(x),x) = 0:
sol:=y(x) = -1/3/(exp(I*x)+I)^2*exp(((24*I*x*exp(I*x)-24*x)*polylog(2,I*exp(I*x))+(-24*I-24*exp(I*x))*polylog(3,I*exp(I*x))+(4*I*x^3-3*I*x+6*I*Re(x)-6*Im(x))*exp(I*x)-6*I*Im(x)+3*x-6*Re(x))/(3*exp(I*x)+3*I))*(1-I*exp(I*x))^(-4*x^2)*(4*int((1-I*exp(I*x))^(4*x^2)*x*(2*I*exp(((-24*I*x*exp(I*x)+24*x)*polylog(2,I*exp(I*x))+(24*I+24*exp(I*x))*polylog(3,I*exp(I*x))+(6*Im(x)-6*I*Re(x)-4*I*x^3+(3+6*I)*x)*exp(I*x)+6*I*Im(x)+6*Re(x)+(-6+3*I)*x)/(3*exp(I*x)+3*I))+exp(((-24*I*x*exp(I*x)+24*x)*polylog(2,I*exp(I*x))+(24*I+24*exp(I*x))*polylog(3,I*exp(I*x))+(6*Im(x)-6*I*Re(x)-4*I*x^3+(3+9*I)*x)*exp(I*x)+6*I*Im(x)+6*Re(x)+(-9+3*I)*x)/(3*exp(I*x)+3*I))-exp(((-24*I*x*exp(I*x)+24*x)*polylog(2,I*exp(I*x))+(24*I+24*exp(I*x))*polylog(3,I*exp(I*x))+(6*Im(x)-6*I*Re(x)-4*I*x^3+(3+3*I)*x)*exp(I*x)+6*I*Im(x)+6*Re(x)+(-3+3*I)*x)/(3*exp(I*x)+3*I)))/(sin(x)+1),x)-3*C[1]):

timelimit(30,odetest(sol,ode));

Error, (in tools/map) too many levels of recursion

I agree that the solution I gave it is very long and most likely is wrong solution. But that is besides the point. The problem with these internal recursion errors, is that try/catch does not catch them. So the whole program stops, and not able by bypass this error.

Should odetest have handled this better?

fyi, I posted similar internal error from Maple about 2 weeks ago in https://www.mapleprimes.com/questions/229872-Error-in-Discontzero-Too-Many-Levels

due to too many levels of recursion as well, but that was fromt rying to evaluate int. 

Maple 2020.1 , Physics 708

 

why does Maple say that timelimit got one argument when doing

timelimit(30,solve(x^2+a=0,x) assuming a>0)

There is clearly 2 arguments in the above, The first is 30 and the second argument is solve(x^2+a=0,x) assuming a>0

I know the workaround is to add [ ] around solve(). 

timelimit(30, [solve(x^2+a=0,x) assuming a>0])

Maple 2020.1 windows

I am interested in the AC circuits which control electric motor performance.

I have installed the Syrup package, written by Joseph Riel, from the Application Centre but it seems to draw and solve only DC powered circuits.

Does Syrup have AC circuit capability?

If not, is there any available package written in Maple which can draw and analyse AC circuits, preferably one in which the circuit can be constructed by clicking circuit elements in an palette and dragging them to a canvas?

Finally, if there is no such Maple package, can you point me to an equivalent, free package which is downloadable from the internet? 

I guess this command got missed?

with(ColorTools)

?ColorString

 

 

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]

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

 

First 44 45 46 47 48 49 50 Last Page 46 of 55