2
$\begingroup$

I have an equation and have defined all variables except one. One of the variables is a Range of numbers. I now want to solve for a specific value and was expecting result to also be a range of numbers - unfortunately this was not the case!

Here is a small piece of my code showing my problem:

ClearAll["Global`*"];
(*define known variables*)
rnc = 0
WRes = 10/1000
DRes  = 1/1000
VPE = 0
rho = 1000
r2  = Range[20/1000, 45/1000, 1/1000]
r1  = r2 - 10/1000
V2min = 3/1000/1000/1000
(*define target freq*)
ftarg = 25
omegtarg = ftarg*2*Pi
(*equation for frequency*)
o1targ = Sqrt[
2*(((V1min + V2min)/V1min) - 1)*
P/(rho*((r2 + rnc)^2 - (r1 + rnc + V2min (WRes*DRes) + 
       VPE/(WRes*DRes))^2))]
(*Solutions for V1min*)
V1range = V1min /. Solve[omegtarg == o1targ , V1min]

From this code all I'm getting is V1range = V1min?? The solve was working for me previously (though not for a range of values). I also tried to make omegtarg a range to match o1targ but this also gave me no luck.

any help is much appreciated! Thank you and regards, D

$\endgroup$
3
$\begingroup$
ClearAll["Global`*"];
(*define known variables*)
rnc = 0;
WRes = 10/1000;
DRes = 1/1000;
VPE = 0;
rho = 1000;

Leave r2 undefined until later

(* r2=Range[20/1000,45/1000,1/1000] *)

r1 = r2 - 10/1000;
V2min = 3/1000/1000/1000;
(*define target freq*)
ftarg = 25;
omegtarg = ftarg*2*Pi;
(*equation for frequency*)

o1targ = Sqrt[
    2*(((V1min + V2min)/V1min) - 1)*
     P/(rho*((r2 + rnc)^2 - (r1 + rnc + V2min (WRes*DRes) + 
             VPE/(WRes*DRes))^2))] // Simplify;

Define r2 as a Range

(*Solutions for V1min as a function of P*)

V1range = V1min /. Solve[omegtarg == o1targ, V1min][[1]] /. 
   r2 -> Range[20/1000, 45/1000, 1/1000];

V1range // N

(* {8.10569*10^-13 P, 7.59909*10^-13 P, 7.15208*10^-13 P, 6.75475*10^-13 P, 
 6.39923*10^-13 P, 6.07927*10^-13 P, 5.78978*10^-13 P, 5.52661*10^-13 P, 
 5.28632*10^-13 P, 5.06606*10^-13 P, 4.86342*10^-13 P, 4.67636*10^-13 P, 
 4.50316*10^-13 P, 4.34234*10^-13 P, 4.1926*10^-13 P, 4.05285*10^-13 P, 
 3.92211*10^-13 P, 3.79954*10^-13 P, 3.68441*10^-13 P, 3.57604*10^-13 P, 
 3.47387*10^-13 P, 3.37737*10^-13 P, 3.28609*10^-13 P, 3.19962*10^-13 P, 
 3.11757*10^-13 P, 3.03964*10^-13 P} *)

Or define r2 as an Interval

V1interval = 
  V1min /. Solve[omegtarg == o1targ, V1min][[1]] /. 
   r2 -> Interval[{20/1000, 45/1000}];

V1interval // N

(* P Interval[{3.03964*10^-13, 8.10569*10^-13}] *)
$\endgroup$
  • $\begingroup$ this worked exactly as needed - appreciate it and thank you! $\endgroup$ – DeltaJ Apr 17 '18 at 16:10

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.