# Solve within a range?

Is it possible to solve an equation in which some some of the parameters have defined ranges?

Example:

Solve[x^2 + 0.09149 x + 6.263*10^-6 + kp (10.95 x + 0.9574) == 0 &&
y^2 + 0.09149 y + 6.263*10^-6 + kp (10.95 y + 0.9574) == 0 &&
kp (10.95 z + 0.9574) == 0, {kp}]


where x < -4 and y < -5 and 0 > z > -5.

I am trying to solve for variable kp and would like to know how the value of kp differs for different values of x, y and z which is defined. X and y shall of course have some kind of max value for which it shall evaluate the solve function.

Ohh.. one important fact. Kp can't become negative. it's the main reason why i want to to solve it for for changing parameter defined within a range.

• No, expressions cannot be solved but equations sometimes... – Artes May 20 '14 at 10:02
• To make this question answerable, you should add example code to detail your problem. – Yves Klett May 20 '14 at 10:07
• I tried to make it more understandable?? – ssolver May 20 '14 at 17:29
• Not completely sure about the last paragraph, but perhaps the example will help to get an idea of what you are after. – Yves Klett May 20 '14 at 17:36
• It's an optimization question, more or less. Please reopen. – Daniel Lichtblau May 20 '14 at 17:44

Clear[x,y,z,kp];
Reduce[FullSimplify[
x < -4 && y < -5 && 0 > z > -5 &&
x^2 + 0.09149 x + 6.263*10^-6 + kp (10.95 x + 0.9574) == 0 &&
y^2 + 0.09149 y + 6.263*10^-6 + kp (10.95 y + 0.9574) == 0 &&
kp (10.95 z + 0.9574) == 0], {x, y, z, kp}]


to get:

x < -5. && y == x && z == -0.0874338 &&
kp == (-6263. - 9.149*10^7 x - 1.*10^9 x^2)/
(9.574*10^8 + 1.095*10^10 x)


and a plot:

Edit when Simplify instead of FullSimplify is used, we get a different kp:

x < -5. && y == x && z == -0.0874338 &&
kp == (-9.09542*10^15 - 1.32866*10^20 x - 1.45225*10^21 x^2)/(
1.39038*10^21 + 1.59021*10^22 x)


and the plot has a slightly different slope.

• Ohh.. one important fact. Kp can't become negative. it's the main reason why i want to to solve it for for changing parameter defined within a range. – ssolver May 21 '14 at 7:28
• But your solution seems to make it work..How did get the equation for kp, i have mutiple equations which i need this operation to be done.. so a method would be helpfull, your reduce function doesn't seem to give me the equation. – ssolver May 21 '14 at 7:45
• But those have multiple variables (kp,ki,kd) which I need to adjust for.. but using your method it looks like i am getting a function for ki which is dependent of kp, kp,ki and kd, shall only depend of the values of x,y and z. – ssolver May 21 '14 at 8:12
• @ssolver, I took your statement and added the conditions from the 'Where' and did the Reduce[FullSimplify which gave us the next box. The part to the right of kp== is what I plotted. – Fred Kline May 21 '14 at 8:38
• Hmm.. but i don't get any of these equation. it just evalutates the box, but doesn't give any output.. – ssolver May 21 '14 at 8:45

You can get the range of values by minimizing and maximizing kp with the specified constraints. Since the input is approximate Minimize will punt to NMinimize so what you see below is not a guaranteed result. All the same one can get a good idea of which bounds are tight and what is the range in question.

Minimize[{kp,
x^2 + 0.09149 x + 6.263*10^-6 + kp (10.95 x + 0.9574) == 0,
y^2 + 0.09149 y + 6.263*10^-6 + kp (10.95 y + 0.9574) == 0,
kp (10.95 z + 0.9574) == 0, x <= -4, y <= -5, 0 > z > -5}, {kp, x,
y, z}]

During evaluation of In[40]:= NMinimize::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations. >>

(* Out[40]= {0.456244070108, {kp -> 0.456244070108, x -> -4.99999977222,
y -> -5., z -> -0.0874337974049}} *)

Maximize[{kp,
x^2 + 0.09149 x + 6.263*10^-6 + kp (10.95 x + 0.9574) == 0,
y^2 + 0.09149 y + 6.263*10^-6 + kp (10.95 y + 0.9574) == 0,
kp (10.95 z + 0.9574) == 0, x <= -4, y <= -5, 0 > z > -5}, {kp, x,
y, z}]

(* Out[41]= {6811.46425441, {kp -> 6811.46425441, x -> -74585.537642,
y -> -74585.537642, z -> -0.0874337899543}} *)

• it's not possible to get values from within the range, just from it's max. and min. range values. – ssolver May 20 '14 at 22:10
• Ohh.. one important fact. Kp can't become negative. it's the main reason why i want to to solve it for for changing parameter defined within a range. – ssolver May 21 '14 at 7:29
• The other constraints already prevent it from becoming negative. Per computations above, it ranges from 0.456... to 6811.464... – Daniel Lichtblau May 21 '14 at 16:16