# Mathematica: Piecewise functions and shortcuts

I work with piecewise functions a lot in the courses I teach, and sometimes to do a quick reality check I would enter a piecewise function on Mathematica. Mathematica (the old version 5 I have) can do piecewise functions by declaring a function beginning with a replaceable parameter:

f[x_]:=

After this, I press <ESC>pw<ESC><CTRL+ENTER> and I get:

with four placeholders for math expressions and their restrictions, which can be added by pressing CTRL+ENTER. I can add more by pressing CTRL+ENTER again. If I want an exponent, I type the base, then CTRL+6 then my exponent. Mathematica 5 makes it only partially clear what keyboard shortcuts to use for math expressions so that you don’t have to go to the pallette each time, but they are there.

Also the hints are not always there if you glide your mouse on the palette, so you will need to look for “keyboard shortcuts” in the documentation.

Here is a table of some shortcuts you might frequently use: