I created two variables l and v and want to create l2 variable from LengthContractionRelativistic formula
l=Quantity[1,"Meters"]
v=Quantity[0.5, "SpeedOfLight"]
l2=FormulaData["LengthContractionRelativistic", {"v" ->Subscript["l",0]}]
It create l2 like next l==0.866025m but I want create l2 like 0.866025m to use it in expression l3=l2+Quantity[2,"Meters"] and so on.
How to assign l2 = 0.866025m by using LengthContractionRelativistic formula?
sghuisman
(Sander Huisman)
March 13, 2017, 12:24pm
2
You’re left with an equation, albeit a very simple one, use Solve to solve the equation, substitute the solution, and set it to l :
l2 = l /. First[Solve[l2, l]]
Your answer is not correct. I find next topic Formula Manipulation—Wolfram Documentation where in section Extracting Parts of Formulas is link to Part: Get a specified piece of an expression—Wolfram Documentation
So correct answer is
l2=FormulaData["LengthContractionRelativistic", {"v"->v,Subscript["l",0]->l}] [[2]]
sghuisman
(Sander Huisman)
March 14, 2017, 12:26pm
4
That works for this example in this form, but might not be future proof, as it relies on the fact that the written in a certain form. Both answers are correct, though mine is more widely applicable and robust…