Items tagged with select



In view of the worksheet:

What I need is
a) a better way to display the Tour_Distances (from 1 to M) and
b) a way to select tour elements where each component is <= to a specified distance (say <=H) and the corresponding tour(s) (from Tour2).

I want to solve for the roots of a polynomial, such as a x^2+b x + c = 0, for which the output is only the positive root. All coefficients/variables in the polynomial are positive. 

Recently, someone posted an answer to a question where at some point they performed this task and their solution was really slick. But I can't find it. The answer used either solve, or eval or something like that. (Yes, I did perform a search via the MaplePrimes search before asking this question.) 


Let L = {a1, a2, ..., an} (or L = [a1, a2, ..., an]) with is homogeneous polynomial. How to create function createDegree() return elements of degree <= n from L.

Expamle. L = {a-2b, b^2, (a+c)^2}.

createDegree(L,1) return {a - 2b}.

createDegree(L,2) return {b^2, (a - 2b)^2, (a+c)^2, a - 2b}.

createDegree(L,3) return {b^2, (a - 2b)^2, (a - 2b)^3, (a+c)^2, (a - 2b)b^2, (a - 2b)(a+c)^2, a - 2b}.

Thanks you very much.



Dear Friends, 

I would appreciate your help in resolving some issues. Let me describe my dummy code and the issues I am having. 

1. I have two functions f(x,a) and g(x,a) are well defined. 

2. I need to get roots of f(x,a). I am using the command soln := Roots(f(x,a)) which gives me a list of all possible values of x. 

3. I need to choose only one element -- say x* -- from the list "soln" such that x*=argmax{g(x,a) | g(x,a)>0 for x in soln}.

I am not able to find a technique (i) to evaluate g(x,a) for all elements of the list "soln", (ii) and select x* that maximizes g(x,a). 

Picking and choosing elements of the list one by one is difficult since the number of elements in the list can vary with parameter "a" and it would complicate the matter in numerical studies. 

I would sincerely appreciate any inputs in this regard. 

Thank you,




Unfortunately I got stuck again when trying to work with monomials.  Consider the following set of set of monomials:

f := [theta[1]*y+theta[2]*z,theta[3]+theta[4]*x+theta[5]*y+theta[6]*z+theta[7]*x*y+theta[8]*x*z+theta[9]*y*z,theta[10]*x+theta[11]*y+theta[12]*z+theta[14]*x*y+theta[15]*x*z+theta[16]*y*z+theta[17]*x^2+theta[18]*y*y+theta[19]*z*z+theta[20]];


x, y and z are the variables and thetas are the coefficients.  The coefficients theta can be zero and I need to classify the resulting set as valid or not.   Here are some examples of not valid sets



fffff :=[theta[1]*y+theta[2]*z,theta[3]+theta[4]*x+theta[5]*y+theta[6]*z+theta[7]*x*y+theta[8]*x*z+theta[9]*y*z,theta[12]*z+theta[19]*z*z+theta[20]];

that is, the first coordinate of the set cannot be a function of x alone, the second coordinate cannot be a function of y alone and the third coordinate cannot be a function of z only.  


I could not figure out how to do that automatically, can you help me, please?


Many thanks.





I want to solve this equation and looking at the plot there are at least 3 solutions. I want the greatest/smallest negative solution. Unfortunately using solve with assumptions produces no results and solve without assumptions only finds two solutions.

Can you please help me?

#select greatest negative value from solution


expr:= ax*cos(lambda)+ay*sin(lambda)-(a+b*lambda)



ax:=1:ay:=2:a:=0.5:b:=0.25: #examplanatory values




assume(-2*Pi<lambda,lambda<0): #does not work


sol_lambda:=[solve(expr=0,lambda, useassumptions)];# returns empty list even though without assumption one solution is found

Warning, solutions may have been lost




sol_lambda:=[solve(expr=0,lambda)]; #returns only two solutions even though looking at the plot 3 are there

Warning, solve may be ignoring assumptions on the input variables.


Warning, solutions may have been lost


[2.190357220, -.2688724573]


sol_l_v:=evalb~(sol_lambda<~0); #dirty workaraound

[false, true]


sol_l_add:=[ListTools:-SearchAll(true,sol_l_v)] ; #this seems overly complicated




lambda:=sol_lambda[sol_l_add[-1]];  #to select the last entry




expr; #test








I want to separate strings into substrings for example
input is "6,3,A,n,k,L,+,-" then the procedure breaks this string into substrings like 
if a member numeric b:="6,3",or if lowercase c:="n", if uppercase l:="A,L" else m:="+,-"

[Here's the original Question, restored as best I could.--Carl Love]

restart; with(GroupTheory)


d := Perm([[1, 2, 3, 4, 5]]);

Perm([[1, 2, 3, 4, 5]])


Perm([[1, 3], [4, 6], [5, 7]])


G := PermutationGroup({d, e});

GroupTheory:-PermutationGroup({thismodule, object}, )


H := Elements(G):


Error, invalid operator parameter name







[The question was, of course, How to avoid the error?--Carl Love]

Download subgrouplattice_(1).mw i can chose a minimum and positive answer of different answer in solve rule...

my program attached below.for example at this , the second answer should be selected as 1.965392881*10^9 ,that is the minimum and posetive among other...

thanks alot

loock i have 3 models and a Matrix

so i apply a command named DataFit and it gives me 

and that throws
the variable that i care about is g[1] so every 3 models have differents g[1] so i need to pick the smallest g[1] and then use his model.


>plots:-display(plot(m3, style = point, symbol = diamond, symbolsize = 9), plot(eval("MODEL THAT SHOULD BE PLOT", THE G[2] OF THE MODEL), x = 0 .. 27, color = black));

The right one here would be 

>plots:-display(plot(m3, style = point, symbol = diamond, symbolsize = 9), plot(eval(model[3], G[2]), x = 0 .. 27, color = black));

so how do i select the model[3] for my plot? i knnow how the eval works so the problem here is to pick the right model please Help i hope that i isn't that Hard thnx

Page 1 of 1