# Logical tests in equations?

1. Oct 16, 2005

### ktoz

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.

$$Q(x) = \prod_{j=-5}^x ((j < 1) ? 1 : j)$$

Just wondering...

Ken

Last edited: Oct 16, 2005
2. Oct 16, 2005

### Hurkyl

Staff Emeritus
One often defines functions, like:

$$\delta(x) := \left\{ \begin{array}{ll} 1 \quad & x = 0 \\ 0 & x \neq 0 \end{array}$$

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 $\delta(x) := [x = 0]$

3. Oct 16, 2005

### ktoz

Very nice!

Thanks Hurkyl

So for my example it could be defined like:

$$\delta(x) := \left\{ \begin{array}{ll} 1 \quad & x < 1 \\ x & x \geq 1 \end{array}$$

$$Q(x) = \prod_{j= -5}^x \delta(j)$$

Would that be legal?

Last edited: Oct 16, 2005
4. Oct 16, 2005

### Hurkyl

Staff Emeritus
Yes, but we usually reserve $\delta$ for that particular function. You would probably want to use a different symbol.