## How to use Select...

Experts.

In view of the worksheet:

VRP_permute.mw

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

## Slick technique to select positive root of polynom...

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

## Roots, lists and substitute...

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,

Omkar

## How to select monomials based on a rule?...

Hello

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

fff:=[theta[1]*y+theta[2]*z,theta[5]*y,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]];

ffff:=[theta[1]*y+theta[2]*z,theta[5],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]];

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.

## How to specify solution range for solve...

Hey,

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.

 > #select greatest negative value from solution
 > restart:
 > expr:= ax*cos(lambda)+ay*sin(lambda)-(a+b*lambda)
 (1)
 > ax:=1:ay:=2:a:=0.5:b:=0.25: #examplanatory values
 > plot(expr)
 >
 > assume(-2*Pi
 >
 > sol_lambda:=[solve(expr=0,lambda, useassumptions)];# returns empty list even though without assumption one solution is found
 (2)
 > sol_lambda:=[solve(expr=0,lambda)]; #returns only two solutions even though looking at the plot 3 are there
 (3)
 > sol_l_v:=evalb~(sol_lambda<~0); #dirty workaraound
 (4)
 > sol_l_add:=[ListTools:-SearchAll(true,sol_l_v)] ; #this seems overly complicated
 >
 (5)
 > lambda:=sol_lambda[sol_l_add[-1]];  #to select the last entry
 >
 (6)
 > expr; #test
 >
 (7)
 >

Thanks!

Honigmelone

## Make Maple touch friendly!

If you try and scroll a page up or down, it just selects the content.  How hard would it be to fix this?

## How to split string by types?...

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:="+,-"
thanks

## How to use the select command? ...

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

 >
 >
 >
 (1)
 >
 (2)
 >
 >
 >

 >

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

## How to select minimal positive solution?...

hi.how 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

11.mw

## Find position of positive elements from a list...

Given a list I would like to find the position of the positive numbers. Ex: Given L:=[3,8,-5,1,-3,-7], I would like to have as a result P:=[1,2,4].

I want to avoid using a loop for this. Any suggestion?

## Picking the right model by min...

loock i have 3 models and a Matrix
>m3:=importmatrix("loslobos.txt");
>model[1]:=a*x;
>model[2]:=a^2*x+b;
>model[3]:=C-x^2+a;

so i apply a command named DataFit and it gives me
>g:=Datafit(matrix,model[1]);

and that throws
g:=[3,[a:=5],33];
so
>g[1];
3
>g[2];
5
>g[3];
33
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.
Example:=
>g:=Datafit(matrix,model[1]);
g:=[3,[a:=5],33];
>gg:=Datafit(matrix,model[2]);
gg:=[10,[a:=5,b:=10],44];
>G:=Datafit(matrix,model[3]);
G:=[1.1,[C:=5,a:=2],88];

then

>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