Message Boards Message Boards

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

[?] Replace variables of an expression without being evaluated?

Hello guys,
How to replace the variables of an expression without being evaluated?
For example:

x = 2; y = 3; z = 5; (x + y) / z  

Show (2 + 3) / 5 instead of 1

POSTED BY: Jorge Manrique
4 Replies

Use your approach and work very well
With Defer also works
thanks guys

POSTED BY: Jorge Manrique

You may define a function and use it:

In[1]:= f[x_, y_, z_] := Defer[(x + y)/z]

In[2]:= f[2, 3, 5]

Out[2]= (2 + 3)/5

Another way

Clear[x, y, z]; HoldForm[(x + y)/z] /. {x -> 2, y -> 3, z -> 5}

To calculate the expression use

ReleaseHold[%]
POSTED BY: Ivan Siahlo
Posted 8 years ago
In[1]:= Defer[(x + y)/z] /. {x -> 2, y -> 3, z -> 5}

Out[1]= (2 + 3)/5
POSTED BY: Hans Milton
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