Format piecewise function inline with text

I am still relatively new to TeX. Thank you in advance for your patience with me. I assure you I have looked around for more than just 5 minutes before asking this question.

I am able to create a piecewise function using the following:

\documentclass{exam}
\begin{document}
\begin{questions}
....
\question %7
Let \begin{equation*}
f(x) = \begin{cases}
x, & x < 3,\\
4x, &  x > 3
\end{cases}
\end{equation*}
be a function.  Which of the following statements is/are true about $f$?
...
\end{questions}
\end{document}


However, the piecewise function is centered awkwardly on its own line when really I just want it inline with the rest of the sentence.

In other words, the above gets me

"Let

(centered) f(x)= look-at-all-my-pieces

be a function..."

and I would like it to be "Let f(x)= look-at-all-my-pieces be a function..."

I can do this with a non-piecewise function by simply using $f(x)=function-stuff$ but I am unable to do this once I have cases.

Here are three ways:

\documentclass{exam}

\usepackage{amsmath}

\begin{document}

\begin{questions}

\question
Let $f(x) = \begin{cases} x & \text{if }x < 3 \\ 4x & \text{if }x > 3 \end{cases}\,$
be a function. Which of the following statements is/are true about $f$?

\question
Let $f(x) =\left\{ \begin{matrix} x & \text{if }x < 3 \\ 4x & \text{if }x > 3 \end{matrix}\right.\,$
be a function. Which of the following statements is/are true about $f$?
\question
Let $f(x) = x$ if $x < 3$, $f(x) = 4x$ if $x > 3$, be a function. Which of the following statements is/are true about $f$?
\end{questions}

\end{document}


• shouldn't f be inside the math \$ expression? – barbara beeton Jul 28 '17 at 0:17
• Probably. I guess my mouse slipped while I was asleep. I'll fix that in a while. Thanks for pointing it! – Bernard Jul 28 '17 at 0:21