Question: 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.

Can you please help me?

> 

#select greatest negative value from solution

> 

restart:

> 

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

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

(1)
> 

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

> 

plot(expr)

 
> 

 

> 

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

 

[]

(2)
> 

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]

(3)
> 

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

[false, true]

(4)
> 

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

> 

 

[2]

(5)
> 

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

> 

 

-.2688724573

(6)
> 

expr; #test

> 

 

0.

(7)
> 

 


Download select_solution.mw

Thanks!

Honigmelone

Please Wait...