Case function in Mathematica


by omri3012
Tags: case, function, mathematica
omri3012
omri3012 is offline
#1
Dec24-11, 05:38 AM
P: 62
Does anyone familiar with a convenient way in Mathematica to define a case function such as:

[itex] y(x)=\left\{\begin{array}{c} x \\ -x\end{array}\begin{array}{c} x>0 \\ x<0\end{array}
\right. [/itex]
?

Thankes,
Omri
Phys.Org News Partner Science news on Phys.org
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes
phyzguy
phyzguy is offline
#2
Dec24-11, 05:56 AM
P: 2,071
You want to use 'Piecewise':

y[x_]:=Piecewise[{{x,x>0},{-x,x<0}}]
omri3012
omri3012 is offline
#3
Dec24-11, 08:47 AM
P: 62
Thankes,
It's very helpful :)


Register to reply

Related Discussions
Mathematica play function fun Fun, Photos & Games 0
sum function in mathematica Math & Science Software 2
Give to an interpolation function an analitic function with mathematica Math & Science Software 1
how to use solve function in matlab in this case Math & Science Software 0
Special case of four variable logic function (k-maps) Engineering, Comp Sci, & Technology Homework 1