5
$\begingroup$

I wanted to use the formulas for KineticEnergy and KineticEnergyRelativistic with specific quantity vaules. The later formula does not work as I expected.

First, the KineticEnergy formula:

FormulaData["KineticEnergy"]

KE formula

Specifying quantity values per the documentation works as expected:

FormulaData["KineticEnergy", {"m" -> Quantity[64.8*^-6, "Kilograms"], "v" -> Quantity[0.2, "SpeedOfLight"]}]

KE formula with values

Now, the KineticEnergyRelativistic part:

keRelFD = FormulaData["KineticEnergyRelativistic"]

KE Rel formula

Again, specifying values:

FormulaData["KineticEnergyRelativistic", {"m" -> Quantity[64.8*^-6, "Kilograms"], "v" -> Quantity[0.2, "SpeedOfLight"]}]

KE Rel values 1

When I looked at the result that occurs for a symbolic quantity for the QuantityVariable, v, I see more details about the problem and possibly why the previous result returned False.

FormulaData["KineticEnergyRelativistic", {"m" -> Quantity[64.8*^-6, "Kilograms"], "v" -> Quantity[v, "Meters"/"Seconds"]}]

KE Rel values 2

The only way I found to get around this issue it to use apply a rule to the 2nd part of previous result:

FormulaData["KineticEnergyRelativistic", {"m" -> Quantity[64.8*^-6, "Kilograms"], "v" -> Quantity[v, "Meters"/"Seconds"]}][[2]] /. v -> QuantityMagnitude[UnitConvert[Quantity[0.2, "SpeedOfLight"]]]

KE Rel values 3

While this works, it seems a bit clunky. Does anyone have any idea of how to do this in a way that works like it did for KineticEnergy?

I'm running Mathematica 11 on Win 10.

$\endgroup$
  • $\begingroup$ FormulaData[ "KineticEnergyRelativistic", {"m" -> Quantity[64.8*^-6, "Kilograms"], "v" -> Quantity[v, "SpeedOfLight"]}] /. {v -> 0.2} works too. Btw. I guess you edited-out the second part after && in your final screenshot? $\endgroup$ – masterxilo Aug 31 '16 at 1:24
  • $\begingroup$ Probably you discovered a bug, report it. $\endgroup$ – masterxilo Aug 31 '16 at 1:30
  • $\begingroup$ @masterxilo, it probably looks like I edited the && out, but I didn't intend to edit it out. If you look closely, I take the 2nd part of the formula result like so FormulaData[ "KineticEnergyRelativistic", {"m" -> Quantity[64.8*^-6, "Kilograms"], "v" -> Quantity[v, "Meters"/"Seconds"]}][[2]] /. v -> QuantityMagnitude[UnitConvert[Quantity[0.2, "SpeedOfLight"]]]. $\endgroup$ – david Aug 31 '16 at 5:39
  • $\begingroup$ Ah, it's just missing the part selection in the code you posted. $\endgroup$ – masterxilo Aug 31 '16 at 10:33
  • $\begingroup$ @masterxilo, I guess I left that out my original post. Sorry about that. I've edited to fix it. And, I guess I'll report this issue to WRI. $\endgroup$ – david Aug 31 '16 at 13:50

Your Answer

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

Browse other questions tagged or ask your own question.