3
$\begingroup$

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.

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

How about:

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – ssolver May 21 '14 at 7:28
  • $\begingroup$ 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. $\endgroup$ – ssolver May 21 '14 at 7:45
  • $\begingroup$ 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. $\endgroup$ – ssolver May 21 '14 at 8:12
  • $\begingroup$ @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. $\endgroup$ – Fred Kline May 21 '14 at 8:38
  • $\begingroup$ Hmm.. but i don't get any of these equation. it just evalutates the box, but doesn't give any output.. $\endgroup$ – ssolver May 21 '14 at 8:45
5
$\begingroup$

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}} *)
$\endgroup$
  • $\begingroup$ it's not possible to get values from within the range, just from it's max. and min. range values. $\endgroup$ – ssolver May 20 '14 at 22:10
  • $\begingroup$ 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. $\endgroup$ – ssolver May 21 '14 at 7:29
  • $\begingroup$ The other constraints already prevent it from becoming negative. Per computations above, it ranges from 0.456... to 6811.464... $\endgroup$ – Daniel Lichtblau May 21 '14 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.