HOME > 3D Design in Mathematica

3D Design in Mathematica

Helpful Mathematica techniques

  • Keep a diary! Write down commands that you have explored, keeping track of syntax, interesting things that you can do, and questions that pop up.
  • Think before you code! Before you start typing, think about what you want the computer to do, and how you would be able to write a logical sequence of commands to do this thing. Write some pseudocode out first.
  • Build in stages! When trying to get Mathematica to do a multi-step command, make sure each nested command works before trying to wrap it in another command. Work from the inside of the onion outward!
  • Copy, modify, repeat! When you have code that is working, don't modify it. Copy it to the next line and then modify it. This forms a page of scratch work.

Other Items of Note!

Many of your initial errors will come about because of one of the following two problems:
  • Mathematica is Case-SenSitive (AA is not the same as aA), so be careful about what you type.
    In particular, all built-in Mathematica functions are spelled out and capitalized, such as Table, ListPlot, IntegerPart, etc.
  • In Mathematica, it is important to distinguish between parentheses (), brackets [], and braces {}:
    • Parentheses (): Used to group mathematical expressions, such as (3+4)/(5+7).
    • Brackets []: Used when calling functions, such as N[Pi].
    • Braces {}: Used when making lists, such as {i,1,20}.
    If you use the wrong symbols in the wrong places or if you do not have a closing symbol for every opening symbol, Mathematica will give you an error message.
  • In Mathematica, there are four types of equals: =, ==, :=, and ===. We will learn the difference between all of them; at the beginning of this semester, you only need the first two.
    • To define a variable to store it in memory, use =. For example, to define z to be 3, write z=3.
    • You use == to check for equality. For example, 1-1==0 will evaluate to True and 1==0 will evaluate to False.
    • You use := to define your own command. (This is advanced.)
    • You will likely not use === in this class.
  • One of the most important things to do is explore. If you are having trouble with a certain function, use the ? command to ask for help. Enter ? Table and the output will be a yellow box with a quick synopsis of the command. For more detailed information, click the blue >> at the bottom right of this yellow box. This will open the Documentation Center which gives examples of using the command in action, available options for this command, and anything else you might want to know about the command.

Algebra and Calculus

Mathematica will do everything your calculator can and more.
  • Use ^ to put something to a power.
  • pi is Pi, e is E and sqrt(-1) is I.
  • If you want to see the numerical approximation to a fraction or irrational number, use the function N. For example, to find the decimal represenation of pi, write N[Pi].
  • Use E^x or Exp[x] to represent the function ex.
  • To take the derivative of a function, use D and specify the derivative with respect to which variable. For instance D[x^2 + 3x, x].
  • To take the integral of a function, use Integrate and specify the integral with respect to which variable. For instance Integrate[x^2 + 3x, x].
  • To solve for the roots of ax2+bx+c=0 symbolically, use Solve[a x^2 + b x + c == 0, x].
    Notice the double equals sign. (Mathematica is searching for when the expression is True.)
  • Coefficient[(1 + x)^10, x^3] gives the coefficient of x3 in the expansion of (1 + x)10.