13.07.2015 Views

Mathematica Tutorial: Notebooks And Documents - Wolfram Research

Mathematica Tutorial: Notebooks And Documents - Wolfram Research

Mathematica Tutorial: Notebooks And Documents - Wolfram Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Notebooks</strong> and <strong>Documents</strong> 143You can use comments anywhere in the <strong>Mathematica</strong> code you write.In[1]:= If@a > b, H*then*L p, H*else*L qDOut[1]= If@a > b, p, qDH*text*La comment that can be inserted anywhere in <strong>Mathematica</strong>codeComments in <strong>Mathematica</strong>.There is a convention in <strong>Mathematica</strong> that all functions intended for later use should be given adefinite "usage message", which documents their basic usage. This message is defined as thevalue of f ::usage, and is retrieved when you type ? f .f ::usage="text"define the usage message for a function? f get information about a function?? f get more information about a functionUsage messages for functions.In[2]:=Here is the definition of a function f.f@x_D := x^2Here is a "usage message" for f.In[3]:= f::usage = "f@xD gives the square of x."Out[3]= f@xD gives the square of x.In[4]:=This gives the usage message for f.? ff@xD gives the square of x.In[5]:=?? f gives all the information <strong>Mathematica</strong> has about f, including the actual definition.?? ff@xD gives the square of x.f@x_D := x 2When you define a function f , you can usually display its value using ? f . However, if you give ausage message for f , then ? f just gives the usage message. Only when you type ?? f do youget all the details about f , including its actual definition.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!