0
$\begingroup$

Sometimes I will use an equation, for example, imagine the old chemistry ideal gas law, PV=nRT. Depending on the situation I may want to use different variables as the independent variable. So, for example, in the case of the ideal gas law there are 4 different possible independent variables.

What is a good way to manage this situation and set it up in Mathematica so I can easily compute any particular variable in terms of the others in a literate way?

$\endgroup$

closed as unclear what you're asking by chuy, Feyre, corey979, yohbs, MarcoB Jan 19 '17 at 19:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ V /. Solve[P V == n R T, V][[1]]? $\endgroup$ – Feyre Jan 19 '17 at 14:01
  • $\begingroup$ @Feyre I know I can repetitively solve the same equation over and over again. I am hoping there is a more elegant solution. $\endgroup$ – Tyler Durden Jan 19 '17 at 14:26
  • $\begingroup$ What kind of thing do you want? $\endgroup$ – Feyre Jan 19 '17 at 14:33
  • $\begingroup$ It is not quite clear what you're asking. Please elaborate by a specific example. In the meanwhile I'm voting to close this question. $\endgroup$ – yohbs Jan 19 '17 at 16:18
1
$\begingroup$
ClearAll[gasLaw];

gasLaw[var_Symbol, opts : OptionsPattern[]] := 
 Solve[P V == n R T, var, Reals, 
   FilterRules[{opts}, Options[Solve]]][[1]]

gasLaw[P]

(*  {P -> (n R T)/V}  *)

Flatten[gasLaw /@ Variables[Level[P V == n R T, {-1}]]]

(*  {n -> (P V)/(R T), P -> (n R T)/V, R -> (P V)/(n T), T -> (P V)/(n R),
  V -> (n R T)/P}  *)
$\endgroup$
0
$\begingroup$

Do you mean something like this ?

var = n;
Solve[P V == n R T, var]
$\endgroup$

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