Introduction to MathCAD, and Assignment 1
MathCAD is a program for working with mathematics, both symbolically and numerically. In this class, we will use MathCAD to do calculations, solve differential equations, and do some modeling that is better done numerically than analytically. This sheet is intended to get you started with MathCAD.
Your assignment is to reproduce the integral and the graph on the last page. This will require you to get yourself set up with MathCAD, and help you learn how to write, edit, print, etc.
MathCAD processes what you type the same way you read a book: left to right, and top to bottom. This means that you must give statements in a logical order, defining constants before
you attempt to use them in equations.
Click the cursor where you want your typing to go. Here, you'd type the symbo, then a colon (':'), then the value. You can put them on different lines, or string them across a single line like this. To move something you've written, select it and place the cursor over the bounding box. The cursor will change to a hand icon, and you can click to grab and move the object.
To enter this equation, type e ^ a*b <space> <space> = The carat ('^') tells the editor you are entering a superscript. What you type is part of the superscript until you press the space bar twice, which returns you to the "baseline" of the equation. Watch the blue highlighting, toggled with the space bar, to see what the next character will be applied to. Entering '=' then causes the equation to be evaluated.
MathCAD knows units, and I require you to use units wherever you can. The unit tool is accessed by clicking on the measuring cup icon, or you can just multiply the number by the unit when you enter the equation. You may find it a nuisance initially, but it is useful for keeping your units straight in the equations. Here I've redefined my constants a and b to have units (and MathCAD alerts me, "This expression redefines a previously defined variable."). MathCAD will internally convert your units to base units.
It is often useful (and I highly recommend it) to have MathCAD repeat something back to you, to make sure you've got it right. I also recommend this layout: define on the far left, indent the test expressions, and keep a running commentary on the right.
Some things don't work with units. Onscreen the equation to the left is red, and selecting it brings up the message "Can't have anything with units or dimensions here."
Remove the units, and the calculation is "legal" again.
You can define any unit, standard or of your own invention.
With these definitions, we can count with different units:
Some units encountered in soils and environmental work:
Parts per million
Parts per billion
Some time units are not in MathCAD:
Temperature is somewhat cumbersome in MathCAD, because while it is good at converting from any unit to any other unit by multiplication, is not good at conversion by shifting/addition (e.g., from Celsius to Kelvin). So for the purpose of performing temperature calculations above freezing, it can be useful to pretend that water freezes at 0 Kelvin.
OK, back to editing and equations...
To enter a more complex equation, you often need to use one of the palettes. Under the "View" menu, select the toolbar option. This option can open several toolbars:
a Calculator toolbar for numbers, log and trig functions, and other basics,
a Graph toolbar for making graphs of various sorts,
a Vector and Matrix toolbar,
an Evaluation toolbar,
a Calculus toolbar for integrals, derivatives, summations and the like,
a Boolean toolbar,
a Programming toolbar for programming loops, branches, and other control structures,
a Greek symbol toolbar, and
a Symbolic keyword toolbar.
To enter this equation, you click on the worksheet to select where you want the equation to go. Now open the calculus toolbar and select the definite integral sign.
You'll see this:
Type in the equation between the integral and the d:
e ^ a*x <space><space> * sin(b*x). Now click on each of the integration limits in turn, and enter the numbers. Add an x after the d to make dx. Now press <space> until the whole equation is highlighted in blue, and enter =. Notice how the space bar selects more each time you press it.
Sometimes it's useful to define a function, mainly as a convenience: less typing, easier reading, and a single place to fix an error. Here we'll graph the integral function that we just calculated:
Define the function. We now have a function f which takes an argument x. This allows us to use it more conveniently.
We can evaluate it at any value, say p, by typing f(p)=. This is a test expression like the ones I did above with units. Greek letters like p are typed by entering the English equivalent, then hitting control -G to "Greekify" them. Alternatively, you could use the Greek toolbar.
Define the range of interest. To give a "delta-x" of 0.1 for graphing, type 0,0.1;4.2. To use the default increment (1), just type 0;4.2 after the x:. This is called a range variable, and we'll be seeing a lot of them.
To graph the function, type f(x) where you want the graph to be. Then, leaving the text highlighted, open the graph toolbar and click on the X-Y plot button. The graph will appear. You can resize, modify, and annotate it as you want.