Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Small mathematica operator question

  1. Oct 15, 2007 #1
    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: Oct 15, 2007
  2. jcsd
  3. Oct 15, 2007 #2

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    Code (Text):
    yy = E^T*C[1]+C[2] /. { C[1] -> 1/6 }
     x + y /. {x -> 2, y -> 1}
     
    or just
    Code (Text):
    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 (Text):
    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)
     
  4. Oct 15, 2007 #3
    Thx that'll do :cool:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Small mathematica operator question
  1. Mathematica questions (Replies: 10)

  2. Mathematica question (Replies: 10)

  3. Mathematica question (Replies: 1)

  4. Mathematica question (Replies: 4)

Loading...