Message Boards Message Boards

Assign FormulaData to a variable?

GROUPS:

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?

POSTED BY: Alexander Radchenko
Answer
5 months ago

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]]
POSTED BY: Sander Huisman
Answer
5 months ago

Your answer is not correct. I find next topic https://reference.wolfram.com/language/guide/FormulaManipulation.html where in section Extracting Parts of Formulas is link to https://reference.wolfram.com/language/ref/Part.html So correct answer is

l2=FormulaData["LengthContractionRelativistic", {"v"->v,Subscript["l",0]->l}] [[2]]
POSTED BY: Alexander Radchenko
Answer
5 months ago

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...

POSTED BY: Sander Huisman
Answer
5 months ago

Group Abstract Group Abstract