Introducing Logical Tests in Equations?

  • Context: Undergrad 
  • Thread starter Thread starter ktoz
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
ktoz
Messages
170
Reaction score
12
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:
Physics news on Phys.org
One often defines functions, like:

[tex] \delta(x) := \left\{<br /> \begin{array}{ll}<br /> 1 \quad & x = 0 \\<br /> 0 & x \neq 0<br /> \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]
 
Very nice!

Thanks Hurkyl

So for my example it could be defined like:

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

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

Would that be legal?
 
Last edited: