# Math formatting "Pro Tips" edition: Definition by cases! - "?"

##### 2 Answers

I've (finally) found a way to write **definitions by cases** for functions.

The syntax looks like this

hashtag { (expression 1, "case 1"), (expression 2, "case 2"), (expression 3, "case 3") ... (expression n, "case n") :} hashtag

Here's an example

*Without the hashtags*

f(x) = { (x^2, ", if x is even"), (2x + 1, ", if x is odd") :}

*With the hashtags*

Aparently, if you use

However, if you want the first bracket removed, but still keep this format, you'll have to write

*Without the hashtags*

{: ("if x is > 0, ", x^2), ("if x is < 0, ", 2x+1) :}} = f(x)

*With the hashtags*

This could also be used for absolute values equations and stuff like that

*Without the hashtags*

|x + 2| = { (x +2, ", if x + 2" >= "0"), (-x-2, ", if x + 2 < 0") :}

*With the hashtags*

This is just a practice answer.

#### Explanation:

So, the synthax for writing matrices looks iooks like this

*Without the hashtags*

( (1,1,1), (2,2,2), (3,3,3) )

*With the hashtags*

Basically, you group the rows by using parantheses and you write them one after the other. Check out more examples of matrices here:

http://socratic.org/questions/how-to-write-matrices-on-socratic#141468

For piecewise functions, you can write

*Without the hashtags*

{ (2x+2, ", x">="0"), (x^2, ", x<0") :}

*With the hashtags*

The trick here is to write

http://socratic.org/questions/i-ve-found-another-syntax-useful-for-math-answers