Kitonum

21435 Reputation

26 Badges

17 years, 23 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart:
CartProd:=proc(L::list({set,list}))
local n;
n:=nops(L);
if n=1 then return L[1] else
[seq(seq([op(p),l], l=L[n]), p=thisproc(L[1..n-1]))] fi;
end proc:


Examples of use:

CartProd([{a,b,c},{e,f}]);

CartProd([[0,1]$4]);

        [[a, e], [a, f], [b, e], [b, f], [c, e], [c, f]]

   [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 0, 1, 1], 

     [0, 1, 0, 0], [0, 1, 0, 1], [0, 1, 1, 0], [0, 1, 1, 1], 

     [1, 0, 0, 0], [1, 0, 0, 1], [1, 0, 1, 0], [1, 0, 1, 1], 

     [1, 1, 0, 0], [1, 1, 0, 1], [1, 1, 1, 0], [1, 1, 1, 1]]
 

Let us carry out the simplest qualitative analysis of the behavior of the roots of the equation  f(q)=0 . First of all, we note that since the function  f  is even, it is enough to consider only positive roots (for each root  q0 , the number  -q0  is also a root). Let us show that on any interval  (Pi/2+Pi*(n-1), Pi/2+Pi*n), where  n  is an integer and positive, equation  f(q)=0  has at least 1 root. This immediately implies that the equation has infinitely many roots.
At the ends of the above interval, the function takes negative values (for n > 2) and is continuous except for the only point  q  for which the condition  tan(q) - q = 0  is satisfied. At this point, the sign of the function necessarily changes from   to  . Hence the existence of the root. The figure below illustrates this behavior. The vertical red line is the vertical asymptote at the point  q  for which  tan(q) - q = 0  . The root itself  q0  will be extremely close to the right end of the interval (even for relatively small  n), but always less than this end:

limit(f(q), q=Pi/2+n*Pi)  assuming n::posint;
eval(%, n=4);
plot(f, Pi/2+3*Pi..Pi/2+4*Pi, color=red); 

                                                                  -4.*n^2-4.*n+29.24999998
                                                                            -50.75000002
                                                  


To find roots in any interval, we can use the  RootFinding:-Analytic  command with success, but each individual calculation must be performed in some interval  Pi/2+Pi*(n-1) .. Pi/2+Pi*n :

restart:
  with(RootFinding):
  a[1]:= .1093: k[3]:= 7.5*10^(-12): k[2]:= 3.8*10^(-12):
  d:= 0.2e-3: eta[1]:= 0.240e-1: alpha[2]:= -.1104:
  alpha[3]:= -0.1104e-2: eta[2]:= .1361: xi:= 1.219*10^(-6):
  alpha:= 1-alpha[3]^2/(a[1]*eta[1]): theta[0]:= 0.5e-1:
  Hc:= (Pi/d)*sqrt(k[2]/xi):
  H:= 5.5*Hc:
  lambda:= a[1]/(xi*H^2):
  f:= unapply((H/Hc)^2-4*q^2*(tan(q)-q/(1-alpha))/(Pi^2*(tan(q)-q)),q);

for n from 0 to 100 do
r:=Analytic(f(q), re=Pi/2+Pi*(n-1)..Pi/2+Pi*n, im=-1..1);
L[n]:=[n,r];
od:
L:=convert(L, list);

                       
L := [[-1], [0, 1.57942376642640], [1, 4.71262209961613], 

  [2, 7.85399406399405, 10.9955581135723], [3, 14.1371463457335], 

  [4, 17.2787394247345], [5, 20.4203335662126], 

  [6, 23.5619278325359], [7, 26.7035219764330], 

  [8, 29.8451159450471], [9, 32.9867097430933], 

  [10, 36.1283033908297], [11, 39.2698969105772], 

  [12, 42.4114903225772], [13, 45.5530836440255], 

  [14, 48.6946768891667], [15, 51.8362700696975], 

  [16, 54.9778631952095], [17, 58.1194562735900], 

  [18, 61.2610493113535], [19, 64.4026423139095], 

  [20, 67.5442352857770], [21, 70.6858282307535], 

  [22, 73.8274211520490], [23, 76.9690140523910], 

  [24, 80.1106069341120], [25, 83.2521997992155], 

  [26, 86.3937926494325], [27, 89.5353854862630], 

  [28, 92.6769783110160], [29, 95.8185711248365], 

  [30, 98.9601639287295], [31, 102.101756723583], 

  [32, 105.243349510183], [33, 108.384942289227], 

  [34, 111.526535061337], [35, 114.668127827068], 

  [36, 117.809720586919], [37, 120.951313341338], 

  [38, 124.092906090730], [39, 127.234498835458], 

  [40, 130.376091575855], [41, 133.517684312220], 

  [42, 136.659277044826], [43, 139.800869773923], 

  [44, 142.942462499739], [45, 146.084055222482], 

  [46, 149.225647942343], [47, 152.367240659499], 

  [48, 155.508833374111], [49, 158.650426086328], 

  [50, 161.792018796289], [51, 164.933611504120], 

  [52, 168.075204209940], [53, 171.216796913859], 

  [54, 174.358389615977], [55, 177.499982316390], 

  [56, 180.641575015186], [57, 183.783167712447], 

  [58, 186.924760408250], [59, 190.066353102666], 

  [60, 193.207945795763], [61, 196.349538487603], 

  [62, 199.491131178245], [63, 202.632723867744], 

  [64, 205.774316556153], [65, 208.915909243520], 

  [66, 212.057501929892], [67, 215.199094615311], 

  [68, 218.340687299818], [69, 221.482279983453], 

  [70, 224.623872666251], [71, 227.765465348247], 

  [72, 230.907058029473], [73, 234.048650709960], 

  [74, 237.190243389737], [75, 240.331836068833], 

  [76, 243.473428747273], [77, 246.615021425082], 

  [78, 249.756614102284], [79, 252.898206778902], 

  [80, 256.039799454956], [81, 259.181392130468], 

  [82, 262.322984805456], [83, 265.464577479940], 

  [84, 268.606170153936], [85, 271.747762827462], 

  [86, 274.889355500534], [87, 278.030948173166], 

  [88, 281.172540845375], [89, 284.314133517173], 

  [90, 287.455726188574], [91, 290.597318859591], 

  [92, 293.738911530236], [93, 296.880504200521], 

  [94, 300.022096870458], [95, 303.163689540056], 

  [96, 306.305282209327], [97, 309.446874878281], 

  [98, 312.588467546926], [99, 315.730060215272], 

  [100, 318.871652883328]]


We see that there are no roots in the interval  -Pi/2 .. Pi/2 , and in each subsequent interval there will be one root, except for the case  n=2 .

a-bar is an invalid name in Maple. See a fragment from help on ?names:

"A name in its simplest form is a letter followed by zero or more letters, digits, underscore characters (_) and question marks (?), with lowercase and uppercase letters distinct.  The maximum length of a name is system dependent. On 32-bit platforms, it is 268,435,439 characters; on 64-bit platforms, it is 34,359,738,335 characters.
There are two types of names: indexed names and symbols (non-indexed names)."

It's unclear why your copy of Maple isn't signaling an error.

In Maple 2018:

Using the triple integral, we find the first coordinate  x0  of the center of mass of this body (the second and third coordinates are equal to 0 due to symmetry), as well as the moment of inertia  J  for the axis of revolution through the center of mass and parallel to the y axis:

restart;
Eq:=x^2/3^2+y^2/2^2+z^2/1^2=1;
Sol_z:={solve(Eq, z)};
Sol_y:={solve(eval(Eq,z=0), y)};
x0:=int(x, [z=Sol_z[1]..Sol_z[2],y=Sol_y[1]..Sol_y[2], x=-2..1])/int(1, [z=Sol_z[1]..Sol_z[2],y=Sol_y[1]..Sol_y[2], x=-2..1]);
J:=int((x-x0)^2+z^2, [z=Sol_z[1]..Sol_z[2],y=Sol_y[1]..Sol_y[2], x=-2..1]);

                         

                  

In such examples, it is advisable to use functional notation, because we get a simpler and shorter code:

restart;
x:=t->2*a+b*t+2*t;
solve({x(0)=1, x(1)=1});

                                                    

 

with(Units:-Standard):
seq(ii*Unit('m'), ii = 1.0.. 10.0);

 

You can calculate the sum of this alternating number series with the  sum  command:

sum((-1)^(n-1)/(2*n-1), n=1..infinity);

                                                     

 

NULL

restart

with(LinearAlgebra)

F[1] := 1/2+(3/4)*x[0]*y[0]+x[0]+(3/8)*y[0]

1/2+(3/4)*x[0]*y[0]+x[0]+(3/8)*y[0]

(1)

F[2] := -1/2-(1/8)*x[0]^2+(5/8)*y[0]^2-(1/8)*x[0]+y[0]

-1/2-(1/8)*x[0]^2+(5/8)*y[0]^2-(1/8)*x[0]+y[0]

(2)

F[3] := 1/2+(3/4)*u[0]*z[0]+(3/8)*u[0]+x[0]

1/2+(3/4)*u[0]*z[0]+(3/8)*u[0]+x[0]

(3)

F[4] := -1/2+(5/8)*u[0]^2-(1/8)*z[0]^2+y[0]-(1/8)*z[0]

-1/2+(5/8)*u[0]^2-(1/8)*z[0]^2+y[0]-(1/8)*z[0]

(4)

Sol := {solve({F[1] = 0, F[2] = 0, F[3] = 0, F[4] = 0}, {u[0], x[0], y[0], z[0]}, explicit)}; nops(Sol); select(proc (t) options operator, arrow; `and`(`~`[type](eval([x[0], y[0], z[0], u[0]], t), realcons)[]) end proc, Sol)

16

 

{{u[0] = -4/5-(1/10)*139^(1/2), x[0] = -1/2, y[0] = -4/5-(1/10)*139^(1/2), z[0] = -1/2}, {u[0] = -4/5+(1/10)*139^(1/2), x[0] = -1/2, y[0] = -4/5+(1/10)*139^(1/2), z[0] = -1/2}, {u[0] = 4/5-(1/10)*139^(1/2), x[0] = -1/2, y[0] = -4/5+(1/10)*139^(1/2), z[0] = -1/2}, {u[0] = 4/5+(1/10)*139^(1/2), x[0] = -1/2, y[0] = -4/5-(1/10)*139^(1/2), z[0] = -1/2}}

(5)

nops(%)

4

(6)

 

Download roots_(1)_new.mw

To check whether a number is even or odd, you do not need any formula, just use the  type  command. If you want to check the terms in the sum, then the sum itself must be written in inert form, otherwise Maple will automatically calculate it and the terms themselves will be lost.

Examples:

restart;
a:=2%+3;
type(op(1,a),odd);
type(op(1,a),even);
type(op(2,a),odd);

                                                

restart;
k:=[seq(1.1..1.3, 0.1)];
plot([seq(x+i, i=k)], x=0..1);

 

By using the  limit  command (according to the definition of an improper integral), you can easily work around this bug:

restart;
int( exp(-2*r)*cos(theta)^3*r^2*sin(theta), phi=0..2*Pi, theta=0..Pi, r=0..R);
limit(%, R=infinity);

                                                     0
                                                     0

See help on the  LinearAlgebra:-MatrixFunction  command.

Example:

restart;
A:=Matrix([[1,2],[3,4]]);
LinearAlgebra:-MatrixFunction(A, sin(x), x);

 

@brian bovril  I completely redid my answer.
The code below returns all possible options where no player is in two matches in a row. The result is the same as Carl's, but the code does not use the Iterator package, so it is suitable for older versions of Maple:

restart:
TA := [A, B, C]:
TB := [X, Y, Z]:
n:=nops(TA):
L:=convert(Matrix(n, (i,j)->[TA[i],TB[j]])^%T, list):
P:=combinat:-permute(L):
k:=0:
for p in P do
if `and`(seq(nops({p[i][],p[i+1][]})=4, i=1..nops(L)-1)) then k:=k+1; 
print(p) fi;
od:
k;  

 

I don't have Maple 2021, but I'm using Maple 2018. In this version, for some reason, your code doesn't work. But the modified version works:

restart;
with(GraphTheory):
g:=[seq(CompleteGraph(i),i=2..6)]:
plots:-display(DrawGraph~(convert(g,Vector[row]), style=spring, stylesheet = [vertexcolor = "Pink"]), size=[200,200]);

 


 

restart

F := [.2169, .1929, .1688, .1448, .1207, 0.9672e-1, 0.7266e-1, 0.4861e-1, 0.245e-1]

[.2169, .1929, .1688, .1448, .1207, 0.9672e-1, 0.7266e-1, 0.4861e-1, 0.245e-1]

(1)

plot([seq(0 .. 1, 1/(nops(F)-1))], F, style = pointline, color = red, symbol = solidcircle, symbolsize = 12)

 

NULL


 

Download help_graph_new.mw

First 21 22 23 24 25 26 27 Last Page 23 of 289