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

Logical tests in equations?

  1. Oct 16, 2005 #1
    Is there a way to introduce logical tests into equations? For example, C has a very useful operator "?:" which returns values like so:

    x = (x < 1) ? 1 : x;

    which could be used in equations like this to multiply by 1 for any value less than 1.

    [tex]Q(x) = \prod_{j=-5}^x ((j < 1) ? 1 : j) [/tex]

    Just wondering...

    Ken
     
    Last edited: Oct 16, 2005
  2. jcsd
  3. Oct 16, 2005 #2

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    One often defines functions, like:

    [tex]
    \delta(x) := \left\{
    \begin{array}{ll}
    1 \quad & x = 0 \\
    0 & x \neq 0
    \end{array}
    [/tex]

    I've also seen the handy little notation [P] which is 1 if P is true, and 0 if P is false. E.G. the aforementioned function could be written as [itex]\delta(x) := [x = 0][/itex]
     
  4. Oct 16, 2005 #3
    Very nice!

    Thanks Hurkyl

    So for my example it could be defined like:

    [tex]
    \delta(x) := \left\{
    \begin{array}{ll}
    1 \quad & x < 1 \\
    x & x \geq 1
    \end{array}
    [/tex]

    [tex]
    Q(x) = \prod_{j= -5}^x \delta(j)
    [/tex]

    Would that be legal?
     
    Last edited: Oct 16, 2005
  5. Oct 16, 2005 #4

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Yes, but we usually reserve [itex]\delta[/itex] for that particular function. You would probably want to use a different symbol.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?