Maple 2020 Questions and Posts

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

Hello,

I plot a pdf of the average of two iid random variables, and get that it is negative. What am I doing wrong?

Here is an example:

restart;
with(plots);
with(Statistics);
X1 := RandomVariable(BetaDistribution(4, 4));
X2 := RandomVariable(BetaDistribution(4, 4));
plot([PDF(X1, t), PDF(0.5*X1 + 0.5*X2, t)], t = 0 .. 1, color = [red, blue], legend = ["PDF X1", "PDF average"]);

I want to plot3d this function :
(2*Int(3*piecewise(x < 1, x, 1 < x, 2 - x)*piecewise(y < 3/2, y, 3/2 < y, 3 - y)*sin(Pi*x/2)*sin((2*Pi*y)/3), [y = 0 .. 3, x = 0 .. 2]))/3
 

So, I wrote : 

plot3d((2*Int(3*piecewise(x < 1, x, 1 < x, 2 - x)*piecewise(y < 3/2, y, 3/2 < y, 3 - y)*sin(Pi*x/2)*sin((2*Pi*y)/3), [y = 0 .. 3, x = 0 .. 2]))/3, x = 0 .. 2, y = 0 .. 3)

and I get :

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

I am totally new with integrals and I think there is a pb related to a bad writing of them.
Thank you for your answers.

Hello, 

is there any possibility how to write just a part of axis label e.g. in Italic? For example if I want want a label to be "ln(h)" and i want just the "h" to be written in Italic font.

Thanks a lot.

Hi all, 

I am trying to plot the amplitude spectrum of a square wave. I plotted the wave by using its fourier series but I want to find the 5th harmonic which should be around 0.5 however, maplesoft retruns it as 0.7 for some reason. When the stem plot is plotted even that look likes 0.5 at the 5th harmonic but the F(5) is giving wrong value. 

Please have a look at the screenshot and file attached. 

Pulse_width_8us.mw

 

(Note: Maple was not giving wrong answer, I accidently uploaded the wrong file and have edited/updated the question)

I easily found the roots of the following equations,

s:=solve(x^3+x^2-2*x-1,x)

I accidentally discovered that  2*cos((2*Pi)/7) is also the root of this equation. 

simplify(eval(x^3+x^2-2*x-1,x=2*cos((2*Pi)/7)))

0

It’s easy to know that 2*cos((2*Pi)/7) is equivalent to the third root found above

s1:=fsolve(x^3+x^2-2*x-1,x);
2*cos((2*Pi)/7.)

         s := -1.801937736, -0.4450418679, 1.246979604

                          1.246979604

 

Maybe I don’t like the use of imaginary units, and I prefer  2*cos((2*Pi)/7) .

In the case that I don’t know that  2*cos((2*Pi)/7) is the solution of the equation, can I make a certain transformation without using the imaginary unit to represent the real number. For example, trigonometric functions, exponential functions, etc.

I tried to use the following functions, all failed.

s:=solve(x^3+x^2-2*x-1,x);
convert(s[3],cos);
identify(s[3])

 

What is interesting is the following phenomenon. Even if Zeta function does not look great:

s1:=fsolve(x^3+x^2-2*x-1,x):
identify(s1[3])

 

 

For this example, can all roots be transformed into trigonometric expressions by maple.

 

 

I would like to use the command "TensorArray"  to create the contravariant tensor.  As seen in the following simple routine, the command output seems to assign values to the contravariant tensor, but, on the last line, the contravariant value is still unassigned. 




 

 

 

The uploaded worksheet describes a chain driven at constant speed by gears.

What math will describe its shape?

GearDrivenChain.mw

Hi there.

I would like to get advice about most elegant and effective ways of building animated plots (sequnces of plots) of two kinds:

1. Coordinates of point on some background curve. So each plot in sequence contain constant background curve and single point that moving from plot to plot;

2. Line of points from some array. So i-th plot in sequence draw line that build on i (1..i) points from array.

I want to demonstrate these animated plots on some example - Kepler problem (point moving on ellipse):

ell.mw

But I don't think that my code is effective.

Thank you.

I read the code in the link below and have some thoughts on drawing the graph.

https://www.mapleprimes.com/questions/216092-Options-For-Graph-Drawing-In-The-GraphTheory

restart:
with(GraphTheory):
with(SpecialGraphs): 
G     := PetersenGraph();:
POS := GetVertexPositions(G);
EG   := Edges(G); 
PLOT(
   seq( CURVES([POS[EG[i][1]], POS[EG[i][2]]], LINESTYLE(3) ), i=1..numelems(Edges(G))),
   POINTS(POS, SYMBOL(_SOLIDBOX, 35), COLOR(RGB, 1, 1, 0)),
   seq(TEXT(POS[i], i), i=1..numelems(Vertices(G))),
   AXESSTYLE(NONE)
)

 

 

But if we want to change the edge to a curvilinear style, it seems very difficult. We know  PetersenGraph is 1-planar graph.  The following picture is one of  its 1-plane drawing.  That is  also what I want to draw .

 

PS: 1-planar graph is a graph that can be drawn in the Euclidean plane in such a way that each edge has at most one crossing point, where it crosses a single additional edge

Although I asked a similar question, but it uses too many special curve functions and the method is relatively isolated. Because the cycle graph is too special.  https://www.mapleprimes.com/questions/228987--Can-We-Draw-Curved-Edges-In-The-Graph

I also noticed the optional items of the edge style.  But there are no curves, such as arcs, parabola, etc.

The plot style must be one of line, point, pointline, polygon (patchnogrid), or polygonoutline (patch).  

I am trying to draw a parabola, it seems to be quite difficult. And it completely deviated from the use of graph theory package.

drawarc :=proc(A,B,C,ecolor);

local  c,ax,cx ,ay,cy,ox,oy,oo,x,y,b,a,an_end,an_start,r,yuanhu:
ax :=evalf(geometry)[HorizontalCoord](A):
cx :=evalf(geometry)[HorizontalCoord](C):
ay :=evalf(geometry)[VerticalCoord](A):
cy :=evalf(geometry)[VerticalCoord](C):

geometry[circle](c,[ A ,B ,C], [x,y],'centername' =o):

ox :=evalf(geometry[HorizontalCoord] (o)):
oy :=evalf(geometry[ VerticalCoord] (o)):

if(cx -ox)>0 then
b :=arctan((cy -oy) /(cx -ox)):
elif(cx -ox)=0 and (cy -oy)>0 then

b :=Pi/2 :
elif(cx -ox)=0 and (cy -oy)<0 then

b :=-Pi/ 2 :
else 
b :=Pi +arctan((cy -oy) /(cx -ox)):
fi :
if(ax -ox)>0 then 
a :=arctan((ay -oy) /(ax -ox)):
elif(ax -ox)=0 and (ay -oy)>0 then

a :=Pi /2 :
elif(ax -ox)=0 and (ay -oy)<0 then

a :=-Pi/ 2 ;
else 
a :=Pi +arctan((ay -oy)/ (ax -ox)):
fi ;
if(evalf(b)<evalf(a))then
an_start :=a :
else
an_start :=a +2*Pi :
fi :
an_end :=b :

r :=geometry[ radius] (c); 
yuanhu :=plottools[ arc] ([ ox , oy] , r , an_start..an_end):

plots[ display] (yuanhu , scaling =constrained, color =ecolor,axes=none);

end :

geometry[point] (a , -3 .00 , 1 .70);
geometry[point] (b , 0 .35 , -0 .45);
geometry[point] (c , 3 .13 , 1 .86);
l :=[a , b , c] ;
drawarc(a,b,c,blue);

I would like to ask maple if there is a more versatile and simpler way to draw a curve of  graph drawing.

drawarcs:=proc(VL ::list , ecolor , scope);
local i , num , arcs , arc_text , vl , display_set ;
vl :=VL ;
num:=nops(vl);
arcs :={};
i:=1;
if num <3 then 
"There isn' t enough points in the point list." ;
return ;
elif irem(num-1 , 2)<>0 then  
"The number of the list must be multiple of 2 when it minus 1 .";
fi :
while i <num do
arcs :={drawarc(vl[i] ,vl[i +1] , vl[i +2],ecolor),op(arcs)};
i:=i +2 ;
od ;
arc_text :=geometry[ draw] ({vl[1] , vl[num] }, printtext =true , color =ecolor);
display_set:={op(arcs),arc_text};
plots[ display] (display_set , view =[ -abs(scope)..abs(scope), -abs(scope)..abs(scope)] , scaling =constrained,axes=none);
end proc:
geometry[ point] (v1 , 0 ,0):
geometry[ point] (a , 3, 9):
geometry[ point] (b , 7, 9):
geometry[ point] (c, 6,8):
geometry[ point] (d , 12,9):
geometry[ point] (e , 7 ,2):
geometry[ point] (v3 , 9 ,0):
vl:=[ v1,a,b,c,d,e,v3] :
drawarcs(vl,red,20);

try.mwtry.mw

The above program is too cumbersome and not robust

macro(GS=GetVertexPositions):
with(GraphTheory):
with(SpecialGraphs): 
G     := PetersenGraph():
POS := GetVertexPositions(G):
EG   := Edges(G) minus {{6,10},{6,7}}:
s1:=PLOT(
   seq( CURVES([POS[EG[i][1]], POS[EG[i][2]]], LINESTYLE(3) ), i=1..numelems(Edges(G))-2),
   POINTS(POS, SYMBOL(_SOLIDBOX, 35), COLOR(RGB, 1, 1, 0)),
   seq(TEXT(POS[i], i), i=1..numelems(Vertices(G))),
   AXESSTYLE(NONE)
):
geometry[ point] (a,op(GS(G)[6])):
geometry[ point] (b , op(GS(G)[7])):
geometry[ point] (c , op(GS(G)[10])):
geometry[ point] (d ,op(GS(G)[8])[1]+0.3,op(GS(G)[8])[2]-0.5):
geometry[ point] (d2 ,op(GS(G)[9])[1]-0.3,op(GS(G)[9])[2]-0.5):
s2:=drawarc(a,d,b,red):
s3:=drawarc(c,d2,a,red):
plots:-display({s1,s2,s3});

 

 

 

 

 

I know that the angle between two vectors u = (2, 1, 1) and v = (9, -1, 4) equal to 30 degree. How to find the some options of two vectors u = (a, b, c) and v = (x, y, z), where a, b, c, x, y, z are six integer numbers so that  the angle between two vectors u and v equal to 30 degree?

I'm adjusting a Maple 2015 code for it works correctly in Maple 2020.
A being some matrix, this command executed in Maple 2015 returns a plot with the desired color.

matrixplot(A, heights=histogram, color="X11 Thistle1")

When executed in Maple 2020 the color of the bars is desperatly black.
Note that syntaxes like color=red or color=ColorTools:-Color([1, 0, 0]), despite what seems to be said in the matrixplot help page (wherein the reference to plot:-color help page) keep returning a black plot.
The only thing I'm able to do to turn the plot to red is this

F := (x, y) -> 1:
matrixplot(A, heights=histogram, color=F)


How can I obtain a plot with the color I want?

PS: maybe I'm not very astute, but it looks like the help pages are not very explicit on this point.

Hello there, 

I would think that those two expressions are same as long as L::positive, omega::positive, R::positive, but when I tried in Maple, I could not get that result. The following worksheet shows my attempts. Would you please tell me how to get the answer, true, instead of false from the expression comparison?


 

restart:

arctan_expression := arctan(omega*L/R);

arctan(omega*L/R)

(1)

arctan_expression2 := arctan(R, L*omega);

arctan(R, L*omega)

(2)

evalb(arctan_expression = arctan_expression2) assuming L::positive, omega::positive, R::positive;

false

(3)

is(arctan_expression = arctan_expression2);

false

(4)

 


Best Regards, 

In Kwon Park 

Download Q20210308.mw

 

I needed to normalize the eigenvectors of a matrix. (I did not see an option to do this so far in LinearAlgebra). So I figured I just need to map LinearAlgebra:-VectorNorm(x,'Euclidean')  of each vector of the generated eigenvectors matrix,. Where here means the vector in the matrix. But do not see a way to do it. 

I ended up just using seq, which works fine. But was wondering if there is a way to do it? map function on each column (or each row) and have the result be matrix ofcourse. 

Will show my attempt using map, and then using seq

Sx:=1/sqrt(2)*Matrix([[0,1,0],[1,0,1],[0,1,0]]);
lam,v:=LinearAlgebra:-Eigenvectors(Sx);

Just doing the following does not work ofcourse

map( x->x/LinearAlgebra:-VectorNorm(x,'Euclidean'), v) 

So I used seq

Sx:=1/sqrt(2)*Matrix([[0,1,0],[1,0,1],[0,1,0]]);
lam,v:=LinearAlgebra:-Eigenvectors(Sx);
normalized:=[seq( v(..,i)/LinearAlgebra:-VectorNorm(v(..,i),'Euclidean'),i=1..LinearAlgebra:-RowDimension(v) )];

Will be nice if one can use map or variation of it, which works on either columns or rows at a time.

Maple 2021.2

I am doing some solution for pde :

restart;
with(PDEtools);
with(plots);
alias(u = u(x, y, t), w = w(x, y, t), f = f(w));
pde := diff(u, x, x, x, y) + 3*diff(u, y)*diff(u, x, x) + 3*diff(u, x)*diff(u, x, y) + 2*diff(u, y, t) = 0;
pde2 := subs(u = D(f)(w)*diff(w, x) + u0(x, y, t), pde);

pde3 := expand(pde2);


after this step i want to substitute 
D(f)(w)*D^(3)(f)(w)= (-c/3)*D^(4)(f)(w)

so i apllied command as this :

pde33 := subs({D(f)(w)*(D^(3)(f)(w) = -c/3*(D^(4)(f)(w)}, pde3);

but i not able to replace it !

please help in it ! Thanks!


 

PDE:

(a+b)*(uxx+vxy)+c*laplacian(u)=0

 

(a+b)*(vxy+vyy)+c*laplacian(v)=0

 

a,b,c=const.  Initial:u=1/2*sin(2*theta),v=cos(theta)

 

Text book says: Solve by complex variable method

First 14 15 16 17 18 19 20 Last Page 16 of 55