This question already has an answer here:

I am new to latex and I am having trouble typing the function range before I define the function. So I am trying to define a piecewise function, and how would I have something like this?enter image description here

marked as duplicate by Werner math-mode Jan 26 '18 at 7:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Welcome! Please always provide an MWE for your question. Assuming that you load the amssymb package, the code is $f:\mathbb{N}\mapsto\mathbb{N}$, but you should really use \to instead of \mapsto here. – user121799 Jan 26 '18 at 4:59
  • Hi, for some reason, it keeps giving me undefined control sequence when I use mathbb. – catie Jan 26 '18 at 5:02
  • 2
    add \usepackage{amssymb} to your preamble – koleygr Jan 26 '18 at 5:04
  • I posted a code below. Please tell me when you read and understood it, I'll erase it then. – user121799 Jan 26 '18 at 5:18

Thanks, Mico!

$f\colon\mathbb{Z}\to\mathbb{N}$ is more correct than
 n&\mapsto \left( n\mod 3\right)^2

enter image description here

  • Please change all three instances of : to \colon. (The former is a relational operator.) – Mico Jan 26 '18 at 5:30
  • @Mico: Will do ... but I did not intend to keep this post. – user121799 Jan 26 '18 at 5:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.