Kitonum

21665 Reputation

26 Badges

17 years, 181 days

MaplePrimes Activity


These are replies submitted by Kitonum

@Joe Riel  The useful comment. I'm sure for a smaller number of vectors, the corresponding condition should be imposed on the rank. 

Now I don’t have time to understand your code in detail (maybe this evening), but two errors immediately catch my eye:

1. Vertices must be specified in a single list (not a sequence), that is should be  [[2.5, 21], [6, 13.5], [8, 10], [11, 24.5], [14.3, 19.4], [16.8, 26], [22, 21.5], [22, 17], [22.2, 12.5], [26.8, 23], [28, 20.5], [30, 25.5], [32, 21], [29.5, 16]].

2. Distance  command does not do what you want.

3. I do not see where  GraphTheory package is called. This is usually done using  uses  option in the procedure body.


Earlier, I solved your problem. See this thread

 

@bliengme After your response, I, like Joe, also stopped understanding what you want.

I saw acer's answer already after I sent my own. For positive numbers, our answers are the same, but for negative non-integer numbers, the answers are different, as  trunc  command rounds in the direction to  0 . But OP wrote "How to find the integer that is less than and closest to a real number" .

@JSalisbury  If you want to get a plot of dependence  t  against  thetabn  given by the equation  s , just use  plots:-implicitplot  command:

restart;
v := 145000;
thetavn := (1/6)*Pi;
omegac := 1/10;
s := v*cos(thetavn)*t*(cos(2*thetabn)*tan(thetabn)+sin(2*thetabn)*sin(omegac*t)/(omegac*t));
plots:-implicitplot(s=0, thetabn=0..88*Pi*(1/180), t=-200..200, tickmarks=["piticks", "decimalticks"], gridrefine=4, size=[800,600]
);

Your code does not work because  solve  command simply cannot solve this transcendental equation  s=0  explicitly.

I did not find any options in  Optimization  package  that would allow to find more than one solution. But with one solution can meet problems. There is a bug in  Optimization:-LPSolve  (with  integer  option)  that is still not fixed. Here is a toy example (in Maple 2018.2):

restart;
Optimization:-LPSolve(x+y, {x+y<= 1}, assume = {integer, nonnegative}, maximize);
 
Warning, problem appears to be unbounded
                         [0, [x = 0, y = 0]]


But there is a workaround:
restart;
Digits:=20:
Optimization:-LPSolve(x+y, {x+y<= 1}, assume = {integer, nonnegative},maximize);
                           
 [1, [x = 1, y = 0]]


Submit your specific problem here in text form (not in the form of a picture). Maybe someone will be able to find another solution method that allows you to find all the solutions.

@vv  Thanks for this - vote up. A recursion here is more effective than a direct reproduction of lists using the method of branches and borders (in my procedure).

However, these two procedures ( Partition  and  P ) are not equivalent. The procedure  Partition  solves a larger range of tasks due to the presence of additional options.

@Carl Love  Thanks for the useful information. I previously just did not have to use ListTools:-Classify command.

@Carl Love We can use the  Partition  procedure from  here  instead.

Example:

Partition(7, 3);
                         
  [[1, 1, 5], [1, 2, 4], [1, 3, 3], [2, 2, 3]]


Edit.  Partition procedure is quite effective. For example,

Partition(100, 5); 

will be significantly faster than

sort~(combinat:-composition(100, 5));
 

@bliengme   Copy  ?simplify/siderels  into your worksheet, and press enter key .

@mehdi jafari 

ListTools:-Collect([1,1,5]);
                                             
 [[1, 2], [5, 1]]

@bliengme   See help on  ?simplify/siderels

@dreux  In Maple 2017.3 your code works properly.

  

@minhthien2016 

map(p->Vertices(op(p),-20..20), [[[2, 5], [4, 3]], [[2, 5], [4, 9]], [[2, 6], [4, 8]], [[2, 7], [4, 3]], [[2, 7], [4, 5]], [[2, 7], [4, 9]]]);

@minhthien2016  For ease of use, I completely rewrote the code as a procedure. Formal parameters: Vc is the list of coordinates of the centroid, Vo is the list of coordinates of the orthocenter, R is the range in which the coordinates of the triangle's vertices change.

restart:
Vertices:=proc(Vc::list,Vo::list,R::range)
local x, y, sol, Sol, n, k1, k2, x1, x2, y1, y2, x3, y3, L;
sol:=solve({(x3-x2)*(x-x1)+(y3-y2)*(y-y1)=0, (x2-x1)*(x-x3)+(y2-y1)*(y-y3)=0}, {x,y});
Sol:=eval([x,y], sol);
L:=table();
n:=0;
k1:=lhs(R);  k2:=rhs(R);
for x1 from k1 to k2 do
for x2 from k1 to k2 do
for y1 from k1 to k2 do
for y2 from k1 to k2 do
x3:=3*Vc[1]-x1-x2; y3:=3*Vc[2]-y1-y2;
if x2*y3-x1*y3+x1*y2-y2*x3+y1*x3-y1*x2<>0 and eval(Sol)=Vo then
n:=n+1; L[n]:={[x1,y1], [x2,y2], [x3,y3]} fi;
od: od: od: od:
L:=convert(L, set);
nops(L), L;
end proc:


Example of use (your example):

Vertices([2,5], [4,3], -20..20);     


 

First 39 40 41 42 43 44 45 Last Page 41 of 133