__MathCAD Tutorial __

This worksheet covers many of the basic operations and functions in MathCAD. It covers simple definitions of constants, variables, and arrays, plotting 2-d and 3-d data and functions, vectors and matrix arithmetic, numerical and symbolic evaluation of integrals and differentials, and animations.

Version 2.0 RLM (20 Jan 2005)

__Part 1: Elementary __

__Literals__

__Defining variables__

Using built-in functions

*Display significant digit in result: change to 8 by double-clicking on the answer and changing 'number of decimal places*

__Using dimensions__

a. Example 1

*Define some constants*

*Define custom units in terms of predefined units, express anser in custom units*

*Angles are normally expressed in radians by default*

*Replace placeholder with desired angualr unit (deg)*

b. Example 2: How long does it take light from the star Vega to reach Earth?

Define constants

c. Example 3: What is the gravitational acceleration on the Earth's surface?

*Note mixing of mks,cgs, and English units!*

*Result is in correct units (MathCAD converts variables to a consistent set of units before evaluation)*

d. Example 4: Lost at sea 1 problem (Bennett, p. 109)

At solar transit, the relationship between longitude, UT time of solar transit is

Looking at a world map (e.g. Mapquest,
__map by coordinates) __
shows that this location is close to Hawaii

__Using Arrays__

*Use the Insert... matrix to create array X, 3x3 matrix Y *

__2. Plotting data __

**Entering and Plott****ing data**

enter by hand using commas

**Add a fitting function to the plot**

Fitting function (slope and intercept are pre-defined functions)

Function line reports both slope, intercept

**Plotting functions: Black body curve**

3. __Reading and writing data from files__

**Reading data from a column-based text file**

**Writing to a data file**

Write to a user defined file

__4. ____Vector and matrix arithmetic__

define vectors using insert matrix (1 column x n rows))

Dot product

vector addition

Cross product

Length of vector

Suppose we have matrix equation y = M*x. Given M,y, what is x?

**5. **__Numerical integration (definite integrals)__

Planck function, suppose:

Since luminosity is proportional to the fourth power of T, we expect luminosity ratio to be:

6. __Symbolic evaluation of expression, integrals, differentials __

indefinite integrals

select entire integral, choose Symbolics/ evaluate/ symbolically, or simply select and type control . (period), F9

ordinary n-th order differentials, evaluate symbolically:

Definite integral:

Select entire integral, select Symbolics/Evaluate/Symbolically

Evaluation: floating point: note use large finite upper limit

compare with symbolic result

Symbolic calculation of matrix expressions

select matrix, then symbolics/matrix/invert

factoring of algebraic expressions

solve for variable

Solve for y (note: use ctrl-equal for equal sign in symbolic expressions)

Solve for y

8. __Solve blocks: single variable __

Guess for b

**Solving groups of equations**

Guesses

9. __Solving for roots of an equation using root function__

guesses (from inspection of plot)

10. __Plotting 3-d curves__

Parametric lines

**3-d Surface**

Function describing graph to be revolved about axis

Interval determining portion of

graph to revolve

set up a grid in i,j

Another example:

11. Animations!

Define a 2-d function to plot, with the variable to be stepped (g) defined by special MathcAD variable FRAME. Then choose Tools/Animations/record. Select the region to be animated (including the FRAME statement), then. Animate button