Message Boards Message Boards

0
|
2699 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Substitution

Posted 10 years ago

For 2ab/(a+b). I would like to do a substitution, say I set z=a+b. I want the computer to know that a=z-b resulting in 2(z-b)b/z, then 2(bz-b^2)/z and so on.

Thanks

POSTED BY: Robert Otome
2 Replies
Posted 10 years ago

In[1]:= Solve[{f == 2 a b/(a + b), z == a + b}, f, a]

During evaluation of In[1]:= Solve::bdomv: Warning: a is not a valid domain specification. Mathematica is assuming it is a variable to eliminate. >>

Out[1]= {{f -> (2 (-b^2 + b z))/z}}
POSTED BY: David Keith

another way

Clear[a, b]
expr = 2 a b/(a + b);
replace = z == a + b;
expr /. a -> (a /. First@Solve[replace, a])
(*  (2*b*(-b + z))/z *)
POSTED BY: Nasser M. Abbasi
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