At the beginning of my script, I define a constant E by writing E:=2u+2uv, but then at the end of the script after running the final command, the result comes out with the form K/(2u+2uv). My question is simple: how do I make Mathematica recognise that the result should be in the form K/E?
Asked
Active
Viewed 69 times
1
1 Answers
2
Let's take the expression that you have at the end of the script
K/(2 u + 2 u v)

and look at it using FullForm. Looking at expressions using FullForm is a good way to figure out how to perform replacements or substitutions.
FullForm[K/(2 u + 2 u v)]

We will take the portion enclosed by Power and attempt to replace it (/. is a shortcut for ReplaceAll) with the symbol e.
K/(2 u + 2 u v) /. Plus[Times[2, u], Times[2, u, v]] -> e
(* K/e *)
This produces the desired result.
So you can place this at the end of your script.
If you are still struggling, kindly place your actual code in the question and you will doubtless get an answer that fits your needs.
Jack LaVigne
- 14,462
- 2
- 25
- 37
Eis a built-in symbol. – b.gates.you.know.what Feb 06 '17 at 18:102*u + 2*u*vor2*u + 2*uv? 2) Also,E := 2u+2uvmeansEgets replaced with 2u + 2uv, not the other way around. SinceE` is a protected, built-in symbol, didn't you get an error message?Simplifyand similar commands, and not through defining a value fore. For instance, see the following:Simplify[k/(2 u + 2 u v), e == 2 u (1 + v)]returnsk/e, which I think is what you want. Note also the important fact thatuvis DIFFERENT fromu v(notice the space, which is interpreted as multiplication). The first is a single variable named $uv$, the second is the product of $u$ by $v$. If you want to be extra explicit, you can also use*to indicate multiplication. – MarcoB Feb 06 '17 at 19:57