## Loop over empty table...

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?

 (1)

a := 0;

 (2)

## How do I Int(pde) in Maple?...

Int(UxUxy+UxxUy, x)=UxUy

How can I do this?

## Detect and print the operating system....

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)

## count number of elements in SearchAll...

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

numelems apparently is not the right function.

 (1)

 (2)

 (3)

## Polynomials: How do I determine the linear factors...

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)

## Animated plots and efficiency...

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.

## Convert rational equations to polynomial ones...

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

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 .

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.

## Truncation in save...

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;
f(80):
length(%);  # 100  ???
```

## issue using simplify on result of integration in ...

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?

## Showing quadratic forms are nonnegative

by: Maple
 > 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;

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

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

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^+;

so we have

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

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

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;

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

 > solve(p1>=0);

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

 >

## Is there a more versatile way to draw the curve on...

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 :

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

## How to compute more than 33 terms for OEIS sequenc...

See A342180 in OEIS. Two codes have been written for this, one in Python (17 terms found), the other in Mathematica (33 terms). Could a Maple code go beyond a(33), assuming higher terms exist?

## How do I search for maxima on a polygon constraint...

So in multivariate calculus there is a function called Lagrange Multipliers that searches for maxima, minima and saddle points on a 3d surface with an algebraic as a constraint. I was wondering if there was a way to do something similar on a polygon constraint by feeding the corner points to a procedure and returning all extrema and saddle points? Ideas I've had so far is using the directional derivative on the corners in the direction towards the next corner and looking if it is bigger or equal than 0 if multiplied with the directional derivative towards the previous corner (if yes, extrema or saddle point, if no not) however this adresses only corners and there may be extrema on the lines between the corners too. What should I do for that?

## How to use modular arithmetic in Maple?...

Hi,

Is there a way to make all computations in Maple to run modulo specified prime p? If, for example, I want to use a function such as DifferentialAlgebra:-RosenfeldGroebner and force it to run its internal computations modulo p, can this be done?

So far I have tried to use GF(p, k), but there seem to be issues where `+` and other operations require defining all symbold via :-ConvertIn().

Thanks.

## RootOf interpretation...

I was hoping to find a nice symbolic solution for the root of this equation:

a,c,d,k are parameters.
Unfortunately, I got an RootOf expression, which does not make sense to me. Assumptions do no help me further.

Next week, I have to present my results, but I don't know how to interpret is (the help file does not bring any relief). Is there something to say about the root? Suppose, I wanted to use side restriction on a problem? E.g., find a solution conditional on the fact that the derivative is zero.

Clearly, in the plot it seems simple.

In one case there is a solution Maple provides: a  (a parameter)

This seems strange, because numerically there is one solution (and clearly not a).

 >
 >
 User Interface: 1502365          Kernel: 1502365         Library: 1502365
 (1)
 >
 (2)
 >
 >
 >
 >
 Originally a, renamed a~:   is assumed to be: RealRange(Open(0),infinity) Originally k, renamed k~:   is assumed to be: RealRange(Open(0),infinity) Originally t, renamed t~:   is assumed to be: RealRange(Open(0),Open(21))
 >
 (3)
 >
 (4)
 >
 (5)
 >
 (6)
 >
 (7)
 >
 (8)

Now, numerically:

 >
 (9)
 >
 (10)
 >
 >