Maple 2021 Questions and Posts

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

Hi,

I have a function of 3 variables (PiM) which I can use in plot3d given the first argument while the other two arguments are functions of the two variables I use in plot3d.

In the code I attached below, I am plotting 2 planes using plot3d, but I cannot implicitplot where these two planes intersect. COuld you please take a look at my code?

Thanks.

maple_primes_question.mw

 

 

Hi,

Is there a way to change the font type and size when printing a table of data using DocumentTools:-Tabulate? Also can I change the column width?

DocTabFont.mw

I can't figure this one out.

I need to pick out the subexpression   anything*sin(3*x) from an expression.

it works, when the expression is   anything*sin(3*x)+something else. But when the expression is exactly  anything*sin(3*x) then select returns and not anything*sin(3*x) as I was expecting.

So I must be doing something silly, but do not see it.

restart;
TypeTools:-AddType('type_1', '`*`'({anything,identical(exp(3*x))}));
expr:=25*A[1]*exp(3*x);
type(expr,type_1);

returns true. good. Now I test it on 

select(type,expr+sin(x),type_1) ;

and this returns what is expected. 25*A[1]*exp(3*x) but when I type

select(type,expr,type_1) ;

it return

reading select help page did not help.  Tried flatten, inplace.

I can do this using patmatch

patmatch(expr,a::anything*exp(3*x),'la');la

But why is select not working in the above? What is the correct way to do this so it works for a*expr+anything and also for a*expr only? This is done inside a function and not interactive. So I need it to work for both cases, since the input can be anything, but I only need the term anything*exp(3*x) pulled out.

 

I want to have a proc, which returns an expression using an indexed symbol. The proc needs to basically generate constansts to use to build an expression, similar to how dsolve uses _Cn.  But I do not want to use _Cn for this so not to confuse the expression with another one that was generated using _Cn already.

So I thought to use a local symbol say A.  (I could have used _Zn also, but I think _Z is also used by Maple).

The symbol A is first declared local to the proc, and then the proc returns the expression using A[n]. For example  A[0]*x+A[1]*x^2 etc... The number of A[n]'s is not known before hand, but should not be more than 10. 

I want to make sure that A[n] returned is really part of the local symbol and not different symbol to avoid clash with any global A[n] 

When I do the following check

restart;
foo:=proc()
 local A;
 return A[99]
end proc;

expr:=foo()

type(expr,`global`)

gives

good. So Maple says that A[99] is not global. But when I do

type(expr,`local`)

it also says false!

My question is: When making local A , will A[1] and A[2] also be local, or are they different symbols? Maplemint says nothing about it, so I assume A[n] is local also?

maplemint(foo)
Procedure foo() 
  These local variables were used but never assigned a value:  A

It did not say that A[99] was never declared local. This tells me that A[99] is local, because A is local. But then why did type(expr,`local`)  say false?

Hi,

I was wondering why each time solve is executed, I get a different of number of solutions and can I specify the number of solutions?

 

Thanks so much for taking time to answering this question.

 



Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/number_of_solutions.mw .
 

I don't way the above error happened. But here is my worksheet below.

Download number_of_solutions.mw

Given an expression, how to best find the constants _C1, _C2, etc.... in this expression?  Currently I do the following, but I think there should be a better way.

restart;
sol:=dsolve(diff(y(x),x$2)+y(x)=1);
indets(sol);
select(x->`if`(type(x,symbol) and convert(x,string)[1..2]="_C",true,false),indets(sol))

The above works, at least on the few examples I tried it on, but is there a better way to do it?  All constants will have the form _Cn where n is integer. 

 

 

Why is this integral so difficult -- so slow to execute?

seq(evalf(Int(1/R*sinh(s*coth(1/2*s))^(2*I/k)/(gam-I*k*cosh(s))^5*
     Int(exp(-(k^2*sinh(s)^2/(gam-I*k*cosh(s))-I*k*(1+cosh(s)))*v)*
     hypergeom([1/k*I],[1],k*v*I)*v^n,v = 0 .. 1/2*R), s=0..s_max)), n=0..1);

Hints to improve the efficiency of execution would be appreciated.

The conversion of a maple formula in latex version 2021 produces some

commands which are not defined , see   primes_latex.mw.

Perhaps more informations should be given  in the news about the command latex in Maple 2021

Hello

I need to find all the variants (I am not sure if this is the correct term to be used but I hope this will be clear in the example) of a specific indeterminate in a given expression.  Here is an example:

alpha[3, 5]*xi[1]*xi[8] + alpha[3, 5]*xi[4]*xi[5] + alpha[3, 3]

For this particular example, xi[1], xi[8], xi[4], and xi[5] are the variables I am looking for. The indexes of xi change depending on the previous calculation.  Also, in some cases, I need the alpha variables instead, that is, alpha[3,5], and alpha[3,3].  

I could not figure out how to use indets in this case.

Many thanks for your help. 

I may be misunderstanding the documentation of implicitplot.  Can someone set me straight?

This is extracted from the implicitplot's help page:

implicitplot(-x^2 + y, x = 0 .. 2, y = 0 .. x);

The plotting range is limited to y ≤ x, as intended.  Let us verify that it does the right thing:

display(
	implicitplot(-x^2 + y, x = 0 .. 2, y = 0 .. x, color=red),
	plot(x, x=0..2, color=blue)
);

Yes, indeed it does.

Now let us try limiting the plotting range to y ≤ 1 − x2. Here is what we get:

display(
	implicitplot(-x^2 + y, x = 0 .. 2, y = 0 .. 1-x^2, color=red),
	plot(1-x^2, x=0..2, color=blue)
);

I expected the red curve to lie entirely below the blue curve but it doesn't. Am I misunderstanding implicitplot?

Download worksheet: mw.mw

Sorry to bother you with a basic question again.

How do I get both the indexes and the values of a table?

Table.mw

 

The following code completes apparently without error on Maple 2020.2, but with Maple 2021.1 I get a deconnection from the kernel:

restart:
with(LinearAlgebra):
A:=Statistics:-Sample(Normal(0,1),[2500,2500]):
U,S,Vt:=SingularValues(A,output=['U','S','Vt']):
Norm(U.DiagonalMatrix(S).Vt-A);

The crash occurs when running the last line.

The code works on both versions with a smaller matrix (256x256).

Is there something obviously wrong with this piece of code, or a change in Maple 2021 that could explain this?

Note: I'm running Maple on Windows 10, the machine has 16 GB RAM, and the memory usage stays low.

Which one of these two versions, is the recommened one to use? For example, to check for type  integer*x, where x is literal x. i.e. identical(x)

restart;
TypeTools:-AddType('type_1', `&*`(integer,identical(x)));
type(3*x,type_1);

restart;
TypeTools:-AddType('type_1', '`*`'({integer,identical(x)}));
type(3*x,type_1)

Both work.  The difference is that `*` needs {} while `&*` does not.

I read the help page  and I do not understand what it says about the difference, and when is one supposed to use `*` vs. `&*`. it says 

              | `*`(type)  a product of factors of the given type
              | `&*`(type*)  a product of factors in which the nth factor is of the nth type specified in type*

Could possibly someone please explain in simple plain english what is the difference? If I use `&*`  vs. `*` with {}, will they work the same all the time or are there cases when to use one vs. the other?  Any rules of thumb to follow?

I need to simplify terms such as (cos(x)^2+sin(x)^2) to 1 if present in input, but I do not Maple to also do any other simplification rewriting polynomials that might be present in the expression.

And example will make it clear. Given this

expr:= (cos(x)^2+sin(x)^2)+5+(1+x+x^2+x^3)*(cos(x)^2+sin(x)^2)*exp(x);

I want expr to become  6+(1+x+x^2+x^3)*exp(x).   i.e. only simplify trig terms

But simplify(expr,trig); gives

                 6 + (x + 1)*(x^2 + 1)*exp(x)

Which is not what I want. Then I tried the trick of thaw and freeze to tell Maple to freeze polynomial type, like this

restart;
expr:= (cos(x)^2+sin(x)^2)+5+(1+x+x^2+x^3)*(cos(x)^2+sin(x)^2)*exp(x);
thaw(simplify(subsindets[flat](expr,satisfies(Z->type(Z,polynom(integer, x))),(freeze))));

And it actually worked, giving

           6 + (x^3 + x^2 + x + 1)*exp(x)

Question is: Why did simplify(expr,trig) not do what expected, which is to only simplify trig terms in expression and not mess around with the polynomial there? 

Is the above method of thaw/freeze to control which parts of expression gets simplify a recommended way to work around this, or is there a better way?

 

I can't figure how to make my own type, which is rational and greater than one.

There are buildin types for postive and posint, and so on. But what if I want to make for rational and greater than some value, say 1?

This is easy to do using patmatch, using the conditional. But do not know how to do it to make my own type.

Here is a simple example. I want to check for sin(x)^n, where n is rational and must be >1.  Using pathmatch

restart;
patmatch(sin(x)^(1/2),conditional(sin(x)^a::rational,a>1),'la');la;

does it. Using structured type, the best I could do is this

restart;

TypeTools:-AddType('my_sin',specfunc(sin)^And(rational,positive));
type(sin(x)^(1/2),'my_sin');

But this does not check for >1, only positive.

Any suggestions? I know I could do this using other means, by direct parsing, using op, and so on. But I'd like to learn how to do it using structured type, just to learn the syntax if there is one.

is it possible to use conditional with structured types? But need  name to do that, like with patmatch, but there is no such syntax in structured types. 

ps. I think conditional does not make much sense with structured type. But I need to figure how to make my own type, which is rational and say >1, or integer and say >2 and so on. I just do not know how to do that yet. But I am sure there is a way. Will try to figure it out.

 

 

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