Message Boards Message Boards

0
|
3994 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Assign FormulaData to a variable?

Posted 7 years ago

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?

3 Replies

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

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

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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract