Formula for function I am self-learning mathematics and I don't know the exact language of math. I am trying to learn calculus by using Gilbert Strang's book "Calculus". There is an interesting problem that I want to solve, but I can't find a solution. This problem is about how to represent functions using "$j$" letter.
For example I have this function which outputs: $0 1 0 1 0 1 \ldots$ and I want to represent that function as $f$ by using $j$, which is a number that tells which number I am looking at. So first $f \to 0$ would be $j \to 0$, second $f\to 1$ will be $j \to 1$, third $f \to 0$ will be $j \to 2$, fourth $f \to 1$ will be $j \to 3$ etc.
I have found that if $j$ is odd, then $f$ is $1$ and if $j$ is even, then $f=0$. So I came up with this two functions $f_{j} = j^0$ and $f_{2j} = j-j$ (it is really hard to represent my notebook writing in web text, those $j$ and $2j$ in round brackets represent that they are written under f).
So how can I represent this two functions as one function?
Something like:
$$ f = \begin{cases} 0 & \text{ if $j$ is an even number} \\  1 & \text{ if $j$ is an odd number} \end{cases}$$
I hope I explained the problem pretty well, so you have understood it.
 A: Your piecewise notation is close. I would use something like:
$$f(j) = \begin{cases} 0 & \text{if $j$ is an even number} \\ 1 & \text{if $j$ is an odd number}\end{cases}$$
In physics it is common to describe the relationship between numbers using variables, as "when $t = 2$, $x = 3$" or your "when $j = 2$, $f=0$". In math, however, it is common to describe the relationship between numbers using functions: to define $x(t)$ as a function where $x(2) = 3$, or to define $f(j)$ as a function where $f(2) = 0$.
Here $f$ is a function, and $f(j)$ is the number we get when we plug $j$ into $f$, so we want to say "the number we get if we plug $j$ into $f$ is $0$ if $j$ is an even number and $1$ if $j$ is an odd number".
$$f(j) = \begin{cases} 0 & \text{if $j$ is an even number} \\ 1 & \text{if $j$ is an odd number}\end{cases}$$
What you wrote,
$$f = \begin{cases} 0 & \text{if $j$ is an even number} \\ 1 & \text{if $j$ is an odd number}\end{cases}$$
Reads as "$f$ is $0$ if $j$ is an even number and $1$ if $j$ is an odd number", which is slightly different, implying that $f$ is a variable representing a number instead of a function. We can still understand what you mean, but this could cause problems if you wanted to write a computer program. A computer would be very unhappy if you wrote sqrt(abs) instead of sqrt(abs(x)).
A few other notes: $0^0$ is undefined, just like $\frac{0}{0}$.
Also, you can produce this function using powers of $-1$: $$f(j) = \frac{1-(-1)^j}{2}$$ although this doesn't communicate your intention like the piecewise function notation does.
