Kitonum

21860 Reputation

26 Badges

17 years, 239 days

MaplePrimes Activity


These are replies submitted by Kitonum

@Markiyan Hirnyk

1. The inequality  (1/2)*(x-y)^2-(x-y)^4>=0  follows from the equation  (1/2)*(x-y)^2-(x-y)^4 = (-2*x^2+y^2)^2

2.  I also was solving it as  @_Maxim_   but in Maple 2016  I got this:

solve({y >= 4*x^4+4*x^2*y+1/2, (1/2)*(x-y)^2-(x-y)^4 = (-2*x^2+y^2)^2, -2*x^2+y^2>=0}, [x, y]);

                                                           [ ]

3. In any case, visualization is useful, since it allows you to test the correctness of the solution visually. You do not require Maple any proof! How do you know that the solution received is correct?

@Markiyan Hirnyk Yes you are right, I incorrectly determined those regions in which the solution is located. Here is the right picture:

A:=plots:-implicitplot([y = 4*x^4+4*x^2*y+1/2, (1/2)*(x-y)^2-(x-y)^4 = (-2*x^2+y^2)^2, -2*x^2+y^2=0], x=-3..3, y=-3..1, color=[red,blue, green], thickness=2, gridrefine=5):
B:=plots:-inequal({-2*x^2+y^2>=0, y>=4*x^4+4*x^2*y+1/2}, x=-3..3, y=-3..1, color="LightGreen"):
plots:-display(A, B, scaling=constrained);  

      

 

So the final result is 2 points:  [x = -1, y = -3/2], [x = 0, y = 1/2]

@Jason Lee  You wrote "...can u explain to me how to use implicitplot in Maple." Preben already showed how to use this command. I can only add that the roots of the system of equations are only the intersection points of curves corresponding to different equations of the system. Therefore, in the plot, you should use different colors for different curves:

eqn1:=-x*y^2+4*x=5;
eqn2:=(1/3)*x^3+y^2=1;

plots:-implicitplot([eqn1, eqn2], x=-10..10, y=-10..10, color=[red,blue], gridrefine=3);

                 

 

 

 

@MrYouMath  You did not copy, but just reprinted the code, because should be  symbol  instead of  symobl .

@MrYouMath  No, Maple does not understand such expressions as  {p__11,p__12,...p__1n, p__12,...,p__2n,...,p__1n,....,p__nn}. You must write this code in the form of a procedure

restart;
LyapunovEq:=proc(A::Matrix)
local n, P, Id, eqn;
uses LinearAlgebra:
n:=op([1,1], A);
P := Matrix(n, symbol=p);
Id := Matrix(n, shape=identity);
eqn := Transpose(A).P+P.A =~ -Id;
solve({seq(seq(eqn[i,j], j=1..n), i=1..n)}, indets(P));
end proc: 


Examples of use:

LyapunovEq(<1,2; 3,4>);
LyapunovEq(Matrix(3, symbol=a));


 

@Carl Love Yes, but a little later. I already wrote that this problem is only part of an entertaining problem. I prepare its complete solution  as a separate post, it remains to finish some details. My algorithm for selecting the corresponding matrices will simply be part of this post (not to repeat it twice).

@Carl Love  Thank you!

@Carl Love Thank you very much. Impressive method and its improvement in the comment "Under 1 second". Unfortunately, it seems to work only if each row and each column has exactly 2 zero or  2 units as in the original problem.

@vv Thank you. Unfortunately your code does not work on my computer for some reason:

Only with the option  compile=false  I get the result, but the time is 10 times longer.

When I wrote about my method for 100 seconds, I used another technique (uncompiled code). I'll submit this code later.

@tsunamiBTP  I did this and did not find any fundamental discrepancies. Some differences are due to the fact that in  M_new  I am greatly rounding the results (evalf[3]). For comparison, I calculated the hundredth line of my and your matrix. The graphs are indistinguishable. See untitled5_new2.mw

@John Fredsted  About this construction see Matrix and Vector Construction Shortcuts help page. By the same method, we can remove from a matrix any row or several rows or columns:

A:=LinearAlgebra:-RandomMatrix(6, generator=0..9);
A1:=<A[..3], A[5..]>;  
# 4th row deleted of A
A2:=<A[..,..4] | A[..,6]>;  
# 5th column deleted of A


I think this method is faster than calling  LinearAlgebra:-DeleteRow  or  LinearAlgebra:-DeleteColumn .

@tsunamiBTP  See corrected file  untitled5_new1.mw 

@tsunamiBTP  You wrote "This seems to work like a nested FOR loop". No, these are the different things. Here is a simple example of use nested seq. Let's say you want to create a matrix 10x10 that has symbols  x1, x2, ... ,x10  in the first line, the second line contains the same symbols, which squared, then cubed and so on:

Matrix([seq([seq((x||j)^i, j=1..10)], i=1..10)]);


Another example. It is very convenient and effective to use  seq  command  to obtain the sequence or list of objects with specified properties. In the example, we generate the sequence of Pythagorean triplets with  hypotenuses <=100:

seq(seq(seq(`if`(a^2+b^2=c^2,[a,b,c],NULL), b=a+1..c-1), a=1..c-2), c=3..100);

[3, 4, 5], [6, 8, 10], [5, 12, 13], [9, 12, 15], [8, 15, 17], [12, 16, 20], [7, 24, 25], [15, 20, 25], [10, 24, 26], [20, 21, 29], [18, 24, 30], [16, 30, 34], [21, 28, 35], [12, 35, 37], [15, 36, 39], [24, 32, 40], [9, 40, 41], [27, 36, 45], [14, 48, 50], [30, 40, 50], [24, 45, 51], [20, 48, 52], [28, 45, 53], [33, 44, 55], [40, 42, 58], [36, 48, 60], [11, 60, 61], [16, 63, 65], [25, 60, 65], [33, 56, 65], [39, 52, 65], [32, 60, 68], [42, 56, 70], [48, 55, 73], [24, 70, 74], [21, 72, 75], [45, 60, 75], [30, 72, 78], [48, 64, 80], [18, 80, 82], [13, 84, 85], [36, 77, 85], [40, 75, 85], [51, 68, 85], [60, 63, 87], [39, 80, 89], [54, 72, 90], [35, 84, 91], [57, 76, 95], [65, 72, 97], [28, 96, 100], [60, 80, 100]

 

@Markiyan Hirnyk  Here is a check (I just added a few commands to your document):


 

restart; ListTools:-FlattenOnce(convert(Vector(50, {(1) = 111111111111111111111111111111111111111111111111111111111111111111111111111111, (2) = 111111111111111111111111111111116000808880608061111111111111111111111111111111, (3) = 111111111111111111111111111866880886008008088868888011111111111111111111111111, (4) = 111111111111111111111116838888888801111111188006080011111111111111111111111111, (5) = 111111111111111111110808080811111111111111111111111118860111111111111111111111, (6) = 111111111111111110086688511111111111111111111111116688888108881111111111111111, (7) = 111111111111111868338111111111111111111111111111880806086100808811111111111111, (8) = 111111111111183880811111111111111111100111111888580808086111008881111111111111, (9) = 111111111111888081111111111111111111885811188805860686088111118338011111111111, (10) = 111111111188008111111111111111111111888888538888800806506111111158500111111111, (11) = 111111111883061111111111111111111116580088863600880868583111111118588811111111, (12) = 111111118688111111111001111111111116880850888608086855358611111111100381111111, (13) = 111111160831111111110880111111111118080883885568063880505511111111118088111111, (14) = 111111588811111111110668811111111180806800386888336868380511108011111006811111, (15) = 111111111088600008888688861111111108888088058008068608083888386111111108301111, (16) = 111116088088368860808880860311111885308508868888580808088088681111111118008111, (17) = 111111388068066883685808808331111808088883060606800883665806811111111116800111, (18) = 111581108058668300008500368880158086883888883888033038660608111111111111088811, (19) = 111838110833680088080888568608808808555608388853680880658501111111111111108011, (20) = 118008111186885080806603868808888008000008838085003008868011111111111111186801, (21) = 110881111110686850800888888886883863508088688508088886800111111111111111118881, (22) = 183081111111665080050688886656806600886800600858086008831111111111111111118881, (23) = 186581111111868888655008680368006880363850808888880088811111111111111111110831, (24) = 168881111118880838688806888806880885088808085888808086111111111111111111118831, (25) = 188011111008888800380808588808068083868005888800368806111111111111111111118081, (26) = 185311111111380883883650808658388860008086088088000868866808811111111111118881, (27) = 168511111111111180088888686580088855665668308888880588888508880800888111118001, (28) = 188081111111111111508888083688033588663803303686860808866088856886811111115061, (29) = 180801111111111111006880868608688080668888380580080880880668850088611111110801, (30) = 188301111111111110000608808088360888888308685380808868388008006088111111116851, (31) = 118001111111111188080580686868000800008680805008830088080808868008011111105001, (32) = 116800111111118888803380800830868365880080868666808680088685660038801111180881, (33) = 111808111111100888880808808660883885083083688883808008888888386880005011168511, (34) = 111688811111111188858888088808008608880856000805800838080080886088388801188811, (35) = 111138031111111111111110006500656686688085088088088850860088888530008888811111, (36) = 111106001111111111111111110606880688086888880306088008088806568000808508611111, (37) = 111118000111111111111111111133888000508586680858883868000008801111111111111111, (38) = 111111860311111111111111111108088888588688088036081111860803011111111863311111, (39) = 111111188881111111111111111100881111160386085000611111111888811111108833111111, (40) = 111111118888811111111111111608811111111188680866311111111111811111888861111111, (41) = 111111111688031111111111118808111111111111188860111111111111111118868811111111, (42) = 111111111118850811111111115861111111111111111888111111111111111080861111111111, (43) = 111111111111880881111111108051111111111111111136111111111111188608811111111111, (44) = 111111111111116830581111008011111111111111111118111111111116880601111111111111, (45) = 111111111111111183508811088111111111111111111111111111111088880111111111111111, (46) = 111111111111111111600010301111111111111111111111111111688685811111111111111111, (47) = 111111111111111111111110811801111111111111111111158808806881111111111111111111, (48) = 111111111111111111111181110888886886338888850880683580011111111111111111111111, (49) = 111111111111111111111111111008000856888888600886680111111111111111111111111111, (50) = 111111111111111111111111111111111111111111111111111111111111111111111111111111}), list))

[111111111111111111111111111111111111111111111111111111111111111111111111111111, 111111111111111111111111111111116000808880608061111111111111111111111111111111, 111111111111111111111111111866880886008008088868888011111111111111111111111111, 111111111111111111111116838888888801111111188006080011111111111111111111111111, 111111111111111111110808080811111111111111111111111118860111111111111111111111, 111111111111111110086688511111111111111111111111116688888108881111111111111111, 111111111111111868338111111111111111111111111111880806086100808811111111111111, 111111111111183880811111111111111111100111111888580808086111008881111111111111, 111111111111888081111111111111111111885811188805860686088111118338011111111111, 111111111188008111111111111111111111888888538888800806506111111158500111111111, 111111111883061111111111111111111116580088863600880868583111111118588811111111, 111111118688111111111001111111111116880850888608086855358611111111100381111111, 111111160831111111110880111111111118080883885568063880505511111111118088111111, 111111588811111111110668811111111180806800386888336868380511108011111006811111, 111111111088600008888688861111111108888088058008068608083888386111111108301111, 111116088088368860808880860311111885308508868888580808088088681111111118008111, 111111388068066883685808808331111808088883060606800883665806811111111116800111, 111581108058668300008500368880158086883888883888033038660608111111111111088811, 111838110833680088080888568608808808555608388853680880658501111111111111108011, 118008111186885080806603868808888008000008838085003008868011111111111111186801, 110881111110686850800888888886883863508088688508088886800111111111111111118881, 183081111111665080050688886656806600886800600858086008831111111111111111118881, 186581111111868888655008680368006880363850808888880088811111111111111111110831, 168881111118880838688806888806880885088808085888808086111111111111111111118831, 188011111008888800380808588808068083868005888800368806111111111111111111118081, 185311111111380883883650808658388860008086088088000868866808811111111111118881, 168511111111111180088888686580088855665668308888880588888508880800888111118001, 188081111111111111508888083688033588663803303686860808866088856886811111115061, 180801111111111111006880868608688080668888380580080880880668850088611111110801, 188301111111111110000608808088360888888308685380808868388008006088111111116851, 118001111111111188080580686868000800008680805008830088080808868008011111105001, 116800111111118888803380800830868365880080868666808680088685660038801111180881, 111808111111100888880808808660883885083083688883808008888888386880005011168511, 111688811111111188858888088808008608880856000805800838080080886088388801188811, 111138031111111111111110006500656686688085088088088850860088888530008888811111, 111106001111111111111111110606880688086888880306088008088806568000808508611111, 111118000111111111111111111133888000508586680858883868000008801111111111111111, 111111860311111111111111111108088888588688088036081111860803011111111863311111, 111111188881111111111111111100881111160386085000611111111888811111108833111111, 111111118888811111111111111608811111111188680866311111111111811111888861111111, 111111111688031111111111118808111111111111188860111111111111111118868811111111, 111111111118850811111111115861111111111111111888111111111111111080861111111111, 111111111111880881111111108051111111111111111136111111111111188608811111111111, 111111111111116830581111008011111111111111111118111111111116880601111111111111, 111111111111111183508811088111111111111111111111111111111088880111111111111111, 111111111111111111600010301111111111111111111111111111688685811111111111111111, 111111111111111111111110811801111111111111111111158808806881111111111111111111, 111111111111111111111181110888886886338888850880683580011111111111111111111111, 111111111111111111111111111008000856888888600886680111111111111111111111111111, 111111111111111111111111111111111111111111111111111111111111111111111111111111]

(1)

cat(%[]);

`111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111116000808880608061111111111111111111111111111111111111111111111111111111111866880886008008088868888011111111111111111111111111111111111111111111111116838888888801111111188006080011111111111111111111111111111111111111111111110808080811111111111111111111111118860111111111111111111111111111111111111110086688511111111111111111111111116688888108881111111111111111111111111111111868338111111111111111111111111111880806086100808811111111111111111111111111183880811111111111111111100111111888580808086111008881111111111111111111111111888081111111111111111111885811188805860686088111118338011111111111111111111188008111111111111111111111888888538888800806506111111158500111111111111111111883061111111111111111111116580088863600880868583111111118588811111111111111118688111111111001111111111116880850888608086855358611111111100381111111111111160831111111110880111111111118080883885568063880505511111111118088111111111111588811111111110668811111111180806800386888336868380511108011111006811111111111111088600008888688861111111108888088058008068608083888386111111108301111111116088088368860808880860311111885308508868888580808088088681111111118008111111111388068066883685808808331111808088883060606800883665806811111111116800111111581108058668300008500368880158086883888883888033038660608111111111111088811111838110833680088080888568608808808555608388853680880658501111111111111108011118008111186885080806603868808888008000008838085003008868011111111111111186801110881111110686850800888888886883863508088688508088886800111111111111111118881183081111111665080050688886656806600886800600858086008831111111111111111118881186581111111868888655008680368006880363850808888880088811111111111111111110831168881111118880838688806888806880885088808085888808086111111111111111111118831188011111008888800380808588808068083868005888800368806111111111111111111118081185311111111380883883650808658388860008086088088000868866808811111111111118881168511111111111180088888686580088855665668308888880588888508880800888111118001188081111111111111508888083688033588663803303686860808866088856886811111115061180801111111111111006880868608688080668888380580080880880668850088611111110801188301111111111110000608808088360888888308685380808868388008006088111111116851118001111111111188080580686868000800008680805008830088080808868008011111105001116800111111118888803380800830868365880080868666808680088685660038801111180881111808111111100888880808808660883885083083688883808008888888386880005011168511111688811111111188858888088808008608880856000805800838080080886088388801188811111138031111111111111110006500656686688085088088088850860088888530008888811111111106001111111111111111110606880688086888880306088008088806568000808508611111111118000111111111111111111133888000508586680858883868000008801111111111111111111111860311111111111111111108088888588688088036081111860803011111111863311111111111188881111111111111111100881111160386085000611111111888811111108833111111111111118888811111111111111608811111111188680866311111111111811111888861111111111111111688031111111111118808111111111111188860111111111111111118868811111111111111111118850811111111115861111111111111111888111111111111111080861111111111111111111111880881111111108051111111111111111136111111111111188608811111111111111111111111116830581111008011111111111111111118111111111116880601111111111111111111111111111183508811088111111111111111111111111111111088880111111111111111111111111111111111600010301111111111111111111111111111688685811111111111111111111111111111111111111110811801111111111111111111158808806881111111111111111111111111111111111111111181110888886886338888850880683580011111111111111111111111111111111111111111111111111008000856888888600886680111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111`

(2)

isprime(parse(%));

true

(3)

``


 

Download Check.mw

 

@mehdibaghaee Sorry, I did not notice the second condition.
Should be:

seq(`if`(V[i]>0 and V[i]<>infinity, [i, V[i]], NULL), i=1..10);

First 60 61 62 63 64 65 66 Last Page 62 of 134