Maple 2020 Questions and Posts

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

Look at the following Maple code and output, from Maple 2020. Can you explain the results? I know returning an uninitiated local variable is bad practice, but I cannot make sense of what happens when I do it anyway (just to understand the internals of the Maple language). Should I simply consider the results as undefined behavior?

> f:=proc()                                                                    
>     local x;                                                                 
>     return x;                                                                
> end proc:                                     

> a1 := f() + f();                                                             
                                   a1 := 2 x

> a2 := f() - f();                                                             
                                  a2 := x - x

> a1 + a2;                                                                       
                                  2 x + x - x

> a3 := f() + f() + f();                                                       
                                   a3 := 3 x

> a4 := f() + f() + f() - f();                                                 
                                 a4 := 3 x - x

EssayTools command SpellCorrectWord("trnu") will return "run" and not return "turn".

Is there a way for Maple to only find anagrams with the same length as the given string?

Can Maple do this referencing an external dictionary located on the internet e.g. a complete Websters?

Hello,

HazardRate seems not to work for a convolution - it always returns zero.

restart;
with(plots);
with(Statistics);
X1 := RandomVariable(Uniform(0, 1));
X2 := RandomVariable(Uniform(0, 1));
HazardRate(1/2*X1 + 1/2*X2, 0.4); #returns zero
plot(HazardRate(1/2*X1 + 1/2*X2, t), t = 0 .. 0.9, legend = "Hazard Rate"); #plots zero
#writing hazard rate explicitly works fine
plot(PDF(1/2*X1 + 1/2*X2, t)/(1 - CDF(1/2*X1 + 1/2*X2, t)), t = 0 .. 0.9, legend = "Hazard Rate explicitly");

Thank you!

 

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.

4 5 6 7 8 9 10 Last Page 6 of 46