Maple 2020 Questions and Posts

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

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

Given some expression, I want to replace each exp(.....) in it with something else.

This is what I currently do. First I find all the exp() terms, then using a loop and use subs  like this

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

#find all exp terms
s:=select(x->has(x,exp),indets(expr));
s:=select(x->op(0,x)='exp',s)

Now, lets says I want to replace each with Z

I tried to use but that did not work.

So now I am doing this

for item in s do
    expr:=subs(item=Z,expr);
od:
expr

is it possible do this without a loop? could not do it using ~

With map, I can do this map(x->subs(x=Z,expr),s) but this does not replace it inside expr where I want. 

Assignment is not allowed inside the above so I can not do  this map(x->expr:=subs(x=Z,expr),s)

And if I do expr:=map(x->subs(x=Z,expr),s)  it does not work either. it gives

 

How to do the replacement without using a do loop? 

 

 

 

This is the Maple code

restart;
result:=int(1/tanh(u),u)

simplify(result,size) ;
simplify(result,symbolic);
simplify(result,ln);
simplify(result,trig);

Any suggestions?

 

 

How to find a rational function with give horizontal asymptotes: y=0.7, y=-0.7 and vertical asymptotes: x=0.001, x=-0.001?

Hello

I have a list with a large number of elements and I need to partition it in chunks of a specific size.  Here is my attempt

listpart := proc(cond::list,nchunk::nonnegint:=1000)
if numelems(cond) < nchunk then
	newcond:=[cond]:
else
	ss:=[`$`(1..numelems(cond))]:
	sss:=map(`mod`,ss,nchunk):
	ind:=[ListTools:-SearchAll(0,sss)]:
	ind:=[0,op(ind),ifelse(ss[numelems(ss)]=ind[numelems(ind)],[],ss[numelems(ss)])]:
	newcond:=[Threads:-Seq(cond[(ind[j]+1)..ind[j+1]],j=1..(numelems(ind)-1))];
end if:
return(newcond):
end proc:

It does not run as fast as I thought.  I am not even sure if Threads:-Seq could be used in this case.  Please tell me what I am doing wrong and how I can modify the code to get a faster response.  

Many thanks

Ed

 

This is an animation of the spread of the COVID-19 over the U.S. in the first 150 days.  It was created in Maple 2020, making extensive use of DataFrames. 

 

https://www.youtube.com/watch?v=XHXeJKTeoRw

 

The animation of 150 Day history includes COVID-19 data published by the NY Times and geographic data assembled from other sources. Each cylinder represents a county or in two special cases New York City and Kansas City. The cross-sectional area of each cylinder is the area in square miles of the corresponding county. The height of each cylinder is on a logarithmic scale (in particular it is 100*log base 2 of the case count for the county. The argument of the logarithm function is the number of cases per county divided by the are in square miles-so an areal density.  Using a logarithmic scale facilitates showing super high density areas (e.g., NYC) along with lower density areas.  The heights are scaled by a prefactor of 100 for visualization.

Hello,

I am trying to calculate an integral involving dirac delta as given below

int(Dirac(sin(x)),x=-3/2*Pi..3/2*Pi)

However, Maple returns the integral unevaluated as

int(Dirac(sin(x)),x=-3/2*Pi..3/2*Pi)

How can I get it evaluated? the result should be 3 here.

Thanks in advance.

I can't figure out how Maple obtained this solution and looking for some ideas to try.

It is first order non-linear ode in y(x), which is separable.

ode:=diff(y(x),x)=x*ln(y(x));
dsolve([ode,y(1)=1],y(x))

But the general solution is

sol:=dsolve(ode)

Setting up manually an equation using the given condition in order to solve for _C1, produces no solution. 

eq:=subs([y(x)=1,x=1],sol);
solve(eq,_C1)

Warning, solutions may have been lost
 

Also 

coulditbe(exp(RootOf(1 + 2*Ei(1, -_Z) + 2*_C1))=1)

   FAIL

So how did Maple solve for the constant of integration which results in particular solution y(x)=1 that is supposed to satisfy the condition y(1)=1?  

It is clear that y(x)=1 satisfies the ODE itself. But I am asking about how it also satisfies y(1)=1

(odetst says it does satisfy the ODE and condition as well. So Maple must have done something very smart under the cover)

Next I tried

ode:=diff(y(x),x)=x*ln(y(x));
sol:=dsolve(ode,y(x));
sol:=DEtools:-remove_RootOf(sol);
sol:=subs([y(x)=1,x=1],sol)

And now

solve(sol,_C1)

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

Just wondering how did Maple decide that y(x)=1 satisfies y(1)=1? I do not see it.

Using Maple 2020.1. But same result on Maple 2019

Theoretically, if the multiplication sign  is missed Maple needs to give reminders or warnings.But the following is not the case, why?I am surprised its output. 

x:=1
                             x := 1
x(2+1)Actually, I want to enter x*(2+1)

                               1
x(sin(y))Actually, I want to enter x*(sin(y))
                               1

In preparing to sample problems, I came across this difference in an output depending upon the input type: 2d Input vs. Maple Input. Is there a typo on my part?


 

restart; kernelopts(version); Digits

`Maple 2020.1, X86 64 WINDOWS, Jun 10 2020, Build ID 1474787`

 

10

(1)

Very happy with the output of the following line:

x := evalf[30](3.0^1.2)

3.73719281884655197790004100992

(2)

 

But I'm confused about the output of the next line. Is it a limit to the calculation or a display problem?

a := evalf[30](3.0^(1.2))

3.737192819

(3)

 

and yet this next output looks fine:

b := evalf[30]( exp( 1.2 * ln(3)))

3.73719281884655197790004100989

(4)

 

Fortunately, there appears to be no difference between x and b:

evalf[30](x-b)

0.3e-28

(5)

 

But these next  lines suggest there is an actual limit in the calculation of a.

evalf[30](a-b)

0.15344802209995899011e-9

(6)

evalf[30](a - b);

0.15344802209995899011e-9

(7)

Note - when Digits is set to 30, the calculation difference between x and a disappears.

``


 

Download 2020_evalf_digits.mw

From help, it says

coulditbe routine returns true if there is a possible value of x1 that satisfies prop1

my question is, how to find out this condition/possible values that Maple found?  This infomration is very useful, but now I do not see how to obtain it. All what coulditbe retuirn is true or false.

Context of why I am asking:  Sometimes odetest do not verify its own solutions. And coulditbe can help in finding under what conditions the solution can satisfy the ode. Here is an example

restart;
ode:=diff(y(x),x) = abs(y(x))+1;
solExplicit:=dsolve(ode);
offset := odetest~([solExplicit],ode)

gives

[exp(-x)/_C1 - abs((-exp(-x) + _C1)/_C1) - 1, exp(x)*_C1 - abs(exp(x)*_C1 - 1) - 1]

Both solution fail odetest. 

coulditbe~(offset,0)

gives true

So there are assumptions/conditions which makes the solution satisfy the ODE. In this case, by inspection one can see what these conditions are. They are, for one solution:

(-exp(-x) + _C1)/_C1  >0

and for the other, the condition is

exp(x)*_C1 - 1 >0

Under these assumptions, odetest would have given 0 for each odetest.

And it is this information I wanted to obtain automatically from coulditbe.

In Mathematica, Reduce is used for this. Reduce gives conditions under which something is satisfied. For example, 

Reduce[ C[1] Exp[x] - Abs[C[1] Exp[x] - 1] - 1 == 0, {x, C[1]}, Reals]

Gives

C[1] >= Exp[-x]


While the above in  Maple

coulditbe( C[1]*exp(x)- abs( C[1]*exp(x)-1)-1 = 0)

gives true  only, but without the important information, true under what conditions.

Is there a different command in Maple which could give this information?

Hi there.

I need to calculate multiplcations of huge polynoms with reducing in GF(2^m) with m>1000.

For example, modpol(a*a,f_t,t,2^N) with N=4007, degree(a)=8008 and degree(f_t)=8009.

Standard modpol calculates this in 4-5 sec on my computer.

Maybe there is an easy way to speed up this calculation?

Thank you.

ex.mw

nn.txt

Suppose I have

with(GraphTheory):
vertices:=["M","P","C"]:
edge_weights:={[{"M","P"},3],[{"M","C"},1]}:

G1:=Graph(vertices,edge_weights)

EigenvectorCentrality(G1)
                                                  

Is it right to say the EigenvalueCentrality values correspond to the names in the vertices correspondingly?  ie M corresponds to 0.4415.. P corresponds to  0.4188.. and C corresponds to 0.1396... ?

This was generated when running some code on Maple 2020.1.

Just wondering if this might indicate some problem internally, or is this something that can happen.

restart;
ZZ:=Int(-(a*_a^2+(_a^4*a^2-4*_a*b*y(x))^(1/2))/(a*_a^3+_a*(_a^4*a^2-4*_a*b*y(x))^(1/2)+6*y(x)),_a = _b .. x)+Intat(-2/(a*x^3+x*(a^2*x^4-4*_f*b*x)^(1/2)+6*_f)-Int(2/(_a^4*a^2-4*_a*_f*b)^(1/2)*b*_a/(a*_a^3+_a*(_a^4*a^2-4*_a*_f*b)^(1/2)+6*_f)+(a*_a^2+(_a^4*a^2-4*_a*_f*b)^(1/2))/(a*_a^3+_a*(_a^4*a^2-4*_a*_f*b)^(1/2)+6*_f)^2*(-2*_a^2/(_a^4*a^2-4*_a*_f*b)^(1/2)*b+6),_a = _b .. x),_f = y(x))+_C1 = 0;

timelimit(30,value(ZZ))

Error, (in discont/zero) too many levels of recursion

The problem is that I am not able to trap the error. This does not work

try
ZZ:=Int(-(a*_a^2+(_a^4*a^2-4*_a*b*y(x))^(1/2))/(a*_a^3+_a*(_a^4*a^2-4*_a*b*y(x))^(1/2)+6*y(x)),_a = _b .. x)+Intat(-2/(a*x^3+x*(a^2*x^4-4*_f*b*x)^(1/2)+6*_f)-Int(2/(_a^4*a^2-4*_a*_f*b)^(1/2)*b*_a/(a*_a^3+_a*(_a^4*a^2-4*_a*_f*b)^(1/2)+6*_f)+(a*_a^2+(_a^4*a^2-4*_a*_f*b)^(1/2))/(a*_a^3+_a*(_a^4*a^2-4*_a*_f*b)^(1/2)+6*_f)^2*(-2*_a^2/(_a^4*a^2-4*_a*_f*b)^(1/2)*b+6),_a = _b .. x),_f = y(x))+_C1 = 0;
timelimit(30,value(ZZ));
catch:
  print("ignore");
end try;

Error, (in discont/zero) too many levels of recursion

Why can't one catch this error inside try/catch? It means the whole program can not  continue.

Maple 2020.1

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