Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

A very simple question (by example):

Consider two polynomials g and h:

with(PolynomialTools):

g:=FromCoefficientList([1,2,3],x);

h:=FromCoefficientList([4,5,6,7],x);

 

What is the syntax for computing the composition of g with h? (As a polynomial.)

For instance, I would like to use CoefficientList on the result.

 

I know the @ operator and the subs command and have tried using them in various ways, but with no success.

(Of course, my question is general; the above is just an example.)

---

Edit: Additional question (which is my real question):

I'm writing a procedure that takes two polynomials g and h, and in which I define an unknown polynomial f. I want to compute its coefficients so that

f "composition" g = h

I write:

fCoeff:=seq(a[i],i=0..t) (to define the unknown coefficients. I can compute t.)

f := FromCoefficientList([fCoeff],x);

Then I would like to do something like:

comCoeff:=CoefficientList(f "composition" g,x)

If I have this, then I know how to solve for the unkown coefficients in f.

Hello. Tell me, please, is it possible to somehow remove the labels on the axes in Maple when plotting graphs? I mean labels 1, 2, 3 and so on. Thank you for your help.

Maple will give error when one tries to make a variable of the same name as a Maple command. Which is good ofcourse. So this gives an error

Vector:=5;

But Maple also uses hundreds of other names, as options, which are not protected like this. Even when adding this

adding interface(warnlevel=4);
kernelopts('assertlevel'=2):

There was no warning when a user makes a variable of same name as one of those Maple option names.

So if a user make a variable with such a name, it will cause serious problem. For example Vector constructor takes the name row as an option. But this name is not protected. So one can write  row:=5 and there is no warning generated by Maple.

Using Vector['row'] does not actually help. Here is an example, where Maple crashes due to this

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector['row']);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem

ArrayTools:-Concatenate(1,A,convert([a,b],Vector['row'])); #this will crash Maple

 

A workaround this, it to use double '' in the second call. Like this:

ArrayTools:-Concatenate(1,A,convert([a,b],Vector[''row''])); 

And if this to used again, to use

ArrayTools:-Concatenate(1,A,convert([a,b],Vector['''row'''])); 

And so on.  Ofcourse this is no way to do things.

So the user should not use row as variable name. May be use the_row instead, or a_row, and so on.

But this comes back to my question. The above is a made up example. How is the user supposed to remember there is some option used by Maple somewhere with such a name and avoid using it as a variable name? 

There are may be thousands of such names in Maple, with common names, like color and so on, and it is very easy to make a variable of this name by the user without noticing.

I also tried maplemint() and it gave no warning that a user variable have the same name as a Maple option name.

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc()
local A,row,res,a,b;
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector['row']);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem
ArrayTools:-Concatenate(1,A,convert([a,b],Vector['row'])); #this will crash Maple
end proc;

maplemint(foo);

foo()

 

Finally, I found that if I use Vector(:-row) instead of Vector('row'), then the crash goes away and now it works

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc()
local A,row,res,a,b;
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector[:-row]);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem
ArrayTools:-Concatenate(1,A,convert([a,b],Vector[:-row])); #this will now work
end proc;

foo();

But this worked because there was no global variable of the name row before calling foo. That is all. To make the above crash, all what I had to do is this
 

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc()
local A,row,res,a,b;
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector[:-row]);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem
ArrayTools:-Concatenate(1,A,convert([a,b],Vector[:-row])); #this will now work
end proc;

row:=5;
foo();

And now it crashes again.

This is all a big mess. Maple should warn users they are using variable of same name as Maple own option names, or make all Maple option names use some standard prefix. May be have them all start with or _ and have this special first letter be allowed only for Maple own use.

This will help prevent name clashes.

In Mathematica, this issue does not happen. Since all Mathematica names and symbols used, even as options, are protected or are strings. So no such possibility of name clash happen.

Is there a 100% robust way in Maple to prevent such name clash between user variable names and names used as options to Maple commands?

 

Hi!

There is some procedure/function to convert C code into maple code? For instance, the above text file

C_code.txt

contains the C code of this paper  http://www.dcs.bbk.ac.uk/~jkl/pubs/JL1_00a.pdf to compute the image of a point in [0,1] under the N-dimensional Hilbert curve and vice versa (i.e., given a point P in the N-dimensional cube [0,1]^{N} find the point t in [0,1] such that t is mapped into P under the Hilbert curve)

Unfortunately, I don't know anything about the C programming language.

Many thanks in advance for your comments.

Fyi, there seems to be some problem here

Maple 2020.2 with Physics 897

restart;
interface(warnlevel=4):
kernelopts('assertlevel'=2):
eq:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+(1/3)/y(x)^(2/3))*(D(y))(x) = 0;
timelimit(30,solve(eq,y(x)));

 

Full screen shot:

 



Maple Worksheet - Error

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

Download solve_error.mw

Hi,

I noticed that, in Maple 2020.2, the caracters seem smaller. As if the zoom had somewhat been reduced (a bit).

However, in the preferences, the default zoom level I would like is between 100 and 125% (something like 110%) (since the default zoom level is adjusted by steps of +/- 25%). I wondered if there was a way to set the default zoom level to an arbitrary value. In fact I thought it would be great to have a field instead of a list of choices, so we can choose a custom value.

Thank you

I was trying to plot a simple degree two curve but with one point removed. My first attempt was the following;

p1 := plot(x^2 - 1, x = -2 .. 2);
p2 := plot([[0, -1]], style = point, symbol = circle, symbolsize = 20);
plots[display](p1, p2);

But the curve line is shown even inside the circle of the removed point. Changing order of `p1` and `p2` in `plots[display]` doesn't make any changes on the output.

My second attempt was the following.

p3 := plots[display](plottools[disk]([0, -1], 0.1, color = white)):
plots[display](p1,p3);

This didn't help either.

Is there a way to tell Maple to compute an integral over a domain defined by an implicit condition?

A trivial example would be: integrate 1 over the 2D domain defined by x^2+y^2<=1.

I know it's possible to write the explicit double integral

int(int(1,y=-sqrt(1-x^2)..sqrt(1-x^2)),x=-1..1);

Or even as a single integral:

integrate(2*sqrt(1-x^2),x=-1..1);

However, it's not always possible to do this explicitly, depending on the form of the relation f(x,y)=0 defining the domain.

 

My idea was:

int(Heaviside(1-x^2-y^2),[x=-1..1,y=-1..1]);

But Maple returns 0. However, evalf/Int returns the correct numerical value of Pi.

 

Hi,

Is there a way to keep the fractional form of probabilities? I tried with InertForm without success. thanks

ARBREprobabilité.mw

Hello everyone,

There is a strange behaviour with code-edit. Namely, when hiding code-edit window and recovering it, sometimes Maple create a very narrow window. It is very hard to see the code that way. After a while the code-edit region window readjusts itself though. However it takes time.

Also another thing, it would be useful when searching in a worksheet, to have an option that allows to search in code-edit region also.

Best regards,

By the code

P := plot( [ sin(x)-x+(x^3)/3! ] ) :
L := plots[textplot]( [ 3 , 15 , sin(x)-x+(x^3)/3! ],  axes = none) :
plots[display]( P ,L, axes = normal )

I'd like to put the text sin(x)-x+(x^3)/3!  not  sin(x)-x+(x^3)/6   in the image.

I thought  that parse can do that

parse("sin(x)-x+(x^3)/3!")

But One use it in plots[textplot] , it is not useful!

P := plot( [ sin(x)-x+(x^3)/3! ] ) :
L := plots[textplot]( [ 3 , 15 , parse("sin(x)-x+(x^3)/3!") ],  axes = none) :
plots[display]( P ,L, axes = normal )

How to do? Thanks!

 The code

s:=solve(sin(x)=3*x/Pi,x)

gives us following output:

s := RootOf(-sin(_Z)*Pi + 3*_Z)

The allvalues command attempts to find symbolic representations of the roots using solve.
But  the code:

allvalues(s);
solve(sin(x)=3*x/Pi,x,AllSolutions)

gives us 

RootOf(-sin(_Z)*Pi + 3*_Z, 0.5235987756), RootOf(-sin(_Z)*Pi + 3*_Z, -0.5235987756), 0

RootOf(-sin(_Z)*Pi + 3*_Z)

To see the roots of sin(x)-3*x/Pi   we use plot

plot(sin(x)-3*x/Pi,x=-100..100)

 

plot(sin(x)-3*x/Pi,x=-Pi/4..Pi/4)

And we can also figure out  three roots of this function are 0  Pi/6 and -Pi/6

High probability it has no other root.

seq(eval(sin(x)-3*x/Pi,x=i),i in [-Pi/6,0,Pi/6])

0, 0, 0

Why doesn't Maple do anything about it

 

 

 

Why doesn't the graphs of alpha=0 and alpha=1  appear in the following code?

restart:
v:=t->t:
plot([seq(fracdiff(v(t), t,alpha),alpha=-1..1.5,0.5)],t=0..10,view=[0..9.5,0..5],legend=[seq('alpha'=alpha,alpha=-1..1.5,0.5)],color = [red, blue, green,yellow,cyan,magenta],axis[2]=[gridlines=[linestyle=dot]]);

 

if alpha=1;

fracdiff(t, t,alpha)

gives 1. But it doesn't appear in the figure. 

if alpha=0, 

fracdiff(t, t,alpha)

gives t. But it doesn't appear in the figure, also. 

How can i remove a section envelope ( the initial arrow and the vertical line) without removing the content.

In other words how can I liberate the content from being imprisoned in the section

 

Thank you

First 333 334 335 336 337 338 339 Last Page 335 of 2097