# How to use NSolve while specifying the range of one variable

I have an equation that uses three variables that I have defined as follows: b[l_, m_, lt_] := 0.025 * (((1 - m)*l)^(-1/2))*((1 - m)*lt) - 5.

After this definition, I am attempting to solve this equation using NSolve --> NSolve[{b[l, m, lt] = 0}, {l, m, lt}, Reals].

This results in an error of NSolve: 3 is not a valid variable with an additional output of NSolve[{0, False}, {l, 3, lt}, Reals]. However, this is not a massive deal since the problem definition I am working with requires 0<=m<=1, which negates the issue of NSolve not working when m=3. The issue that I am running into is I cannot find a way in which to have the parameters of NSolve reflect the bounds that I want to place on m.

For instance, NSolve[{b[l, 0 <= m <= 1, lt] = 0}, {l, m, lt}, Reals] and NSolve[{b[l, m, lt] = 0, 0 <= m <= 1}, {l, m, lt}, Reals] both give the exact same error and result, while NSolve[{b[l, m, lt] = 0}, {l, 0 <= m <= 1, lt}, Reals] just gives me empty brackets.

Any suggestions on what my parameters should be? Thank you so much!

• better not use l as variable names, it looks like 1 which makes the code hard to read. Also, are you sure you want to write NSolve[{b[l, m, lt] = 0} instead of NSolve[{b[l, m, lt] == 0} ? Nov 6, 2021 at 4:48

Clear["Global*"]

b[l_, m_, lt_] := 1/40*(((1 - m)*l)^(-1/2))*((1 - m)*lt) - 5

sol = Solve[{b[l, m, lt] == 0, 0 <= m <= 1}, {l, m, lt}, Reals] //
Simplify Verifying,

Assuming[{l > 0, 0 <= m < 1}, b[l, m, lt] == 0 /. sol[] //
Simplify]

(* True *)


To find 10 instances

inst = FindInstance[{b[l, m, lt] == 0, 0 <= m < 1, l > 0},
{l, m, lt}, Reals, 10]

(* {{l -> 532, m -> 49/102, lt -> 400 Sqrt[13566/53]}, {l -> 638, m -> 0,
lt -> 200 Sqrt}, {l -> 663, m -> 89/102,
lt -> 10200 Sqrt}, {l -> 816, m -> 55/102,
lt -> 40800 Sqrt[2/47]}, {l -> 769, m -> 0,
lt -> 200 Sqrt}, {l -> 89, m -> 0,
lt -> 200 Sqrt}, {l -> 530, m -> 4/51,
lt -> 200 Sqrt[27030/47]}, {l -> 532, m -> 0,
lt -> 400 Sqrt}, {l -> 530, m -> 0,
lt -> 200 Sqrt}, {l -> 898, m -> 49/102,
lt -> 400 Sqrt[22899/53]}} *)


Verifying,

And @@ (b[l, m, lt] == 0 /. inst)

(* True *)


ContourPlot3D shows all solutions {m,l,lt}

ContourPlot3D[0 == 1/40*(((1 - m)*l)^(-1/2))*((1 -m)*lt) - 5, {m, 0, 1 }, {l, 0 , 10}, {lt, 0, 1000}, AxesLabel -> {"m", "l", "lt"}]
` 