Mathematica Small mathematica operator question

AI Thread Summary
The discussion centers around the use of shorthand notation for variable substitution in Mathematica, similar to the TI-89 calculator's operator. Users inquire about how to replace variables in expressions, specifically using the example of substituting C[1] with 1/6 in the expression yy = E^T*C[1]+C[2]. The suggested methods include using replacement rules with the syntax /. {C[1] -> 1/6} or simply /. C[1] -> 1/6 for single replacements. Additionally, the Block function is mentioned for more frequent variable assignments without needing to redefine them each time. The conversation concludes with a confirmation that the provided solutions are satisfactory.
FocusedWolf
Messages
81
Reaction score
0
Hi,

Quick question. In the ti89 i can do this:

x+1|x=2
Answer = 3

It works like x + 1 given x = 2...do 2+1 = 3. I'm not sure what the '|' operator would be called in this case...

Anyway, is this shorthand possible in mathematica?

like if i had: yy = E^T*C[1]+C[2], and i wanted to specify C[1]=1/6... what would do it?
 
Last edited:
Physics news on Phys.org
Code:
yy = E^T*C[1]+C[2] /. { C[1] -> 1/6 }
 x + y /. {x -> 2, y -> 1}
or just
Code:
yy = E^T*C[1]+C[2] /. C[1]->1/6
x+1 /. x -> 2
if you have only one replacement.

You can also do
Code:
Block[ {C[1]=1/6},
   E^T*C[1]+C[2]
 ];
if you need the expression more often, but since you assign it anyway that's not necessary here (thought I generally prefer not assign variables)
 
Thx that'll do :cool:
 

Similar threads

Replies
13
Views
2K
Replies
3
Views
3K
Replies
5
Views
3K
Replies
1
Views
2K
Replies
19
Views
2K
Replies
1
Views
2K
Replies
4
Views
2K
Back
Top