Small mathematica operator question

  • Context: Mathematica 
  • Thread starter Thread starter FocusedWolf
  • Start date Start date
  • Tags Tags
    Mathematica Operator
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
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)