2
$\begingroup$

I am exploring some of the functions involving units and formulas, and wondered how to input quantities if the variable has a subscript.

This works

FormulaData["NewtonsLawOfUniversalGravitation", 
 {"r" -> Quantity[12, "Meters"],
  QuantityVariable[Subscript["m", 1], "Mass"] -> 
   Quantity[12, "Kilograms"],
  QuantityVariable[Subscript["m", 2], "Mass"] -> 
   Quantity[12, "Kilograms"]
  }
 ]

But when I tried to evaluate using a subscripted m, it doesn't recognize the variable.

I checked the documentation and didn't see any examples with subscripted variables.

Any help with the proper way to work with these kinds of expressions would be appreciated.

$\endgroup$
0

1 Answer 1

3
$\begingroup$
formula = FormulaData["NewtonsLawOfUniversalGravitation"];

formula /. {
  QuantityVariable["r", "Distance"] -> Quantity[12, "Meters"],
  QuantityVariable[Subscript["m", 1], "Mass"] -> Quantity[12, "Kilograms"],
  QuantityVariable[Subscript["m", 2], "Mass"] -> Quantity[12, "Kilograms"]}

enter image description here

$\endgroup$

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.