Maple Questions and Posts

These are Posts and Questions associated with the product, Maple


 

restart

R := .46+9.1625*t^alpha/(GAMMA*(alpha+1))+8.8318*t^(2*alpha)/(GAMMA*(2*alpha+1))+11.6888*t^(3*alpha)/(GAMMA*(3*alpha+1));

.46+9.1625*t^alpha/(GAMMA*(alpha+1))+8.8318*t^(2*alpha)/(GAMMA*(2*alpha+1))+11.6888*t^(3*alpha)/(GAMMA*(3*alpha+1))

 

.32+0.9282e-1*t^alpha/(GAMMA*(alpha+1))+2.1126*t^(2*alpha)/(GAMMA*(2*alpha+1))+3.9028*t^(3*alpha)/(GAMMA*(3*alpha+1))

 

.52+0.569e-1*t^alpha/(GAMMA*(alpha+1))+0.243e-1*t^(2*alpha)/(GAMMA*(2*alpha+1))+1.3102*t^(3*alpha)/(GAMMA*(3*alpha+1))

 

.46+9.1625*t^alpha/(GAMMA*(alpha+1))+8.8137*t^(2*alpha)/(GAMMA*(2*alpha+1))+8.8450*t^(3*alpha)/(GAMMA*(3*alpha+1))

 

.32+0.9282e-1*t^alpha/(GAMMA*(alpha+1))+2.1126*t^(2*alpha)/(GAMMA*(2*alpha+1))+1.9472*t^(3*alpha)/(GAMMA*(3*alpha+1))

 

.46+0.569e-1*t^alpha/(GAMMA*(alpha+1))+0.243e-1*t^(2*alpha)/(GAMMA*(2*alpha+1))+.6551*t^(3*alpha)/(GAMMA*(3*alpha+1))

(1)

``


 

 

Given a list say

A=[1, 2,6,7,9,10,15,17]

 

If I give a=3 and b=5

I should get a sublist containing all elements from 3 to 5 in index

 

That is [6,7,9] sublist of the above list

 

Kind help 

I am writing a program that produces ball and stick images of raphs in 3D - hence in a box.  It works find (well, it takes a while) for graphs of a certain size, but when I want to double the length / width / height of the box, it produces an error message: "Plot internal error: unrecognized option Dag in Plot".  Of course, I have no option Dag in my code.  Any ideas?

Hi there.

I found some strange behavior of int function in document with using of Physics package in Maple 2021 in comparison with Maple 2020:

kerr.mw

Please look at that.

Thank you.

Here's another basic question in programming, sorry about that.

This little program does a loop over a table which was just created, and thus empty. As far as I can see the for - do loop goes through the loop at least once.

Is there a way to change the program, so that it doesn't go through the contents of the loop at all?


 

i := table()

table( [ ] )

(1)

NULL

a := 0;

0

1

1

numelems(i)

0

(2)

NULL


 

Download table_and_loop.mw

Int(UxUxy+UxxUy, x)=UxUy

How can I do this?

Is there a means of getting Maple to detect and print the operating system which it is being run on? Searching for this topic is awkward as it returns page after page of troubleshooting guides on how to get Maple running on different operating systems.

Conventionally in Bash I would use something like: echo $(uname)

Any idea how I can get the number of elements in an exprseq after a SearchAll command?

numelems apparently is not the right function.


 

with(StringTools)

a := "tre - tre - tre"

"tre - tre - tre"

(1)

b := SearchAll("-", a)

5, 11

(2)

whattype(b)

exprseq

(3)

numelems(b)

Error, invalid input: numelems expects 1 argument, but received 2

 

``


 

Download numelems.mw

Show that x-2 is a factor of p(x)=x^3+3x^2-4x-12

I)determine all the linear factors of p(x)

ii)what are the zeros of y=p(x)

iii)sketch function y=p(x)

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.

Suppose I have one or more equations in the variables x[1] , ..., x[n], where each equation is a linear combination of rational functions in x[1] , ..., x[n]. For example, one equation might be:

(a*x[1]+b*x[2])/x[3] + c * x[1]^2 / ( d + e*x[2]) = f

Any such equation can be turned into a polynomial by multiplying both sides by the products of all the denominators. In the example, this would be x[3]( e*x[2] + d ).

My question is whether there is a Maple command to do this automatically? This would be helpful as I have a large number of equations.

I seem to remember that the save command had a bug about truncating big integers, and it was solved.
But now (Maple 2020) it is present again.
I wonder whether it is present in Maple 2021 too.

restart;
fname:="d:/tmp/ftest.mpl":
f:=proc(n)
  local i,k;
  for i to n do f(i):=parse(cat("", seq(k mod 10, k=1..10*i))) od;
  f(n);
end:

f(80):
length(%);  # 800, ok
save f, fname;
f:='f':
#restart;
read fname:
f(80):
length(%);  # 100  ???

 

In Maple 2021

restart;
B:=sqrt( (-4*u^(1/3)+1)*u^(4/3));
A:=1/(-12*u+3*u^(2/3)-3*B);
res:=int(A,u);
simplify(res)

This is one of the integrals, that in Maple 2020 did not handle. In Maple 2020, it gives this

restart;
B:=sqrt( (-4*u^(1/3)+1)*u^(4/3));
A:=1/( -12*u+ 3*u^(2/3)-3*B);
res:=int(A,u);

The difference is that in Maple 2021 int is able to solve this (but gives very long output which I will not post here). The problem is now simplify() gives an error on the result. I was trying to see if possible to obtain the same small result as Mathematica's after simplifying. Here is Mathematica's result

ClearAll[u];
B = Sqrt[(-4*u^(1/3) + 1)*u^(4/3)];
A = 1/(-12*u + 3*u^(2/3) - 3*B);
res = Integrate[A, u]

It is good that Maple can solve this integral, but why simplify gives error on the result? Is there a workaround?

 

restart;

with(LinearAlgebra):

Recently @Nour asked (in part) if Maple can simplify 2*(x^2 - x*y - x*z + y^2) to (x - y)^2 + (y - z)^2 + (z - x)^2. User @vv pointed out that a sum of squares form is not unique. I'm not sure if @Nour's intent was to show that this was always non-negative, but even if the sum of squares form is not unique, it does help to demonstrate that the expression will be nonnegative for all real x,y,z. This reminded me that I have over the years had cases where I wanted to know if a quadratic form (multivariate polynomial with all terms of degree 2) would always be non-negative (a quadratic form will be zero if all variables are zero, so we know it won't always be positive). I have typically done this by hand in the following way, which I demonstrate for the simpler case

p1:=2*x^2-3*x*y+4*y^2;

2*x^2-3*x*y+4*y^2

We make a (column) vector of the variables, v = [x,y] and then construct the symmetric Matrix A for which Transpose(v).A.v is the required expression. For the squared term 2*x^2, the coefficient 2 is put in the diagonal entry A[1,1] and likewise 4*y^2 leads to A[2,2] = 4. The term -3*x*y comes from the sum A[1,2]+A[2,1] and so half of the coefficient -3 goes to each of A[2,1] and A[1,2]. The Matrix is therefore

A:=Matrix(2,2,[2,-3/2,-3/2,4]);v:=Vector([x,y]):simplify(v^+.A.v);

A := Matrix(2, 2, {(1, 1) = 2, (1, 2) = -3/2, (2, 1) = -3/2, (2, 2) = 4})

2*x^2-3*x*y+4*y^2

The Matrix is found to be positive definite (positive eigenvalues), which means that the quadratic form is positive for all non-zero real vectors v.

IsDefinite(A,query='positive_definite');evalf(Eigenvalues(A));

true

Vector[column]([[4.802775638], [1.197224362]])

One way to get the sum of squares form is to use the Cholesky decomposition (for positive definite or semidefinite matrices), which yields A = L.Transpose(L) = L.I.Transpose(L), and then note that Transpose(L).v is a change of variables to a diagonal quadratic form

L:=LUDecomposition(A,method='Cholesky');
L.L^+;

L := Matrix(2, 2, {(1, 1) = 2^(1/2), (2, 1) = -(3/4)*2^(1/2), (2, 2) = (1/4)*46^(1/2)}, storage = triangular[lower], shape = [triangular[lower]])

Matrix([[2, -3/2], [-3/2, 4]])

so we have

v2:=L^+.v;
v2^+.v2;
map(simplify,%);

v2 := Vector(2, {(1) = 2^(1/2)*x-(3/4)*2^(1/2)*y, (2) = (1/4)*46^(1/2)*y})

(2^(1/2)*x-(3/4)*2^(1/2)*y)^2+(23/8)*y^2

(1/8)*(4*x-3*y)^2+(23/8)*y^2

and we have rewritten the quadratic form in an explicitly nonnegative form.

 

Another way to the sum of squares would be via the othogonal similarity A = U.Lambda.Transpose(U), where U is an orthogonal matrix of eigenvectors and Lambda is diagonal with eigenvalues on the diagonal. This form works even if the matrix is not positive (semi)definite.

 

In this simple case, Maple has some other ways of showing that the quadratic form is non-negative for real x,y

Student[Precalculus]:-CompleteSquare(p1,x);

2*(x-(3/4)*y)^2+(23/8)*y^2

Without assumptions, is correctly decides p1 is not always nonnegative, and an example of this for complex x and y is easily found. With assumptions, is fails.

is(p1,nonnegative);
eval(p1,{x=I,y=I});
is(p1,nonnegative) assuming real;

false

-3

FAIL

At least in Maple 2017, solve suggests any x and y will do, which is not quite right

solve(p1>=0);

{x = x, y = y}

In the next worksheet, I implement this method in a general procedure IsQformNonNeg, which works as well as IsDefinite does. For most cases of interest (integer or rational coefficients) there are no problems. For floating point coefficients, as always, numerical roundoff issues arise, and I dealt with this by giving warnings. (Rank is more robust in these cases than IsDefinite, but since this case can be better dealt with by converting floats to rationals, I haven't worked too hard on this - perhaps IsDefinite will be improved.)

 

The original example 2*(x^2 - x*y - x*z + y^2)  is dealt with as an example in the next worksheet

 

 

Download QformPost.mw

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});

 

 

 

 

 

First 304 305 306 307 308 309 310 Last Page 306 of 2097