TRN 4010 003 01 - SG Ins - Lec - EN

Download as pdf or txt
Download as pdf or txt
You are on page 1of 257
At a glance
Powered by AI
The document discusses copyright restrictions on documentation and software from PTC Inc. It also details consequences for unauthorized use.

The document content appears to provide information and instructions regarding Mathcad Prime 3.0 software and related training materials from PTC Inc.

Two engineering projects are described involving structural and mechanical engineering design tasks.

Fo

rP
TC

In

te

rn

al

se

nl

Mathcad Prime 3.0 Essentials

Authored and published using

Copyright 2013 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
User and training guides and related documentation from PTC Inc. and its subsidiary companies
(collectively "PTC") are subject to the copyright laws of the United States and other countries
and are provided under a license agreement that restricts copying, disclosure, and use of such
documentation. PTC hereby grants to the licensed software user the right to make copies in
printed form of this documentation if provided on software media, but only for internal/personal use
and in accordance with the license agreement under which the applicable software is licensed.
Any copy made shall include the PTC copyright notice and any other proprietary notice provided
by PTC. Training materials may not be copied without the express written consent of PTC. This
documentation may not be disclosed, transferred, modified, or reduced to any form, including
electronic media, or transmitted or made publicly available by any means without the prior written
consent of PTC and no authorization is granted to make copies for such purposes.

Information described herein is furnished for general information only, is subject to change without
notice, and should not be construed as a warranty or commitment by PTC. PTC assumes no
responsibility or liability for any errors or inaccuracies that may appear in this document.

nl

The software described in this document is provided under written license agreement, contains
valuable trade secrets and proprietary information, and is protected by the copyright laws of the
United States and other countries. It may not be copied or distributed in any form or medium,
disclosed to third parties, or used in any manner not provided for in the software licenses agreement
except with written prior approval from PTC.

rn

al

se

UNAUTHORIZED USE OF SOFTWARE OR ITS DOCUMENTATION CAN RESULT IN CIVIL


DAMAGES AND CRIMINAL PROSECUTION. PTC regards software piracy as the crime it is,
and we view offenders accordingly. We do not tolerate the piracy of PTC software products, and
we pursue (both civilly and criminally) those who do so using all legal means available, including
public and private surveillance resources. As part of these efforts, PTC uses data monitoring and
scouring technologies to obtain and transmit data on users of illegal copies of our software. This
data collection is not performed on users of legally licensed software from PTC and its authorized
distributors. If you are using an illegal copy of our software and do not consent to the collection
and transmission of such data (including to the United States), cease using the illegal version, and
contact PTC to obtain a legally licensed copy.

te

Important Copyright, Trademark, Patent, and Licensing Information: See the About Box, or
copyright notice, of your PTC software.
UNITED STATES GOVERNMENT RESTRICTED RIGHTS LEGEND

rP
TC

In

This document and the software described herein are Commercial Computer Documentation and
Software, pursuant to FAR 12.212(a)-(b) (OCT95) or DFARS 227.7202-1(a) and 227.7202-3(a)
(JUN95), and are provided to the US Government under a limited commercial license only. For
procurements predating the above clauses, use, duplication, or disclosure by the Government
is subject to the restrictions set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data
and Computer Software Clause at DFARS 252.227-7013 (OCT88) or Commercial Computer
Software-Restricted Rights at FAR 52.227-19(c)(1)-(2) (JUN87), as applicable. 01282013
PTC Inc., 140 Kendrick Street, Needham, MA 02494 USA
PRINTING HISTORY

Fo

Document No.

TRN-4010-M02-EN-LM-P01
Printed in the U.S.A

Date

Description

10/21/2013

Initial Printing of:


Mathcad Prime 3.0 Essentials

About PTC University


Welcome to PTC University!
With an unmatched depth and breadth of product development knowledge,
PTC University helps you realize the most value from PTC products. Only
PTC University offers:

In

te

rn

al

se

nl

An innovative learning methodology - PTCs Precision Learning


Methodology is a proven proprietary approach used by PTC to develop and
deliver learning solutions.
Flexible Delivery Options PTC University ensures you receive the same
quality training programs regardless of the learning style. Our extensive
experience, innovative learning techniques, and targeted learning modules
facilitate the rapid retention of concepts, and higher user productivity.
Premier Content and Expertise A thorough instructor certification process
and direct access to the PTC product development and PTC consulting
organizations means that only PTC courses can give you highly-qualified
instructors, the most up-to-date product information and best practices
derived from thousands of deployments.
Global Focus PTC University delivers training where and when you need it
by providing over 100 training centers located across 35 countries offering
content in nine languages.
Delivering Value A role-based learning design ensures the right people
have the right tools to do their jobs productively while supporting the
organizations overall performance goals.

rP
TC

The course you are about to take will expose you to a number of learning
offerings that PTC University has available. These include:

Fo

Instructor-led Training (ILT) - The ideal blend of classroom lectures,


personal demonstrations, hands-on workshops, assessments, and
post-classroom tools.
Pro/FICIENCY - This Web-based, skills assessment and
development-planning tool will help improve your skills and productivity.
eLearning Libraries - 24/7 access to Web-based training that will
compliment your instructor-led course.
Precision LMS - A powerful learning management system that will manage
your eLearning Library and Pro/FICIENCY assessments.

PTC University additionally offers Precision Learning Programs. These are


corporate learning programs designed to your organizations specific goals,
current skills, desired competencies and training preferences.
Whatever your learning needs are, PTC University can help you get the most
out of your PTC products.

PTC Telephone and Fax Numbers


North America

nl

Education Services Registration


Tel: (888) 782-3773
Fax: (781) 370-5307
Technical Support (Monday - Friday)
Tel: (800) 477-6435
Fax: (781) 707-0328
License Management and Contracts
Tel: 877-ASK-4-PTC (877-275-4782)
Fax: (781) 707-0331

se

Europe

Technical Support, License Management, Training & Consulting


Tel: +800-PTC-4-HELP (00-800-78-24-43-57)

al

Asia

rn

Please refer to http://www.ptc.com/services/training/contact.htm for contact


information.

Fo

rP
TC

In

te

In addition, you can access the PTC Web site at www.ptc.com. Our Web
site contains the latest training schedules, registration information, directions
to training facilities, and course descriptions. You can also reach technical
support, and register for online service options such as knowledge base
searches, reference libraries and documentation. You can also find general
information about PTC, PTC Products, Consulting Services, Customer
Support, and PTC Partners.

Precision Learning
The Precision Learning Methodology
PTC developed the Precision Learning methodology to provide you with an
effective, comprehensive learning experience. This methodology is based on
a cycle of learn, assess and improve.

In

te

rn

al

se

nl

Learning via PTC courses available in multiple formats, including:


Live Classroom (either in-center or on-site)
Virtual Class (live training delivered over the Web)
Web-based Training
Assessing using Pro/FICIENCY, PTCs Web-based skills assessment and
development planning tool.
Improving through the review of self-paced learning materials available in
PTC University.

rP
TC

This methodology is continued in PTC University subscriptions, offering


a comprehensive library of self-paced and virtual courses corresponding
to PTC products.

Fo

Precision Learning Programs offer you the ability to create a customized


training program, focused on measuring the increase in your effectiveness
with PTC products.
More information is available for all of these offerings in the training section of
PTC.com at http://www.ptc.com/services/training/index.htm.

Precision Learning In The Classroom


PTCs classes are based on the proven instructional design principal of Tell
Me, Show Me, Let Me Do:
Topics are introduced through a short presentation, highlighting the key
concepts.
These key concepts are then reinforced by seeing them applied in the
software application.
You then apply the concepts through structured exercises.
After the course, a Pro/FICIENCY assessment is provided in order for you to
assess your understanding of the materials. The assessment results will also
identify the class topics that require further review.

At the end of the class, you will either take a Pro/FICIENCY assessment
via your PTC University account, or your instructor will provide training on
how to do this after the class.

Precision Learning After the Class


Each student that enrolls in a PTC class has a PTC University account. This
account will be automatically created if you do not already have one. As part
of the class, you receive additional content in your account:

nl

A Pro/FICIENCY assessment from the course content that generates a


Recommended Learning Report based on your results.
A Web-based training version of the course, based on the same
instructional approach of lecture, demonstration and exercise. The
Recommended Learning Report will link directly to sections of this training
that you may want to review.

Fo

rP
TC

In

te

rn

al

se

Please note that Web-based training may not be available in all languages.
The Web-based training is available in your account for one year after the
live class.

Precision Learning Recommendations


PTC uses a role-based training approach. The roles and the associated
training are graphically displayed in a curriculum map. Curriculum maps are
available for numerous PTC products and versions in the training section of
PTC.com at http://www.ptc.com/services/edserv/learning/paths/index.htm.
Please note that a localized map may not be available in every language and
that the map above is partial and for illustration purposes only.

Fo

rP
TC

In

te

rn

al

se

nl

Before the end of the class, your instructor will review the map
corresponding to the course you are taking. This review, along with instructor
recommendations, should give you some ideas for additional training that
corresponds to your role and job functions.

For Students: How to Use this Course Handbook


Guide Layout
The information in this guide is organized as topics to aid students in finding
information after the class is complete. Each topic is divided into the following
sections:

al

se

nl

Concept this section contains the initial introduction to the topic and is
presented during the class lecture.
Theory this sections provides detailed information introduced in the
Concept.
Procedure This section provides step-by-step instructions on how to
complete the topic within MATHCAD. Procedures are short, focused,
and simple exercises that cover the specific topics to which they apply.
Procedures are found in this Student Handbook only. Not every topic has a
Procedure as there are knowledge topics that can not be exercised.
Exercise Exercises are longer than procedures, and may cover multiple
topics, so not every topic will have an associated exercise. Exercises are
typically more involved and use more complicated models. Exercises are
found in the printed Exercise Guide and the online exercise HTML files.

rn

Additionally, these topics are organized into modules. Except for the first
module, all modules are grouped to keep similar functionality together.

Fo

rP
TC

In

te

The first module is a process module. In this module, you will find the generic
process used to solve the common types of Behavioral Modeling problems.

Training Agenda

12
13
14
15
16
17
18
19
20
21
22

3-D Plotting
Boolean Conditions
Symbolics
Solving
Optimization
Differential Equations
Programming
Data Exchange
Data Analysis
Project Day 2
Challenge Exercise Solutions

Fo

rP
TC

In

te

rn

al

Day 2
Module
Module
Module
Module
Module
Module
Module
Module
Module
Module
Module

nl

Getting Started
Documenting and Formatting
Entering and Editing Math
Variables
Functions
Range Variables
Controlling Calculations
Vectors and Matrices
Units
2-D Plotting
Project Day 1

se

01
02
03
04
05
06
07
08
09
10
11

Module
Module
Module
Module
Module
Module
Module
Module
Module
Module
Module

Day 1

rP
TC

Fo

al

rn

te

In
se

nl

Table of Contents
Mathcad Prime 3.0 Essentials
Getting Started ............................................................................1-1
Opening Mathcad ....................................................................1-2
The Mathcad Workspace ..........................................................1-5
Mathcad Worksheets ...............................................................1-6
Saving Mathcad Files ...............................................................1-7

se

nl

Documenting and Formatting........................................................2-1


Text Regions ..........................................................................2-2
Embedding Math in a Text Region ..............................................2-4
Options for Formatting Worksheets .............................................2-6
Understanding Mathcad Templates .............................................2-7

rn

al

Entering and Editing Math ............................................................3-1


Using Operators......................................................................3-2
Entering and Evaluating a Mathematical Expression .......................3-5
Formatting Math Regions ..........................................................3-9
Formatting Mathematical Results.............................................. 3-11
Implied Multiplication.............................................................. 3-12

rP
TC

In

te

Variables ....................................................................................4-1
Defining a Variable ..................................................................4-2
Numerically Evaluating a Variable ...............................................4-5
Defining a Global Variable .........................................................4-7
Assigning an Expression Retroactively ........................................4-9
Using Literal Subscripts .......................................................... 4-11

Fo

Functions ...................................................................................5-1
Defining a User-Defined Function ...............................................5-2
Inserting a Built-In Function .......................................................5-5
Design of Experiments Functions ...............................................5-8
Using Deprecated Functions......................................................5-9
Range Variables ..........................................................................6-1
Defining a Range Variable.........................................................6-2
Using a Range Variable ............................................................6-7
Controlling Calculations ...............................................................7-1
Controlling Calculations ............................................................7-2
Using Calculation Options .........................................................7-5
Using Areas ...........................................................................7-6
Vectors and Matrices ...................................................................8-1
Vectors and Matrices ...............................................................8-2
Defining Vectors and Matrices....................................................8-5

Extracting Elements from an Array ............................................ 8-10


Nested Arrays ...................................................................... 8-14
Using Array Operators and Functions ........................................ 8-17
Units ..........................................................................................9-1
Selecting a Unit System............................................................9-2
Using Units ............................................................................9-4
Adding Units to Arrays and Range Variables .................................9-9
Using Angular Units ............................................................... 9-13
Using Temperature Units ........................................................ 9-14

se

nl

2-D Plotting............................................................................... 10-1


Plotting Data in 2-D ............................................................... 10-2
Plotting Functions in 2-D ......................................................... 10-5
2-D Plot Formatting ............................................................... 10-8
2-D Trace Formatting ........................................................... 10-11
2-D Axes Formatting ............................................................ 10-14
Using Units with 2-D Plots ..................................................... 10-18

rn

al

Project Day 1 .......................................................................... 11-1


Structural Engineering Project Day 1 ...................................... 11-2
Mechanical Engineering Project Day 1 .................................... 11-4

rP
TC

In

te

3-D Plotting............................................................................... 12-1


Plotting Functions in 3-D ......................................................... 12-2
Formatting a 3-D Plot ............................................................. 12-6
Plotting Data in 3-D ............................................................... 12-8
Plotting Multiple Traces ........................................................ 12-11

Fo

Boolean Conditions ................................................................... 13-1


Using Boolean Operators ........................................................ 13-2
Writing Equations Using Boolean Operators................................ 13-3
Creating Conditional Statements .............................................. 13-4
Using Piecewise Continuous Functions...................................... 13-5
Symbolics ................................................................................ 14-1
Symbolics ............................................................................ 14-2
Symbolic Calculation.............................................................. 14-5
Symbolic Algebra .................................................................. 14-8
Solving..................................................................................... 15-1
Solving for Roots of Equations ................................................. 15-2
Numerically Solving Systems of Linear Equations ........................ 15-7
Numerically Solving Systems of Nonlinear Equations.................. 15-12
Symbolically Solving Systems of Equations .............................. 15-15
Modifying the Convergence and Constraint Tolerance................. 15-17
Optimization ............................................................................. 16-1
Constrained Optimization ........................................................ 16-2

Unconstrained Optimization..................................................... 16-5


Differential Equations ................................................................ 17-1
Ordinary Differential Equations................................................. 17-2
Programming ............................................................................ 18-1
Creating a Program ............................................................... 18-2
Conditional Statements .......................................................... 18-6
Looping Constructs.............................................................. 18-12

nl

Data Exchange .......................................................................... 19-1


Importing Data ...................................................................... 19-2
Exporting Data...................................................................... 19-6
Using the Excel Component .................................................... 19-8

al

se

Data Analysis ............................................................................ 20-1


Data Analysis ....................................................................... 20-2
Smoothing Data .................................................................... 20-4
Interpolating Data ................................................................ 20-10
Regressing Data ................................................................. 20-16

te

rn

Project Day 2 .......................................................................... 21-1


Structural Engineering Project Day 2 ...................................... 21-2
Mechanical Engineering Project Day 2 .................................... 21-3

Fo

rP
TC

In

Challenge Exercise Solutions ...................................................... A-1

rP
TC

Fo

al

rn

te

In
se

nl

1
y

Module

nl

Getting Started

se

Module Overview

In this module, you learn how to open Mathcad and save Mathcad files.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Open Mathcad files.
Save Mathcad files.

2013 PTC

Module 1 | Page 1

Opening Mathcad
This process enables you to open Mathcad, a new worksheet,
or an existing file.
To get started:

se

nl

Open Mathcad and display a blank


worksheet.
Open a new Mathcad worksheet.
Open an existing Mathcad file.

rP
TC

In

te

rn

al

Figure 1 Blank Mathcad


Worksheet

Figure 2 Opening a New


Worksheet or an Existing
Mathcad File

Fo

Opening Mathcad

To get started, you must learn how to:


Open Mathcad and display a blank worksheet.
Open a new Mathcad worksheet.
Open an existing Mathcad file.

Module 1 | Page 2

2013 PTC

PROCEDURE - Opening Mathcad and Mathcad Files


Task 1:

Open Mathcad.

button.

rP
TC

In

te

rn

al

1. Click the Prime

Open a new Mathcad file.

se

Task 2:

nl

1. Click Start > PTC Mathcad


Prime 3.0.
Mathcad opens and displays a
blank worksheet.

Fo

2. Click New
. A new
worksheet tab opens.

2013 PTC

Module 1 | Page 3

Task 3:

Open an existing Mathcad file.

1. Click the Prime


.

nl

click Open

button and

Fo

rP
TC

In

te

This completes the procedure.

rn

al

se

2. The Open dialog box displays.


Select any appropriate Mathcad
file and click Open.

Module 1 | Page 4

2013 PTC

The Mathcad Workspace


The Mathcad workspace consists of worksheets and user
interface items.
The Mathcad workspace contains the following user interface items:
Mathcad Prime button
Ribbon
Quick Access toolbar
Status Bar

nl

se

Figure 1 The Mathcad Workspace

The Mathcad Workspace

rn

al

The Mathcad workspace consists of worksheets and the following user


interface items:

Fo

rP
TC

In

te

The Mathcad Prime


button When selected, you can access
commands related to files such as Open, Save, and Print.
Ribbon The ribbon contains tabs that group related commands. The
following tabs are available:
Math Contains operators, symbols, constants, and units.
Input/Output Contains data input and output elements.
Functions Contains Mathcad built-in functions.
Matrices/Tables Contains matrices, table operators, and functions.
Plots Contains commands to insert and format plots.
Math Formatting Contains math, results, and label formatting
commands.
Text Formatting Contains text and paragraph formatting commands.
Calculation Contains calculation options, controls, and error tracing.
Document Contains documentation and page options.
Getting Started Contains help, tutorials, and various other supporting
resources.
Quick Access toolbar Contains frequently used commands. By default,
the New, Open, Save, Undo, and Redo commands are located here. You
can customize this by right-clicking a command or icon located in the
ribbon and selecting Add to Quick Access Toolbar.
Status Bar Located at the bottom of the Mathcad window and contains:
Find and Replace commands.
A Zoom Slider.
Page and Draft View icons.
2013 PTC

Module 1 | Page 5

Mathcad Worksheets
Display and calculate your work in Mathcad worksheets.
Math, text, and other elements
are contained in regions in your
worksheet. The following types of
regions are available:

nl

Math
Table
Plot
Solve Block
Image
Text Block or Box

Figure 1 Math Region

In

Mathcad Worksheets

Figure 3 Text Region

te

Figure 2 Plot Region

rn

al

se

Math
Table
Plot
Solve Block
Image
Text Block or Box

Fo

rP
TC

Mathcad worksheets are where you display and calculate your work. You can
have multiple worksheets open in Mathcad at once. To display a worksheet,
select the tab for that worksheet. Math, text, and other elements are contained
in regions in your worksheet. The following types of regions are available:

The Document tab contains commands that enable you to customize your
worksheet. The following commands are available:

Page Size Print page size.


Page Orientation Portrait or Landscape.
Margin Type Standard, Narrow, or Wide.
Show Grid Show or hide gridlines.
View Print or Draft view.
Zoom Slider Increase or decrease the zoom level of the page.
Headers and Footers Add headers and footers.

Module 1 | Page 6

2013 PTC

Saving Mathcad Files


Mathcad enables you to select from three file types when saving
files.
To save a Mathcad file, select one of
the following file types to Save As:

se

nl

MCDX
MCTX
XPS

Figure 2 Available File Types

te

rn

al

Figure 1 Selecting a File


Type from Save As

In

Saving Mathcad Files

To save a Mathcad file, select one of the following file types to Save As:

Fo

rP
TC

MCDX The default save format for Mathcad files is a Mathcad MCDX
document (.mcdx).
MCTX You can save your document as a template that can be used to
create future worksheets.
XPS You can also select an XML Paper Specification format (.xps). The
XPS format is Microsofts electronic paper file format and is similar to
a PDF.

2013 PTC

Module 1 | Page 7

PROCEDURE - Saving Mathcad Files


Task 1:

Save a Mathcad file.

1. Click the Prime


click Save

button and
.

2. The Save As dialog box displays.


Type a file name in the File name
field.

nl

3. Select a file type from the Save


as type drop-down menu. The
default save format is the native
Mathcad file format (.mcdx).

se

4. Click Save.

Fo

rP
TC

In

te

rn

al

This completes the procedure.

Module 1 | Page 8

2013 PTC

Documenting and Formatting

2
nl

Module

se

Module Overview

To create readable and aesthetically pleasing worksheets, Mathcad provides


many options for formatting worksheets. In this module, you learn how to work
with text regions and use various options for formatting Mathcad worksheets.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Work with text regions.
Embed math in a text region.
Use various options for formatting Mathcad worksheets.
Use Mathcad templates.

2013 PTC

Module 2 | Page 1

Text Regions
Mathcad supports calculation documentation through the use
of text regions.
Text regions:
Are text blocks or text boxes.
Contain resize handles.
Have a text style that you can view
on the Text Formatting tab which
determines:
Font
Size
Color
Other standard text properties

al

se

nl

Figure 1 Text Region

rn

Figure 2 Text Formatting Tab

te

Text Regions

In

Mathcad supports calculation documentation through the use of text regions.


You can insert a text region by selecting the Document or Math tabs.

rP
TC

You can also utilize these additional methods to insert text:


A text block by pressing CTRL+SHIFT+T.
A text box by pressing CTRL+T.

Fo

A text block is a text region that extends the full page width and does not
overlap with other regions in the worksheet. A text box is a text region that
expands as text is typed and can be moved across the worksheet. Text boxes
contain a resize handle to control the width of the region.

Text Regions: Style


Each text region has an associated text style. A style determines the font,
size, color, and other standard text properties. The current text style displays
in the Text Font group of the Text Formatting tab. You can change the text
style globally or locally.
The Formatting tab also enables you to:

Alter justification.
Add bullets or numbers to lists.
Decrease or increase font size.
Locally modify text.

Module 2 | Page 2

2013 PTC

PROCEDURE - Text Regions


Task 1:

Globally modify text.

1. Select the Text Formatting tab.


2. In the Text Font group, click the
Font drop-down list and select
a font.

Locally modify text.

nl

Task 2:

3. In the Font group, click the Font


Size drop-down list and select
a size.

se
U

2. Click in the text box and type


Formatting text in Mathcad
Prime.

1. Click in a blank space in the


worksheet and press CTRL+T to
insert a text box.

rn

al

3. Highlight the word Mathcad in


the text region.

4. Select the Text Formatting tab.

te

5. In the Font group, make all desired changes.

Fo

rP
TC

In

This completes the procedure.

2013 PTC

Module 2 | Page 3

Embedding Math in a Text Region


You can insert a math region in a text block or a text box.
You can embed:
Expressions
Definitions
Functions
Matrices

Figure 1 Embedded Live Math

nl

Embedding Math in a Text Region

se

You can insert a math region in a text block or a text box. The embedded
math region is live. Mathematical functions, equations, and definitions are
evaluated as if they were located outside of the text.
The embedded math region can include:

rn

al

Expressions
Definitions
Functions
Matrices

Fo

rP
TC

In

te

Module 2 | Page 4

2013 PTC

PROCEDURE - Embedding Math in a Text Region


Task 1:

Embed a math region inside of a text region.

1. Click in a blank space in the


worksheet. Right-click and select
Insert Text Box from the context
menu.
2. In the text box, type The
acceleration due to gravity,.

3. Select the Math tab.

nl

4. In the Regions group, click Math

to embed a math
Region
region in the text region.

al

6. In the text box, click outside of


the math region and type is a
Mathcad built-in variable..

se

5. In the math region, type g= to


evaluate the acceleration due to
gravity (g).

te

rn

7. Click outside of the text region to


complete embedding the math
region inside of the text region.

Fo

rP
TC

In

This completes the procedure.

2013 PTC

Module 2 | Page 5

Options for Formatting Worksheets


Mathcad enables you to create readable, aesthetically pleasing
worksheets.

nl

Inserting and deleting blank lines.


Separating overlapping regions.
Displaying grids and adjusting the grid size.
Editing the worksheet header and footer.
Moving selected text regions using the arrow keys.

You can format worksheets using one or more of the following options:

se

Options for Formatting Worksheets

To create readable, aesthetically pleasing worksheets, you can format


worksheets using one or more of the following options:

te

rn

al

Insert and delete blank lines by right-clicking a blank area between two
regions and selecting Add Space or Remove Space.
Separate overlapping regions by selecting both regions, right-clicking, and
selecting Separate Regions Vertically or Separate Regions Horizontally.
Toggle the worksheet grid off and on by selecting the Document tab. In the

rP
TC

In

.
Page group, click Show Grid
Adjust the grid size by selecting the Document tab. In the Page group, click
Grid Size and select Standard or Fine from the Grid Size drop-down list.
To edit the header or footer, select the Document tab. In the Headers and
Footers group, click Header

to edit the worksheet header, or click

Fo

to edit the worksheet footer. By specifying the commands in


Footer
the Headers and Footers group, you can:
Insert a page number.
Insert the last saved date.
Insert the file name or the full file path.
To move a math or text region, select it and use the arrow keys on your
keyboard.

Module 2 | Page 6

2013 PTC

Understanding Mathcad Templates


Templates are an important aspect of calculation management
within an organization.
Mathcad templates can specify the following:

nl

Math styles
Text styles
Page defaults
Headers and footers
Numerical formats
Unit systems
Calculation mode
Plot values

Understanding Mathcad Templates

se

rn

al

Templates are an important aspect of calculation management within an


organization. You can have multiple templates: a single corporate standard
or separate templates for a variety of tasks that need to be standardized.
Templates have the extension .mctx and are identical in form to a .mcdx
worksheet.
Mathcad templates can specify the following:

Fo

rP
TC

In

te

Math styles Available on the Math Formatting tab.


Text styles Available on the Text Formatting tab.
Page defaults Available on the Document tab.
Headers and footers Available on the Document tab.
Numerical formats Available on the Math Formatting tab.
Unit systems Available on the Math tab.
Calculation mode Available on the Calculation tab.
Plot values Available on the Plots tab.
Templates are often starting points for new worksheets in which all document
settings have been established. Your personal templates are stored in the
My Templates folder. You can also share your templates by saving them to
the Shared Templates folder.
To use a Mathcad template, click Prime
the following options:

, select New, and select one of

From My Templates
From Shared Templates
From Default Templates
Alternately, you can select a template from the Recently Used Templates
section.
Once your new worksheet has been created using the template, save your
worksheet as a .mcdx file using a new file name.
2013 PTC

Module 2 | Page 7

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 2 | Page 8

2013 PTC

Entering and Editing Math

3
nl

Module

se

Module Overview

In this module, you learn how to input math in a Math region in Mathcad, edit
the mathematical expressions you typed, and format the evaluated results.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Use and modify operators.
Enter and evaluate a mathematical expression.
Format math regions.
Format mathematical results.
Use implied multiplication.

2013 PTC

Module 3 | Page 1

Using Operators
Operators are symbols, such as the plus sign (+) and the
minus sign (-), that link variables and numbers together to form
expressions.
When typing or modifying a
mathematical expression in Mathcad
you can:

nl

Insert an operator.
Identify the operands.
Modify an existing operator.

se

Figure 1 Mathcad Expression


Using Multiple Operators

Using Operators

al

Operators are symbols, such as the plus sign (+) and the minus sign (-), that
link variables and numbers together to form expressions. When typing or
modifying a mathematical expression in Mathcad you can:

Fo

rP
TC

In

te

rn

Insert an operator You can insert an operator by typing it in the worksheet


or by selecting an operator from the Operators and Symbols group of the
Math tab.
Identify the operands Operands are the variables and numbers linked by
the operators. The operands linked by an operator are easily identified by
clicking the operator.
Modify an existing operator You can modify an existing operator by
clicking it and inserting a new operator, or by deleting it and inserting
a new operator.

Module 3 | Page 2

2013 PTC

PROCEDURE - Using Operators


Task 1:

Insert an operator.

1. Click in the worksheet and insert the Square Root and Nth Root
operator.
Select the Math tab.
In the Operators and Symbols group, click Operators

operator.

nl

Select the Square Root and Nth Root

, and selecting the

se

the Math tab, clicking Operators


desired operator.

All operators in this procedure are accessed by selecting

2. Type 2+3 in the placeholder under the Square Root operator. The
cursor appears to the right of the 3 when complete.

al

operator. Type 2 in the placeholder

rn

3. Insert the Exponentiation


that appears.

4. Click in the placeholder for the Nth Root and type 3.

operator.

In

Division

te

5. Press SPACEBAR until the entire expression is highlighted. Insert the

rP
TC

6. Click in the denominator placeholder and insert the Absolute Value


or Determinant
operator. Type 10+9 in the placeholder. The
cursor appears to the right of the 9 when complete.

Fo

7. Insert the Exponentiation


that appears.

operator. Type 3 in the placeholder

8. Press SPACEBAR until the entire expression is highlighted. Insert the


Inline Division

operator.

9. Type 25 in the placeholder that


appears. Click outside of the
region to complete.
An alternate method of
inserting an operator
is to use the keystroke
shown in the tooltip for
the operator.

2013 PTC

Module 3 | Page 3

Task 2:

Identify operands.

1. Using the expression typed in for the previous task, click any operator.
2. Note that the operator color changes to blue and blinks. The operands
associated with the blue highlighted operator highlight in gray.
3. Click other operators and note how the operands change.
Task 3:

Modify an operator.

nl

1. Using the expression typed in for


Task 1, click the + operator in the
numerator.

se

2. Type - and click outside of the


expression.

3. Using the modified expression,


click the + operator in the
denominator.

te

rn

Root
operator. Note the
operand location.

al

4. Insert the Square Root and Nth

Fo

rP
TC

In

This completes the procedure.

Module 3 | Page 4

2013 PTC

Entering and Evaluating a Mathematical


Expression
A mathematical expression in Mathcad is typed in a Math region
using natural math notation.
You can use the following items to
insert and evaluate mathematical
expressions:

nl

Placeholders
Operators
Symbols
Constants

Figure 1 Evaluated Mathematical


Expression

se

Entering and Evaluating a Mathematical Expression

rn

rP
TC

Placeholders

te

Placeholders
Operators
Symbols
Constants

In

al

Mathcad enables you to type a mathematical expression in a Math region


using natural math notation. Mathcad assembles and evaluates the parts of
an expression using the rules of precedence. You can use the following items
to insert and evaluate mathematical expressions:

Fo

Placeholders appear whenever you apply an operator. In the placeholder, you


can type a constant, variable, or another expression. If you do not fill in the
placeholder, an error message appears when you click outside of the region.

Placeholders also display when you insert constructs such as integrals,


derivatives, and summations. You can type an appropriate number, variable,
or expression in each placeholder. To navigate to each placeholder, you can
use one of the following methods:
Click in each placeholder individually.
Press the arrow keys.
2013 PTC

Module 3 | Page 5

Operators, Symbols, and Constants

Fo

rP
TC

In

te

rn

al

se

nl

Operators, Symbols, and Constants are all found on the Math tab in
the Operators and Symbols group. You can use them when entering a
mathematical expression.

Module 3 | Page 6

2013 PTC

PROCEDURE - Entering and Evaluating Mathematical


Expressions
Task 1:

Create a mathematical expression.

1. Click in the worksheet and type


the term shown.

Insert operators by
selecting the Math
tab. In the Operators
and Symbols group,

O
se
U

rn

3. Insert the Division


operator.

al

2. Select the entire term. Place the


cursor on the right side of the
term. Press (the minus symbol)
and type 100 in the placeholder.

nl

,
click Operators
and select the desired
operator.

rP
TC

In

te

4. Insert the Pi
constant.
Select the Math tab.
In the Operators and Symbols
group, click Constants

Fo

Select Pi

2013 PTC

Pi displays in a different
color. This denotes
that Pi is labeled as a
constant.

Module 3 | Page 7

Task 2:

Evaluate the mathematical expression.

1. Click anywhere in the expression


you created in the previous task.
2. Press = (equal sign).
You can also insert the
Evaluation operator
by selecting the Math
tab, clicking Operators

nl

, and selecting

Evaluation

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

Module 3 | Page 8

2013 PTC

Formatting Math Regions


Formatting can be applied to all math regions in a worksheet
or in selected regions.
Formatting math regions can include:
Math font properties.
Label styles.

se

nl

Figure 1 Math Font Group

Figure 2 Label Styles Group

al

Formatting Math Regions

te

rn

Formatting can be applied to all math regions in a worksheet or in selected


regions. Each math region has a math font style associated with variables
and constants. A style determines the font, size, color, and other standard
text properties. You can view the style you are using in a math region in the
Math Font group on the Math tab when the region is selected.

In

Formatting math regions can include:

rP
TC

Math font properties.


Label styles.

You can also add highlighting to a math region. This is an effective method
for drawing attention to a region or a set of regions.

Fo

Each region, math or text, is an individual entity that you can move or position
within a workspace. You can move these regions individually or as a group.

2013 PTC

Module 3 | Page 9

PROCEDURE - Formatting Math Regions


Task 1:

Globally format math styles.

1. Click in the worksheet, type


g=, and click outside of the
region. The built-in variable g is
evaluated as shown.

2. Select the Math Formatting tab.

nl

3. In the Label Styles group, select


Constant from the Label Styles
drop-down menu.

se

4. Select the color red from the


color options. The built-in
variable name g changes to a
red font as shown.

to restore

Highlight a region.

te

Task 2:

rn

al

5. In the Label Styles group, click Restore Label Style


the labels to the default style.

In

1. Click inside of the math region


created previously, evaluating g.

2. Select the Math Formatting tab.

rP
TC

3. In the Math Font group, click

Fo

and select
Highlight Color
the color yellow from the color
options. The region is highlighted
as shown.
This completes the procedure.

Module 3 | Page 10

2013 PTC

Formatting Mathematical Results


You can apply results formatting globally or to one or more
regions in your worksheet.
The following formatting options are
available:
Result Format
Display Precision
Show Trailing Zeros
Complex Values

Figure 1 Results Group: Math


Formatting Tab

nl

Formatting Mathematical Results

se

You can apply results formatting globally or to one or more regions in your
worksheet. The following formatting options are available:

Fo

rP
TC

In

te

rn

al

Result Format You can select the display format of numeric results from
this drop-down list. The following options are available:
General
Decimal
Scientific
Engineering
Percent
Display Precision Controls the number of digits displayed to the right
of the decimal point.
To set the zero threshold for your worksheet, set the result format to
Decimal and then modify the display precision. Any result smaller than
the selected display precision is displayed as zero.
Show Trailing Zeros Toggles the display of trailing zeros to the right of
the decimal point. The display precision selected controls the number
of trailing zeros displayed.
Complex Values Displays the result in Cartesian or Polar form.
To remove any changes and return to the default result formatting, click Clear
Format.

2013 PTC

Module 3 | Page 11

Implied Multiplication
Mathcad supports implied multiplication.
Implied multiplication:

Useful when typing expressions.


Insert by typing a numerical
constant followed by a variable.
Use is not supported with the
following variables:
i, j.

nl

Figure 1 Implied Multiplication

se

Figure 2 Explicit Multiplication

Implied Multiplication

al

Mathcad supports implied multiplication; you do not necessarily have to use


the Multiplication operator between constants and variables.

te

rn

When inserting and editing expressions, Mathcad may insert a Multiplication


operator when one is not explicitly specified. To use implied multiplication,
you must type a numerical constant followed by a variable.

rP
TC

In

When you use implied multiplication, a Multiplication operator is automatically


inserted between the leading constant and the variable. Clicking outside of
the region suppresses the operator for display and printing purposes. You can
create the same expression by explicitly typing the Multiplication operator.

Fo

There are two variables in which Mathcad does not insert an implied
Multiplication operator. These two variables are reserved suffixes and are the
letters i and j. These are reserved for complex numbers using i or j notation.
You can select these letters as variables, but you must always explicitly type
the Multiplication operator.

Module 3 | Page 12

2013 PTC

4
y

Module

nl

Variables

se

Module Overview

In this module, you learn how to define and evaluate variables, assign an
expression retroactively, and use literal subscripts.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Define a variable.
Evaluate a variable.
Define a global variable.
Assign an expression retroactively.
Use literal subscripts.

2013 PTC

Module 4 | Page 1

Defining a Variable
A variable may equal a scalar, array, string, or range of scalar
values.
Variables in Mathcad:

al

se

nl

Are defined by the Definition operator.


Variable names may include the following:
Upper and lowercase letters.
Digits (0-9).
Underscore (_) character.
Symbols.
Literal subscripts.
Constants.
The following restrictions apply to variable names:
Variable names cannot start with a digit.
All characters must have the same font.
Mathcad does not distinguish between variable and function names.

rn

Defining a Variable

te

Often you must define values as variables that you can use in subsequent
calculations.

In

To insert definitions, or assignments, select the Math tab. In the Operators


and select Definition

rP
TC

and Symbols group, click Operators

A variable may equal a scalar, array, string, or range of values. Variable


names in Mathcad may include:
Upper and lowercase letters.
Digits (0-9).
Underscore (_) character.
Symbols.
Literal subscripts.
Constants.

Fo

The following restrictions apply to variable names:


Variable names cannot start with a digit.
All characters must have the same font.
Mathcad does not distinguish between variable and function names.

Variable Error Messages


Expressions may contain a variable that has been previously defined to
the left or above the location of its current use. Math regions are read and
processed left to right, top to bottom.
Module 4 | Page 2

2013 PTC

If the variable used in the expression has not been previously defined, an error
message displays and the undefined variable is circled in red. Even if more
than one variable is undefined, Mathcad flags only one variable at a time.

Fo

rP
TC

In

te

rn

al

se

nl

You can overwrite a previous variable definition, built-in variable definition, or


function name. If you redefine these names the previous or built-in meaning
no longer works.

2013 PTC

Module 4 | Page 3

PROCEDURE - Defining a Variable


Task 1:

Define a variable.

1. Type a variable name.


2. Select the Math tab. In the
Operators and Symbols group,
click Operators

and select

nl
O
se
U
al

Fo

rP
TC

In

te

This completes the procedure.

rn

3. Type one of the following in the


placeholder:
A scalar.
An expression.
An array.
A string.
A range variable.

Definition
. The Definition
operator and a placeholder
appears.

Module 4 | Page 4

2013 PTC

Numerically Evaluating a Variable


Mathcad evaluates variables and expressions in a left-right,
top-down order.
Variables and expressions in
Mathcad:

nl

Immediately update as you make


changes, provided the default Auto
Calculation mode is enabled.
Are evaluated to the right or below
where they are defined.

You can define and evaluate a


variable in Mathcad directly in the
definition statement.

Figure 2 Evaluation within a


Definition Statement

In

te

rn

al

se

Figure 1 Define and Evaluate


a Variable

Numerically Evaluating a Variable

rP
TC

Expressions in Mathcad are evaluated in a left-right, top-down order. All


expressions immediately update as you make changes, provided you have
the Auto Calculation mode enabled, which is the default mode.

Fo

You can evaluate a variable to the right of where it is defined or below where it
is defined. If a variable is redefined to the left or below the original definition,
the variable takes on the new definition value when evaluated.
You can also evaluate a variable directly in the definition statement. The
result is bound to the assigned variable name.

2013 PTC

Module 4 | Page 5

PROCEDURE - Numerically Evaluating a Variable


Task 1:

Numerically evaluate a variable in Mathcad.

1. To define the variable, type x3.


Select the Math tab. In the
Operators and Symbols group,
and select

click Operators
Definition

rn

al

2. Type the expression shown in the


placeholder after the Definition
operator.

se

nl

You can also press


SHIFT : to insert the
Definition operator.
The keystrokes display
in the hovertext
description of the
operator.

In

te

3. To evaluate the variable, type


x3. Select the Math tab. In the
Operators and Symbols group,

and select

rP
TC

click Operators

Fo

Evaluation

You can evaluate a


variable:
To the right of where
it is defined.
Below where it is
defined.
You can also evaluate
a variable in the
definition statement,
binding the result to
the assigned variable
name.

This completes the procedure.

Module 4 | Page 6

2013 PTC

Defining a Global Variable


Mathcad also uses a definition construct called a global
definition.

nl

Figure 1 Global Variable Definition

The array origin.


Custom units and unit
abbreviations.
Material properties.
Other variables and functions that
remain the same.

Global definitions can be used to


specify:

se

Defining a Global Variable

al

Global definitions are similar to other variable definitions except they are
evaluated first. When a worksheet is opened, Mathcad scans the entire
document twice. The first scan processes global definitions. The second
scan processes other variable definitions.

te

rn

If you define a variable or function with a global definition, that variable or


function is available to all other definitions in your worksheet, regardless of
whether the definitions appear above or below the global definition.

The array origin.


Custom units and unit abbreviations.
Material properties.
Other variables and functions that remain the same.

rP
TC

In

Global definitions can be used to specify:

Fo

Once a variable name is used to define a global variable it cannot be


redefined in the same worksheet. Any attempt to redefine the variable name
results in an error.

2013 PTC

Module 4 | Page 7

PROCEDURE - Defining a Global Variable


Task 1:

Define a global variable.

1. Click in the worksheet and type


the variable name global.

A global variable name


adheres to the same
rules and restrictions
as a local variable
name.

nl

2. Select the Math tab.

3. Click Operators
from the
Operators and Symbols group.

se

4. Click Global Definition

rP
TC

In

te

rn

A global variable
definition can contain
variables that have
been globally defined
to the left or above
where they are being
used.

al

5. Type 100 in the placeholder.

from the Definition and


Evaluation group.

Task 2:

Evaluate the global variable.

Fo

1. Click in the worksheet below or


to the right of where you have
defined the global variable. Type
global.
2. Press = (equal sign) to evaluate
the variable.
Once a variable name
is used to define a
global variable, it
cannot be redefined in
the same worksheet.
Any attempt to redefine
the variable name
results in an error.

This completes the procedure.

Module 4 | Page 8

2013 PTC

Assigning an Expression Retroactively


Mathcad enables you to retroactively assign an expression to a
variable or function name.

nl

There are many instances in which


it is useful to retroactively assign an
expression.

al

se

Figure 1 Expression to be
Retroactively Assigned

rn

Figure 2 Retroactively Assigned


Expression

te

Assigning an Expression Retroactively

Fo

rP
TC

In

You often assign a value to a variable or function name after evaluating it


in the worksheet.

2013 PTC

Module 4 | Page 9

PROCEDURE - Assigning an Expression Retroactively


Task 1:

Retroactively assign an expression.

1. Type and evaluate the


expression shown.

se

nl

2. Click in the region and place


the cursor on the left side of the
expression as shown.

al

. A placeholder

te

Definition
appears.

and select

rn

click Operators

3. Select the Math tab. In the


Operators and Symbols group,

rP
TC

In

4. Type Value in the placeholder


and click outside of the region.

Fo

This completes the procedure.

Module 4 | Page 10

2013 PTC

Using Literal Subscripts


Mathcad provides literal subscripts for use in variable names.
You use literal subscripts in Mathcad
for:
Variable names.
Representing derivatives in partial
differential equations.

Figure 1 Literal Subscript

nl

Using Literal Subscripts

You use literal subscripts in Mathcad for:

se

Variable names.
Representing derivatives in partial differential equations.

click Subscript

You create literal subscripts by selecting the Math tab. In the Style group,
and type the subscript text.

Fo

rP
TC

In

te

rn

al

Be sure not to confuse literal subscripts with array subscripts. They


appear similar, but are different. Literal subscripts represent a
variable name. Array subscripts identify an element of an array,
specified by the subscript.

2013 PTC

Module 4 | Page 11

PROCEDURE - Using Literal Subscripts


Task 1:

Create a variable containing a literal subscript.

1. In a blank area of the worksheet


type v. Select the Math tab. In
the Style group, click Subscript
. Note the cursor position.

nl

2. Type the subscript text and click


outside of the math region.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

Module 4 | Page 12

2013 PTC

5
y

Module

nl

Functions

se

Module Overview

In this module, you learn how to define and evaluate user-defined and built-in
functions.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Define a user-defined function.
Insert a built-in function.

2013 PTC

Module 5 | Page 1

Defining a User-Defined Function


A user-defined function is a mathematical expression that
provides a unique output for one or more input values.
User-defined functions in Mathcad are defined using the Definition
operator.

se

nl

Function names may include the following:


Upper and lowercase letters.
Digits (0-9).
Underscore (_) character.
Symbols.
Literal subscripts.
Constants.
Function names have the following restrictions:
Function names cannot start with a digit.
All characters must have the same font.
Mathcad does not distinguish between variable and function names.

al

Defining a User-Defined Function

In

te

rn

A user-defined function is a mathematical expression that provides a unique


output for one or more input values. These input values are referred to as the
arguments of the function and are always enclosed in a pair of parentheses.
Mathcad contains built-in functions and enables the input of user-defined
functions.

rP
TC

User-defined function names in Mathcad may include:

Fo

Upper and lowercase letters.


Digits (0-9).
Underscore (_) character.
Symbols.
Literal subscripts.
Constants.
The following restrictions apply to user-defined function names:
Function names cannot start with a digit.
All characters must have the same font.
Mathcad does not distinguish between variable and function names.

Function Error Messages


User-defined function expressions may contain a variable that has been
previously defined to the left or above the location of its current use. Math
regions are read and processed left to right, top to bottom.
If the variable used in the expression has not been previously defined, an error
message displays and the undefined variable is circled in red. Even if more
than one variable is undefined, Mathcad flags only one variable at a time.
Module 5 | Page 2

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

You can overwrite a previous variable definition, built-in variable definition,


or function name. If you redefine these names, their previous or built-in
meaning no longer works.

2013 PTC

Module 5 | Page 3

PROCEDURE - Defining a User-Defined Function


Task 1:

Define a user-defined function.

1. Type the function name, func,


and press SHIFT+9.

nl

2. Type the arguments of the


function, x,y, in the placeholder.

and select

al

. The Definition
Definition
operator and a placeholder
appears.

se

click Operators

3. Select the Math tab. In the


Operators and Symbols group,

In

te

rn

4. Type the function expression in the placeholder and click outside of


the region.

Fo

rP
TC

This completes the procedure.

Module 5 | Page 4

2013 PTC

Inserting a Built-In Function


Mathcad provides a library of built-in functions.

nl

se

Core Mathematical functions.


Discrete Transform functions.
Statistics, Probability, and Data Analysis functions.
Design of Experiments functions.
Differential Equation Solvers.
File Access functions.
Finance functions.
Image and Signal Processing functions.
Probability Distribution.
Solving and Optimization functions.
Vector and Matrix functions.
Miscellaneous functions.

te

rn

al

Mathcad provides a library of built-in functions in the following areas:

In

Figure 1 Function Tab

rP
TC

Inserting a Built-In Function


Mathcad provides a library of built-in functions in the following areas:
Core Mathematical functions.
Discrete Transform functions.
Statistics, Probability, and Data Analysis functions.
Design of Experiments functions.
Differential Equation Solvers.
File Access functions.
Finance functions.
Image and Signal Processing functions.
Probability Distribution.
Solving and Optimization functions.
Vector and Matrix functions.
Miscellaneous functions.

Fo

To access these functions, select the Functions tab. You can also directly
type in a built-in function. Built-in functions are not font sensitive, but they are
case sensitive and you must spell them correctly.
2013 PTC

Module 5 | Page 5

PROCEDURE - Inserting a Built-In Function


Task 1:

Insert and evaluate a built-in function.

1. Click in a blank area of the worksheet. Select the Functions tab. In


the Functions group, click All Functions
. The Functions dialog
box appears on the left side of the worksheet.
2. Expand the Trigonometric function category.

rP
TC

In

te

rn

al

se

nl

You can sort functions in the Functions dialog box by


category or by name.

Fo

3. Select acos. This action inserts


the function into the worksheet.

Module 5 | Page 6

You can also directly


type in a built-in
function. Built-in
functions are not font
sensitive, but they are
case sensitive and
you must spell them
correctly.

2013 PTC

4. Type 0.5 in the function


placeholder and press = (equal
sign).

To insert a function
in the worksheet,
select the Functions
tab. In the Functions
group, click a function
category and select the
desired function.

Fo

rP
TC

In

te

rn

al

se

nl

This completes the procedure.

2013 PTC

Module 5 | Page 7

Design of Experiments Functions


Design of Experiments (DOE) functions and plots enable you
to analyze the resulting data from experiments performed in a
DOE or Robust Design process.
You can use these functions for:

Constructing experimental design matrices.


Analyzing and screening factors, and plotting results.
Developing statistical models.
Performing Monte Carlo simulations.

Figure 2 Pareto Plot

te

Figure 1 Design Matrix

rn

al

se

nl

In

Design of Experiments Functions

rP
TC

Design of Experiments (DOE) functions and plots enable you to analyze


the resulting data from experiments performed in a DOE or Robust Design
process. You can use these functions for:

Fo

Constructing experimental design matrices.


Create, analyze, or modify design matrices using Mathcads built-in
functions.
Analyzing and screening factors, and plotting results.
Screen factors by calculating their effects, level effects, and interactions.
Plot experimental results using the plot functionality.
Developing statistical models.
Mathcad DOE functions offer different types of regression analysis.
Performing Monte Carlo simulations.
You can generate random numbers for Monte Carlo simulations as well
as create a Monte Carlo sample for a given function.

Module 5 | Page 8

2013 PTC

Using Deprecated Functions


Deprecated functions are functions that are not available in
Mathcad Prime.
Deprecated functions:

Are not documented in Mathcad Prime.


Work if typed in a worksheet, or imported in a legacy worksheet.
Are supported by Mathcad Prime for several releases.

nl

Using Deprecated Functions

Deprecated functions are functions that are not available in Mathcad Prime.
Deprecated functions:

se

Are not documented in Mathcad Prime.


Work if typed in a worksheet, or imported in a legacy worksheet.
Are supported by Mathcad Prime for several releases.

Fo

rP
TC

In

te

rn

al

Many of the deprecated functions have alternative functions in Mathcad


Prime. The Mathcad Prime Help files contain a list of the deprecated
functions and the existing alternative functions.

2013 PTC

Module 5 | Page 9

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 5 | Page 10

2013 PTC

6
y

Module

nl

Range Variables

se

Module Overview

In this module, you learn how to define, evaluate, and use a range variable.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Define a range variable.
Use a range variable.

2013 PTC

Module 6 | Page 1

Defining a Range Variable


Range variables are variables that are equal to a sequence or
range of values.
You can use a range variable to:

nl

Iterate a function over a range of


values.
Define a vector or array,
element-by-element.
Control the domain of a 2-D plot.
Every range variable must have:

rP
TC

In

te

rn

al

se

A starting value.
An ending value.
A second value specified, if not
using a unit step.

Figure 1 A Range Variable


Definition and Evaluation

Fo

Defining a Range Variable


As shown previously, a variable can be equal to a scalar, expression, or
a string. Variables can also be equal to a sequence or range of values.
Iterative processes in Mathcad worksheets depend on ranges of values or
range variables.
Use a range of values to:
Iterate a function over a range of values.
Define a vector or array, element-by-element.
Control the domain of a 2-D plot.
To evaluate a function over a range of points, you must define a range
variable and pass the range to the function.

Module 6 | Page 2

2013 PTC

Define a range variable by selecting the Math tab, clicking Operators

in

operator.

the Operators and Symbols group, and selecting the Range


Every range variable must have:

Fo

rP
TC

In

te

rn

al

se

nl

A starting value.
An ending value.
A second value specified, if not using a unit step.

2013 PTC

Module 6 | Page 3

PROCEDURE - Defining a Range Variable


Task 1:

Define a range variable with a constant step size.

1. Click in a blank area of the


worksheet and type the variable
name force.

nl

group, click Operators


Select Definition

2. Insert the Definition


operator.
Select the Math tab.
In the Operators and Symbols

se

al

rn

, and
Operators
selecting the desired
operator.

You can insert any


operator by selecting
the Math tab, clicking

In

te

3. Type the starting value of the


range followed by a comma, 1,.
Two placeholders and the Range
operator appear.

Fo

rP
TC

4. Type 1.5 in the first placeholder,


and type 5 in the second
placeholder.

Module 6 | Page 4

The step size is


determined by the
difference between
the first and second
value in the range. The
range variable has a
constant step size over
the entire range.

2013 PTC

Task 2:

Define a range variable with a unit step size.

1. Click in a blank area of the


worksheet and type the variable
name force1.
2. Insert the Definition
operator.
3. Type 1..20 in the placeholder.

Alternatively, you can

O
se

Evaluate a range variable.

Fo

rP
TC

In

te

rn

al

1. Click in a blank area of the


worksheet, type force1, and
press =.

Task 3:

nl

insert the Range


operator rather than
typing ...

2013 PTC

Module 6 | Page 5

nl

2. When evaluating range


variables, Mathcad displays
only the first 12 values in the
range. To view the remaining
values:
Click the three dots in the
evaluation display.
The navigator window
appears. Place the cursor
over the window and click and
drag to view the entire range
variable.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

Module 6 | Page 6

2013 PTC

Using a Range Variable


You can use range variables to iterate a function over a range.
To use range variables to iterate a
function:

Figure 1 Range Variable Definition

te

rn

al

se

nl

Define the function.


Define the range variable.
Evaluate the function using the
range variable.

In

Figure 2 Function Definition and Evaluation

rP
TC

Using a Range Variable

Evaluating a function over a range of points using single point evaluation is


cumbersome. To evaluate a range of points:

Fo

Define the function.


Define the range using a range variable.
Evaluate the function by passing the range variable to the function.

2013 PTC

Module 6 | Page 7

PROCEDURE - Using a Range Variable


Task 1:

Use a range variable in a function calculation.

1. Click in a blank area of the


worksheet and define the
function shown.
You can insert any
operator by selecting
the Math tab, clicking

nl

, and
Operators
selecting the desired
operator.

Fo

rP
TC

In

te

rn

al

3. Pass the range variable to the


function and evaluate.

se

2. Using a range variable, define


the range and the step size over
which the function iterates.

This completes the procedure.

Module 6 | Page 8

2013 PTC

7
y

Module

nl

Controlling Calculations

se

Module Overview

In this module you learn how to control calculations by disabling and


re-enabling regions and automatic calculations, selecting calculations
options, and using areas.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Control calculations.
Use calculation options.
Use areas.

2013 PTC

Module 7 | Page 1

Controlling Calculations
By default, Mathcad opens in Auto Calculation mode. In this
mode, all results are automatically updated.
You can control calculations in
Mathcad by:

Disabling and enabling Auto


Calculation mode.
Disabling and re-enabling a
specific region or group of regions.

nl

Figure 1 Disabled Regions

Controlling Calculations

se

By default, Mathcad opens in Auto Calculation mode. In this mode, all


results are automatically updated. When Mathcad is in Auto Calculation
mode, a green circle appears in the message line on the lower-left corner of
the window.

rn

al

The numerical results and graphs you see in your window are always
up-to-date when in Auto Calculation mode. If your worksheet contains
several computationally intensive equations, scrolling through the worksheet
becomes time consuming as Mathcad updates all calculations as you scroll.

te

You can control calculation updates and calculations in Mathcad by:

rP
TC

In

Disabling and enabling Auto Calculation mode.


Disabling and re-enabling a specific region or group of regions to prevent
their evaluation.
If you have disabled a region, or group of regions, the following rules apply:

Fo

You can edit the disabled region but the result is not recalculated, and any
regions that depend on the disabled region are not affected.
The disabled regions are not affected by changes to other regions.

Module 7 | Page 2

2013 PTC

PROCEDURE - Controlling Calculations


Task 1:

Disable Automatic Calculation mode.

1. Select the Calculation tab.


2. In the Controls group, click Stop
.

All Calculations

nl

3. This de-selects Auto Calculation


in the Controls group. A gray
circle now appears in the
message line on the lower-left
corner of the window.

se

4. To re-enable Auto Calculation


mode, select the Calculation
tab.

Calculation

Disable math regions.

te

Task 2:

rn

al

6. A green circle now appears in the


message line on the lower-left
corner of the window.

5. In the Controls group, click Auto

rP
TC

In

1. Create the expressions for the


variable, x, and the function,
Calc(x), shown.

Fo

2. Select both regions, as shown.

2013 PTC

Module 7 | Page 3

3. Disable the regions.


Select the Calculation tab.
In the Controls group, click
.

Disable Region

Re-enable math regions.

nl

Task 3:

Mathcad dims the


regions to indicate
that the regions are
disabled.

In

Disable Region

te

rn

2. Re-enable the regions.


Select the Calculation tab.
In the Controls group, click

al

se

1. Select both disabled regions, as


shown.

rP
TC

Mathcad removes the


dimming to indicate
that the regions are
now enabled.

Fo

This completes the procedure.

Module 7 | Page 4

2013 PTC

Using Calculation Options


Mathcad provides calculation options that can be used when
evaluating mathematical expressions.
The following calculation options are
available:

nl

Approximate Equality
ORIGIN in Strings
Strict Singularity Check
Multithreading
Units/Constants in Symbolics

se

Figure 1 Calculation Options

Using Calculation Options

rn

al

Mathcad provides calculation options that can be used when evaluating


mathematical expressions. The following calculation options are available:

Fo

rP
TC

In

te

Approximate Equality This option controls the standard used in Boolean


expressions and truncation functions. When this option is selected:
Two numbers must differ by less than the maximum accuracy of your
computers floating point processor to be considered equal.
Numbers from 10-307 to 10-307 are considered to be zero.
All decimal places are used in determining the floor, ceiling, or truncated
value of a number.
ORIGIN in Strings This option controls the integer associated with the
first character in a string. String functions consider the worksheet value for
ORIGIN to be the index of the first character when this option is selected.
Strict Singularity Check This option controls the matrix inversion algorithm
used by Mathcad. If this option is selected, Mathcad checks whether the
input matrix or the inverted matrix is singular or ill-conditioned.
Multithreading Enables multiple calculations to run in parallel. Speeds
up processing of large data sets and matrices.
Units/Constants in Symbolics Controls automatic labeling of certain
variables as built-in units and constants in symbolics.
You can access these options by selecting the Calculation tab. In the
Worksheet Settings group, click Calculation Options
required option.

2013 PTC

, and select the

Module 7 | Page 5

Using Areas
Calculations in Mathcad can be enclosed in an area and
collapsed and/or disabled.
To enclose calculations in an area:

Insert an area.
Type calculations in the area.

In

te

rn

al

se

nl

Figure 1 Inserted Area

Figure 3 Disabled Regions

rP
TC

Figure 2 Enabled Regions

Using Areas

Fo

Calculations in Mathcad can be enclosed in an area and collapsed and/or


disabled. Areas enable you to group, hide, and disable calculation regions
within the area.
To enclose calculations in an area:
Insert an area.
Type calculations in the area.
An area enables you to:
Group related calculations.
Collapse or expand sets of calculations.
Disable all the math regions within the area at once by clicking in the area,
selecting the Calculation tab and clicking Disable Region

Within an area you cannot:


Insert a page break.
Insert an area, or a worksheet header or footer.
Module 7 | Page 6

2013 PTC

8
y

Module

nl

Vectors and Matrices

se

Module Overview

In this module, you learn how to define and use vectors and matrices.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Define vectors and matrices.
Extract elements from an array.
Nest arrays.
Use array operators and functions.

2013 PTC

Module 8 | Page 1

Vectors and Matrices


A variable can be comprised of a group of data in the form of a
vector or matrix.
You can insert an array in Mathcad
by:

Manual entry.
Defining each element using a
range variable.
Importing data from a file.

nl

Elements in an array:
By default, have a starting index of
0, referred to as the array ORIGIN.

se

Figure 1 Mathcad Array

Figure 2 Array Origin

al

Vectors and Matrices

rn

A variable can be comprised of a group of data in the form of a vector or


matrix. You can insert an array in Mathcad by:

In

te

Manual entry.
Defining each element using a range variable.
Reading in the array directly from a file.

rP
TC

The terms array and matrix are synonymous in Mathcad. A vector


is an array containing a single column.

Fo

The row and column index starting point default for the array elements is a
built-in variable in Mathcad. This variable is named ORIGIN and by default is
set to 0. You can globally set this variable by selecting the Calculation tab.
In the Worksheet Settings group, select 0 or 1 from the ORIGIN drop-down
list. You can also set this variable locally or globally using a definition in
the worksheet.
IMPORTANT! For the examples used in this training, the array
ORIGIN is equal to 1.

Range Variables and Vectors: An Important Distinction


A range variable and a vector may look similar, but they are two distinct
quantities and Mathcad treats them differently.
Some differences to consider:
A range variable is evaluated as a sequence of values, one at a time. A
vector or matrix evaluates all values simultaneously.
It is not possible to extract a single element from a range. It is always
possible to extract a single element from a vector or matrix.
Module 8 | Page 2

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

A range variable is used to iterate evaluations or definitions. A vector or


matrix is used to store and access information.

2013 PTC

Module 8 | Page 3

PROCEDURE - Vectors and Matrices


Scenario
Change the array ORIGIN both globally and locally.
Task 1:

Globally change the array ORIGIN.

1. Select the Calculation tab.

2. In the Worksheet Settings group,


select 0 or 1 from the ORIGIN
drop-down list.

Task 2:

Locally change the array ORIGIN.

al
rn

and insert the Definition


operator.

1. Type the word ORIGIN (all


capital letters) in the worksheet

se

nl

The ORIGIN is set to 0


by default.

In

te

You can insert all


operators by selecting
the Math tab, clicking

rP
TC

, and
Operators
selecting the desired
operator.

Fo

2. Type the desired array ORIGIN


in the placeholder and click
outside of the region.
This reassigns the
array ORIGIN from the
insertion point to the
end of the worksheet.

This completes the procedure.

Module 8 | Page 4

2013 PTC

Defining Vectors and Matrices


You can define a vector or matrix in Mathcad using various
methods.
You can define a vector or matrix in
Mathcad by:

nl

Manual entry.
Populating an array
element-by-element.
Using range variables.

rn

al

se

Figure 1 Populating a Matrix


Using Manual Entry

Figure 3 Populating a Matrix


Using Range Variables

In

te

Figure 2 Populating a Matrix


Element-by-Element

Defining Vectors and Matrices

rP
TC

You can define a vector or matrix in Mathcad using various methods:


Manual entry by selecting the Matrices/Tables tab. In the Matrices and

Fo

and select the number of elements


Tables group, click Insert Matrix
required.
You can insert a matrix containing up to 144 elements using this method.
Populating a matrix element-by-element by defining each element in the
array.
To populate an array using this method, you must use a matrix subscript
operator
to identify each element. You can locate the Matrix Index
by selecting the Matrices/Tables tab. In the Matrices and Tables group,
click Vector and Matrix Operators

and select the Matrix Index

operator.
Populating a matrix using range variables.
Here the definition process is automated by using an iterative variable:
a range variable representing the index.
2013 PTC

Module 8 | Page 5

Each value in the matrix may be one of the following:


A scalar.
A string.
An array.
A variable or function that evaluates to a scalar, string, or array.

Fo

rP
TC

In

te

rn

al

se

nl

Module 8 | Page 6

2013 PTC

PROCEDURE - Defining Vectors and Matrices


Scenario
Define a vector or matrix manually, element-by-element, and using range
variables.
Task 1:

Define a vector or matrix manually.

1. Type the variable name Matrix

nl

and insert the Definition


operator. Do not remove your
cursor from the math region.

se
U

al

, and
Operators
selecting the desired
operator.

You can insert all


operators by selecting
the Math tab, clicking

In

te

rn

2. Insert the matrix.


Select the Matrices/Tables
tab.
In the Matrices and Tables
group, click Insert Matrix

Fo

rP
TC

.
Click and drag to select a 3x3
matrix.

3. A matrix with three rows and


three columns appears. Each
element is represented by a
placeholder.

4. Type the values shown in the


placeholders. To navigate
between placeholders, use the
mouse, use the arrow keys, or
press TAB.

2013 PTC

Module 8 | Page 7

Task 2:

Define a vector or matrix element-by-element.

1. Type the variable name Array in


the worksheet.
2. Insert the Matrix Index
operator.
You can also insert

nl

the Matrix Index


operator by selecting
the Matrices/Tables
tab, clicking Vector
and Matrix Operators

rP
TC

In

4. Insert the Definition


operator.

te

rn

al

3. Type the subscript number of the


element in the placeholder as
shown.

se

, and selecting the


desired operator.

5. Type 10 in the placeholder.

Fo

6. Repeat for each element in the


array.

Module 8 | Page 8

2013 PTC

7. Evaluate the array by typing


Array and inserting the
Evaluation

operator.

Define a vector or matrix using range variables.

nl

Task 3:

In

te

rn

al

se

1. Define a range variable to


represent the index of the vector.
The following are some
important guidelines:
The range variable
for the index usually
begins at the origin.
The subscript value
must be integer
valued and take unit
steps most of the
time.

You can also define


a matrix using this
procedure. The
subscript notation
used is in the form row,
column.

rP
TC

2. Using the definition statement


shown, define the elements in
the vector.

Fo

The elements of the


array may depend on
the range variable.

3. Evaluate the vector by typing


the vector name vector1 and
inserting the Evaluation
operator.

This completes the procedure.

2013 PTC

Module 8 | Page 9

Extracting Elements from an Array


You can extract elements in arrays and use them in functions
and definition statements.
You can extract three types of data
from a matrix or array:

nl

A single element.
An entire column or row.
A subset, or submatrix of data.

rn

al

se

Figure 1 Original Matrix

Figure 3 Extracted Submatrix

te

Figure 2 Extracted Column

In

Extracting Elements from an Array

rP
TC

You can extract elements from arrays and use them in functions and definition
statements.
There are three basic types of data that you can extract from a matrix or array:

Fo

A single element.
An entire column or row.
A subset, or submatrix of data.
You can use the built-in submatrix function to extract a subset of data from an
array. The submatrix function returns the data in a matrix consisting of the
specified number of rows and columns.

Module 8 | Page 10

2013 PTC

PROCEDURE - Extracting Elements from an Array


Scenario
Extract basic types of data from an array.
Task 1:

Extract a single element from an array.

nl

1. Define the matrix CP as shown.

2. Type the matrix name, CP, and

te

rn

al

You can insert matrix


operators using one of
the following methods:
Select the Math
tab, click Operators

se

insert the Matrix Index


operator.

Fo

rP
TC

In

, and select the


required operator.
Select the
Matrices/Tables
tab, click Vector and
Matrix Operators
, and select the
required operator.
Type the shortcut
for the required
operator.

3. Type the row and column indexes


shown, separated by a comma,
in the index placeholder.
Vectors require only
a single subscript
containing the row
index.

4. Insert the Evaluation


operator.

2013 PTC

Module 8 | Page 11

Task 2:

Extract a column from an array.

1. Type the matrix name, CP, and


insert the Matrix Column
operator.

2. Type the column index, 2, in the


index placeholder.

te

insert the Matrix Row


operator.

rn

1. Type the matrix name, CP, and

Extract a row from an array.

al

Task 3:

se

nl

3. Insert the Evaluation


operator.

rP
TC

In

2. Type the row index, 2, in the


index placeholder.

3. Insert the Evaluation


operator.

Extract a subset of data from an array.

Fo

Task 4:

1. Type the variable name, CPSUB,


to which you want to assign the
extracted data, and insert the
Definition

Module 8 | Page 12

operator.

2013 PTC

2. Insert the submatrix function.


Select the Matrices/Tables tab.
In the Matrices and Tables group, click Vector and Matrix
.
Functions
Select submatrix.

nl

You can also type in the submatrix function or insert it from


the Functions tab.

rP
TC

In

te

rn

al

se

3. The submatrix function displays in the worksheet. Complete the


arguments as shown. Do not click outside of the math region.
The arguments required for the submatrix function are:
The name of the array that contains the data to extract.
The row to start extracting data.
The row to stop extracting data.
The column to start extracting data.
The column to stop extracting data.

4. Insert the Evaluation


operator to evaluate the
extracted data.

Fo

This completes the procedure.

2013 PTC

Module 8 | Page 13

Nested Arrays
An array may contain an element that is another array.

se

nl

An array embedded within another


array is called a nested array.

In

te

rn

al

Figure 1 Nested Array

rP
TC

Figure 2 Evaluated Nested Array

Figure 3 Evaluated Expanded


Array

Nested Arrays

Fo

An array may contain elements that are other arrays. An array that is
embedded within another array is called a nested array.
When initially evaluating an array containing a nested array, Mathcad
indicates the nested array using a shorthand notation. This shorthand
indicates the dimensions (rows, columns) of the nested array and encloses
the dimensions in brackets.

Module 8 | Page 14

2013 PTC

PROCEDURE - Nested Arrays


Scenario
Display nested arrays by extracting them and by specifying the result format.
Task 1:

Display nested array elements by extracting the array.

se

nl

1. Define the two matrices shown. The matrix Nest is nested in the
matrix P.

al

insert the Matrix Index


operator.

2. Type the matrix name, P, and

In

te

rn

3. In the placeholder, type the


row and column location of the
nested array, 2,2.

rP
TC

4. Insert the Evaluation


operator.

Task 2:

Display nested array elements by specifying the result format.

Fo

1. Evaluate the parent array P as shown.

2013 PTC

Module 8 | Page 15

2. Select the evaluated matrix P. To expand the nested matrix:


Select the Matrices/Tables tab.

nl

In the Result Format section, click Collapse Nested Matrices


to de-select it.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

Module 8 | Page 16

2013 PTC

Using Array Operators and Functions


You can use vectors and arrays when working with operators
and functions in Mathcad.
You can find operators and functions
used with vectors and arrays:

se

nl

On the Matrices/Tables tab.


Matrices and Tables group.
You can also find Vector and
Matrix operators on the Math tab.
Operators and Symbols group.
You can also find Vector and Matrix
functions on the Functions tab.
Functions group.

rn

al

Figure 1 The Function and


Arguments

te

Figure 2 Incorrect Evaluation

Figure 3 Correct Evaluation Using


the Vectorization Operator

In

Using Array Operators and Functions

rP
TC

You can use vectors and arrays when working with operators and functions in
Mathcad. You can find operators and functions used with vectors and arrays:

Fo

On the Matrices/Tables tab.


Matrices and Tables group.
You can also find Vector and Matrix operators on the Math tab.
Operators and Symbols group.
You can also find Vector and Matrix functions on the Functions tab.
Functions group.

The Vectorization Operator


Many functions that typically use a scalar argument also accept a vector.
This is termed implicit vectorization, which means passing each element,
one-by-one, to the function as an argument.
When a matrix is passed to the same function for element-by-element
processing, an error often occurs or incorrect answers result as shown on
the slide.
You can use element-by-element processing of a function or operator by
selecting the Vectorization
and Math tabs.
2013 PTC

operator located on both the Matrices/Tables

Module 8 | Page 17

Array Functions
The Vector and Matrix Functions category located in the Matrices and Tables
group on the Matrices/Tables and Functions tabs contains a list of functions
that operate on arrays.
The following functions are useful when working with vectors and matrices:

Fo

rP
TC

In

te

rn

al

se

nl

rows and cols Returns the number of rows or columns in an array.


length Returns the number of elements in a vector.
last Returns the index of the last element in a vector. The number
returned depends on the value of ORIGIN.
max and min Returns the maximum or minimum element in an array.
stack Places the arrays one on top of the other.
augment Places the arrays side-by-side.

Module 8 | Page 18

2013 PTC

PROCEDURE - Using Array Operators and Functions


Scenario
Use the Vectorization operator.
Task 1:

Use the Vectorization operator.

se
U

2. Type the function name and


arguments, F1(b), as shown.
Press SPACEBAR until the entire
function name highlights.

nl

1. Define the function, F1(b), and matrix, b, shown.

In

te

rn

al

3. Insert the Vectorization


operator.
Select the Matrices/Tables
tab.
In the Matrices and Tables
group, click Vector and Matrix
.

rP
TC

Operators

Select Vectorization

Fo

You can also insert the


Vectorization
operator by one of the
following methods:
Selecting the
Math tab, clicking
,
Operators
and selecting the
Vectorization
operator.
Press CTRL ^ .

2013 PTC

Module 8 | Page 19

4. Evaluate the function or operator by inserting the Evaluation


operator.

Fo

rP
TC

In

te

rn

al

se

nl

This completes the procedure.

Module 8 | Page 20

2013 PTC

9
y

Module

nl

Units

se

Module Overview

In this module, you learn how to select a unit system and use units in
calculations.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Select a unit system.
Use units in calculations.
Add units to arrays and range variables.
Use angular and temperature units.

2013 PTC

Module 9 | Page 1

Selecting a Unit System


Mathcad currently supports three systems of units.
The SI system is the default unit
system for Mathcad. You can modify
this by selecting the Math tab and
selecting the commands in the Units
group.

Mathcad also supports the following


systems:

nl

CGS
USCS

Figure 1 Units Group

se

Selecting a Unit System


Mathcad currently supports three systems of units.

al

The SI system is the default unit system for Mathcad. Mathcad also supports
the following unit systems:

rn

CGS
USCS

In

te

Every unit system has a set of base dimensions and derived units associated
with it. Mathcad stores all units in terms of the base units for a particular
dimension. Because of this, unit results are initially returned in the base
units for the default system of units.

rP
TC

For example, if you select the SI system as the default unit system:
Length is initially returned in meters, m.
Mass is initially returned in kilograms, kg.
Time is initially returned in seconds, s.

Fo

You can select the default unit system by selecting the Math tab. In the Units
, and select a unit system. Regardless of
group, click Unit System
the unit system selected, you can use units from other systems to define
variables and evaluate results.

Module 9 | Page 2

2013 PTC

PROCEDURE - Selecting a Unit System


Task 1:

Select a default unit system.

1. Select the Math tab.


2. In the Units group, click Unit System

3. Select the default unit system SI from the drop-down list.

rn

al

se

nl

When you change the default unit system, Mathcad converts


all of the evaluated values that have a unit into the new
base unit. Definitions do not change.

Fo

rP
TC

In

te

This completes the procedure.

2013 PTC

Module 9 | Page 3

Using Units
Mathcad enables you to multiply values by built-in units or
custom defined units.
Using Mathcad you can:
Add units to variable definitions.
Change units.
Define a custom unit.

Figure 1 Variable Definition


with Units

Adding Units to Variable Definitions

nl

You can add units to a variable definition by typing them in or by selecting the

se

and select the desired unit.


Math tab. In the Units group, click Units
Mathcad uses the units in calculations and, if possible, simplifies the result
units to a base unit from the default unit system specified for the worksheet.
You can then rescale the results of a calculation in terms of a different unit.

al

Click in the worksheet.


Select the Math tab.

rn

1.
2.

To display results in base units:

te

3. In the Units group, click Base Units


.
Mathcad redisplays the result in terms of unsimplified base units.

rP
TC

In

Mathcad checks your worksheet for dimensional consistency. It is a


units-aware product. The unit checking feature may prevent costly mistakes
in calculations that involve multiple units. Mathcad converts all units to base
units internally. Therefore, you can add or subtract different units from the
same dimension, if the equation is dimensionally correct. If you attempt to
add variables containing units from different dimensions, an error message
appears. If the equation contains any dimensionless or unitless values, they
are treated as though they came from an incompatible dimension.

Fo

Built-in units are predefined variables and you can overwrite them with a
variable of the same name. For example, you can rewrite the built-in unit
m, representing meters, to represent any quantity, but any subsequent
results depending on meters represented by m do not make sense and may
generate an error. To avoid overwriting predefined variables, if you evaluate
the variable you are using, Mathcad evaluates a built-in unit.

Creating Custom Units


Although Mathcad provides an extensive list of built-in units, you can also
use custom units. You can define your own unit if:
Mathcad does not recognize the unit you need.
You want to use a different abbreviation that Mathcad does not recognize.
To create custom units or unit abbreviation definitions, define the custom unit
as a variable at the top of the worksheet or globally. If defined at the top, you
can use a custom unit or unit abbreviation just like a built-in unit anywhere to
the right or below where it is defined to rescale results.
Module 9 | Page 4

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

A custom unit or abbreviation must contain one of Mathcad's built-in units.


Once defined, you can use the custom units the same way you use built-in
units, but they do not display in the Units group.

2013 PTC

Module 9 | Page 5

PROCEDURE - Using Units


Task 1:

Add units to variable definitions.

1. Click in a blank area in the


worksheet and type the variable
name mass.

nl

group, click Operators


Select Definition

2. Insert the Definition


operator.
Select the Math tab.
In the Operators and Symbols

U
al

rn

You can insert


operators by selecting
the Math tab, clicking
the appropriate group,
and selecting the
desired operator or
symbol.

se

te

3. Type 40 in the placeholder and

In

insert the Multiplication


operator.

Fo

rP
TC

Mathcad does
not require the
Multiplication operator
when using units.
You can use implied
multiplication.

4. Insert the kg unit.


In the Units group, click Units
.
Select the kg unit.
You can also type
a unit directly in the
worksheet.

Module 9 | Page 6

2013 PTC

Task 2:

Change units.

1. Evaluate the variable mass


defined in the previous task.
2. Click to the right of the equation.
Press BACKSPACE until the kg
unit is deleted.

nl
O
se
U

Define a custom unit.

te

Task 3:

rn

al

The abbreviation
lb refers to pound
mass, while lbf is the
abbreviation for pound
force.

3. Type lb or insert the lb unit from


the Units group. Click outside
of the region. Mathcad rescales
and redisplays the result. This
result is now locked and will not
be rescaled if the unit system
changes.

rP
TC

In

1. Click in a blank area of the


worksheet and type the unit
variable name cfs.

Fo

2. Insert the Definition


operator.
A custom unit can
also be defined
globally by inserting
the Global Definition
operator.

3. Type the custom unit definition


as shown and click outside of the
region. The custom unit must
contain one of Mathcad's built-in
units.

2013 PTC

Module 9 | Page 7

4. In the definition expression


you have just typed, select the
variable name cfs.
5. In the ribbon, select the Math
tab.
6. Click Labels
group.

from the Style

7. Select Unit from the drop-down


list.

se

nl

You can use a custom


unit to the right or below
where it is defined
in the worksheet to
rescale results.

al

Custom units do not


appear in the Units
group.

Fo

rP
TC

In

te

rn

This completes the procedure.

Module 9 | Page 8

2013 PTC

Adding Units to Arrays and Range Variables


Mathcad enables you to add units to arrays and range variables.
In Mathcad you can add units to:

nl

Arrays.
Range variables.

se

Figure 1 Array Definition


with Units

rn

al

Figure 2 Range Variable


Definition with Units

te

Adding Units to Arrays and Range Variables


You can add units to array elements and range variables.

In

Use one of the following methods to add a unit to an array:

rP
TC

Add a unit to each element of the array.


Add a unit to the entire array.

Fo

When adding units to range variables, you should add the unit to each
element in the range variable definition. A dimensioned range variable must
always specify the second value in the range in the appropriate dimension,
even if the step size is equal to one. If this is not specified, an error message
appears.

2013 PTC

Module 9 | Page 9

PROCEDURE - Adding Units to Arrays and Range


Variables
Task 1:

Add units to an entire array.

1. Click in a blank area of the


worksheet and type the variable
name Shear.

nl
O
se

group, click Operators


Select Definition

2. Insert the Definition


operator.
Select the Math tab.
In the Operators and Symbols

al

te

rn

, and
Operators
selecting the desired
operator.

You can insert


operators by selecting
the Math tab, clicking

rP
TC

In

3. Insert a 5x1 matrix in the


placeholder.
Select the Matrices/Tables
tab.
In the Matrices and Tables
group, click Insert Matrix

Fo

.
Click the cursor and drag to
highlight a 5x1 matrix and
release. A 5x1 matrix of blank
placeholders appears in the
original placeholder for the
variable.

Module 9 | Page 10

2013 PTC

nl

4. Type the numbers shown in the


placeholders. Press SPACEBAR
to highlight the entire matrix.

5. Insert the Multiplication


operator.

, and

Add units to each element of an array.

te

Task 2:

rn

al

tab, clicking Units


selecting kip.

se

6. Type kip in the placeholder, or


insert it by selecting the Math

Fo

rP
TC

In

1. Insert a 5x1 matrix Shear1 as


shown.

2. In each placeholder, type each


matrix element and multiply by
the unit shown.
Elements of an array
can be from different
systems. Mathcad also
supports arrays with
mixed dimensions.

2013 PTC

Module 9 | Page 11

Task 3:

Add units to a range variable.

1. Type the variable name Press


and insert the Definition
operator.
2. Complete the following:

nl

Type 1 and insert a Multiplication


operator.
Type psi in the placeholder.
Press COMMA. Two placeholders and the range variable operator
appear.

se

In the first placeholder type 2 and insert a Multiplication


operator.
Type psi in the placeholder.

In

te

rn

al

In the second placeholder type 5 and insert a Multiplication


operator.
Type psi in the placeholder.

Fo

rP
TC

3. To evaluate the range variable,


type the variable name Press
and press =.
The variable is
evaluated in the default
units for the worksheet.
You can then change
these to the desired
unit, as shown.

This completes the procedure.

Module 9 | Page 12

2013 PTC

Using Angular Units


Mathcad assumes that values provided for functions requiring
an angular argument are in radians.
You must specify degrees when
using them in Mathcad.

nl

Figure 1 Default Angular Units

se

Figure 2 Using Degrees

Using Angular Units

te

rn

al

Mathcad assumes that values provided for functions requiring an angular


argument are in radians. If you use a number or a variable as a function
argument without a unit associated to it, the function uses that argument as if
it is in radians. If you use degrees, you must specify them. The number or
variable that you use as the argument must have degrees in the definition.

Fo

rP
TC

In

Functions returning angular measurements provide the initial results in


radians. You can then edit the result and use degrees as the unit.

2013 PTC

Module 9 | Page 13

Using Temperature Units


Temperature units do not follow a typical multiplicative
relationship with other temperature units.
Mathcad supports the following temperature units:

nl

Kelvin.
Rankine.
Degrees Fahrenheit.
Change in degrees Fahrenheit.
Degrees Celsius.
Change in degrees Celsius.

se

Using Temperature Units

rn

al

Mathcad enables you to type temperature expressions in natural notation and


return results that have the quantity temperature associated with them. The
most common temperature scales are Fahrenheit and Celsius. In Mathcad,
these temperature units do not follow a typical multiplicative relationship with
other temperature units. These scales have a multiplicative factor and an
additive constant in the transformation. Kelvin and Rankine temperatures are
related in the usual multiplicative manner.

te

In Fahrenheit and Celsius units, temperature differences are required to


convert results when finding the difference between two temperatures.

rP
TC

In

Example of calculating a correct temperature difference:

Fo

Example of calculating an incorrect temperature difference:

The incorrect equation is obtained because both temperatures were


converted internally to degrees K, the default temperature unit. The resulting
difference was then evaluated as 0 K. When 0 K is then converted to
Fahrenheit, the result is -459.67. Degrees are measured against the
absolute zero while a change in degrees represents the change between
two temperatures.
Temperature differences are also required when you add two temperatures,
because doing so implies a change from the current temperature.

Module 9 | Page 14

2013 PTC

PROCEDURE - Using Temperature Units


Task 1:

Define variables using degrees Celsius or Fahrenheit.

1. In a blank area of the worksheet,


type the variable name Temp.

nl

group, click Operators


Select Definition

2. Insert the Definition


operator.
Select the Math tab.
In the Operators and Symbols

rn

al

, and
Operators
selecting the desired
operator.

se

You can insert


operators by selecting
the Math tab, clicking

In

te

3. Type 45 in the placeholder.

rP
TC

4. Insert a Fahrenheit temperature


unit.
Select the Math tab.
In the Units group, click Units

Fo

.
Select F.

You can insert units


by selecting the Math
tab, clicking Units
, and selecting
the desired unit. Use
implied multiplication
when defining units.
You can insert a
degrees Celsius
temperature unit using
the same method.

2013 PTC

Module 9 | Page 15

Task 2:

Rescale temperatures to degrees Celsius or Fahrenheit from


degrees Kelvin or Rankine.

1. Define and evaluate a


temperature variable using
Kelvin as shown.

nl

2. Click in the math region


containing the temperature
evaluation to the right of the K.
Press BACKSPACE until the K
is deleted.

te

rn

1. Type 10 and insert a Fahrenheit


temperature unit as shown.
Press .

Evaluate temperature differences.

al

Task 3:

se

3. Insert a Fahrenheit temperature


unit and click outside of the
region to evaluate.

operator.

rP
TC

Multiplication

In

2. Type 10 and insert a

Fo

3. Insert a Change F temperature unit. Press =.

4. Click to the right of the K and press BACKSPACE until the K is deleted.
Insert a F temperature unit. Click outside of the region to evaluate.

This completes the procedure.

Module 9 | Page 16

2013 PTC

10
y

Module

nl

2-D Plotting

se

Module Overview

In this module, you learn how to plot data and functions on a 2-D plot.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Plot data in 2-D.
Plot functions in 2-D.
Format a 2-D plot and axes.
Use units with 2-D plots.

2013 PTC

Module 10 | Page 1

Plotting Data in 2-D


You can plot data stored in vectors on 2-D plots.
2-D plots of data in Mathcad have
the following properties:

nl

They are plotted as a line plot by


default.
A simple legend is shown along
the vertical y-axis.
Axes limits are automatically
selected based on the properties
of the data set.
Both axes are automatically
partitioned and numbered.

Figure 2 2-D Plot

rP
TC

In

te

rn

al

se

Figure 1 Data Set

Plotting Data in 2-D

Fo

You can plot data stored in vectors on 2-D plots. When plotting vectors of
data, you must store the data to be plotted in two vectors of equal length. The
data must be free of strings or variables, and functions which do not equal
scalar quantities. For large vectors, you can determine the number of rows
using the built-in rows function.
You can create vectors by:
Manually typing them in.
Using a function or a range variable.
Importing them from a data source, such as Microsoft Excel.
Once plotted, the graphs have the following properties:
They are plotted as a line plot by default.
A simple legend is shown along the vertical y-axis.
Axes limits are automatically selected based on the properties of the data
set.
Both axes are automatically partitioned and numbered.
Module 10 | Page 2

2013 PTC

PROCEDURE - Plotting Data in 2-D


Task 1:

Plot data on a 2-D graph.

1. Create two vectors of data, x and


y, as shown.

nl

2. Insert a plot region.


Select the Plots tab.
In the Traces group, click

rn

al

Select XY Plot
. A blank
plot region appears.

se

Insert Plot

Fo

rP
TC

In

te

3. Type y in the y-axis placeholder,


and type x in the x-axis
placeholder as shown. Click
outside of the plot region to
display the plot.

2013 PTC

Module 10 | Page 3

Task 2:

Format the plot to display individual data points.

nl

1. Click y to select the trace.

rn

al

.
Symbol
Select x.
In the Styles group, click Line

se

2. Display the data as points.


Select the Plots tab.
In the Styles group, click

In

te

.
Style
Select (none). The data
displays as data points.

Fo

rP
TC

This completes the procedure.

Module 10 | Page 4

2013 PTC

Plotting Functions in 2-D


You can plot functions of a single independent variable on 2-D
plots.
In Mathcad you can plot:
User-defined functions.
Built-in functions.
A quickplot.

Figure 2 Function Quickplot

te

rn

al

se

nl

Figure 1 User-Defined Function

Plotting Functions in 2-D

rP
TC

In

You can plot functions of a single independent variable on a 2-D plot. In


Mathcad you can plot:
User-defined functions.
Built-in functions.
A quickplot.
Quickplots have the following properties:

Fo

The horizontal axis must be populated with the independent variable, not
previously defined.
The plot is made over a default domain of 10 to 10, if possible.

2013 PTC

Module 10 | Page 5

PROCEDURE - Plotting Functions in 2-D


Task 1:

Plot a function using a quickplot.

1. Define the function shown.

When defining the


function, select an
independent variable
that you have not
previously used in the
worksheet.

se

Insert Plot

nl

2. Insert an x-y plot region.


Select the Plots tab.
In the Traces group, click

rn

al

Select XY Plot
. A blank
plot region appears.

Fo

rP
TC

In

te

3. Type the function name and


arguments, Plot(x), in the
vertical axis placeholder. Type
the independent variable, x, in
the horizontal axis placeholder.
Click outside of the plot region to
display the plot.

Task 2:

Plot a function using a defined independent variable.

1. Define the function shown.

2. Define a range variable that


specifies the plot domain.
For a smooth plot, the
second value specified
must create a small
step.

Module 10 | Page 6

2013 PTC

Manually edit the axis limits.

nl

Task 3:

3. Insert a blank x-y plot region.


Type the function name and
arguments, Plot(x), in the
vertical axis placeholder. Type
the independent variable, x, in
the horizontal axis placeholder.
Click outside of the plot region to
display the plot.

rn

al

se

1. Click the 6.5 axis limit and press


BACKSPACE until the number
deletes, as shown.

In

te

2. Type a new limit, 5, in the


placeholder. Click outside of the
plot region to display the plot.

Fo

rP
TC

You can change


the remaining axis
limits using the same
procedure.

This completes the procedure.

2013 PTC

Module 10 | Page 7

2-D Plot Formatting


Mathcad provides several options for formatting a 2-D plot.
Plot formatting features in Mathcad
include:

se

nl

Adding vertical markers.


Adding horizontal markers.

Figure 1 Plot Markers

2-D Plot Formatting

rn

al

There are many formatting features available for 2-D plots in Mathcad.
Features discussed here are:

Fo

rP
TC

In

te

Adding vertical markers.


This feature adds vertical lines to a plot at specified locations.
Adding horizontal markers.
This feature adds horizontal lines to a plot at specified locations.

Module 10 | Page 8

2013 PTC

PROCEDURE - 2-D Plot Formatting


Task 1:

Plot a function using a quickplot.

1. Define the function shown.

When defining the


function, select an
independent variable
that you have not
previously used in the
worksheet.

nl

2. Insert an x-y plot region.


Select the Plots tab.
In the Traces group, click

rn

al

Select XY Plot
. A blank
plot region appears.

se

Insert Plot

Fo

rP
TC

In

te

3. Type the function name and


arguments, Plot(x), in the
vertical axis placeholder. Type
the independent variable, x, in
the horizontal axis placeholder.
Click outside of the plot region to
display the plot.

Task 2:

Add markers to a plot.

1. Double-click inside of the plot


region.
2. Insert a vertical marker.
Select the Plots tab.
In the Markers group, click
. A
Add Vertical Marker
vertical marker appears on the
plot.

2013 PTC

Module 10 | Page 9

3. Highlight the number in the


callout and press BACKSPACE
to delete the number. Type 6
in the callout and click outside
of the plot region. The marker
moves to the location specified.

se

4. Click the marker callout to delete the marker.


Select the Plots tab.

nl

You can also move the


marker by placing the
cursor over the marker.
The cursor changes
to a double-headed
arrow. Click the
marker and drag it
to the desired location.

. The marker is

al

In the Markers group, click Delete Marker


deleted.

Fo

rP
TC

In

te

rn

This completes the procedure.

Module 10 | Page 10

2013 PTC

2-D Trace Formatting


Mathcad enables you to plot multiple traces on a single plot.
Once plotted, you can individually
format each trace. Formatting
options include:

nl

Symbol style, color, and weight.


Line type, weight, and color.
Trace type.

se

Figure 1 Plotting Multiple Traces

2-D Trace Formatting

rP
TC

In

te

rn

Symbol style
Symbol weight
Line type
Line weight
Color
Trace type (line, points, bar)

Fo

al

Mathcad enables you to plot multiple traces on a single plot. Once plotted,
you can individually format each trace. Formatting options include:

2013 PTC

Module 10 | Page 11

PROCEDURE - 2-D Trace Formatting


Task 1:

Add additional traces to a plot.

nl

1. Define the functions, y1(x) and


y2(x), and the independent
variable, x, shown.

se
te

rn

Select XY Plot
. A blank
plot region appears.

al

Insert Plot

2. Insert a x-y plot region.


Select the Plots tab.
In the Traces group, click

In

3. Type x in the horizontal axis


placeholder.

rP
TC

4. Add a trace.
Click in the vertical axis
placeholder.
Select the Plots tab.
In the Traces group, click Add

Fo

. A second vertical
Trace
axis placeholder appears.

5. Type y1(x) in the first vertical axis


placeholder and type y2(x) in the
second vertical axis placeholder,
as shown.

Module 10 | Page 12

2013 PTC

Task 2:

Format a trace.

1. Click in the first vertical axis


expression, y1(x). Any formatting
selections will be applied to this
trace.

Click Symbol
select x.

2. Format the trace.


Select the Plots tab.
In the Styles group, make the
following selections:

Click Line Style


select (none).

nl

, and

Fo

rP
TC

In

te

rn

This completes the procedure.

al

You can also modify


Trace Color and Trace
Thickness.

se

, and

2013 PTC

Module 10 | Page 13

2-D Axes Formatting


Mathcad provides many options to format axes on a 2-D plot.
The formatting options available for
the 2-D plot axes include:

nl

Axes Formatting
Log scale
Cross axes at 0,0
Tick marks
Tick mark values
Axis expressions

rP
TC

In

te

rn

al

se

Figure 1 Default Plot

Figure 2 Formatted Axes

2-D Axes Formatting

Fo

Mathcad provides many options to format axes on a 2-D plot. The formatting
options available for the 2-D plot axes include:
Axes Formatting
Log scale Plot using a logarithmic scale.
Cross axes at 0,0.
Tick marks Add or remove tick marks from the axes.
Tick mark values Add or remove values from the tick marks on the
axes.
Axis expressions Add or remove the axes expressions.
Mathcad also provides a feature that enables you to change the displayed
format and precision of the axis limits and markings. The options available
are:
General
Decimal
Module 10 | Page 14

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

Scientific
Engineering
Percent

2013 PTC

Module 10 | Page 15

PROCEDURE - 2-D Axes Formatting


Task 1:

Add additional traces to a plot.

nl

1. Define the functions, y1(x) and


y2(x), and the independent
variable, x, shown.

se
te

rn

Select XY Plot
. A blank
plot region appears.

al

Insert Plot

2. Insert an x-y plot region.


Select the Plots tab.
In the Traces group, click

In

3. Type x in the horizontal axis


placeholder.

rP
TC

4. Add a trace.
Click in the vertical axis
placeholder.
Select the Plots tab.
In the Traces group, click Add

Fo

. A second vertical
Trace
axis placeholder appears.

5. Type y1(x) in the first vertical axis


placeholder and type y2(x) in the
second vertical axis placeholder,
as shown. Click outside of the
plot region to display the plot.

Module 10 | Page 16

2013 PTC

nl
O
se

al

1. You can edit the first, second,


and last tick marks. Editing the
second tick mark changes the
numbering interval for the axis.
To edit the tick marks:
Click to the right of the 0 on the
x-axis. The first, second, and
last values on the axis change
to black, indicating that you
can edit them.
Press BACKSPACE to delete
the 0 and type 1.0.
Repeat for the second and
last value. Type 1.5 to replace
the second value. Type 5.0 to
replace the last value.
Click outside of the plot region
to display the plot.

Edit the tick mark values on the x-axis.

Task 2:

rP
TC

In

te

rn

2. Move the y-axis.


Cursor over the y-axis.
The cursor changes to a
double-headed arrow.
Click the cursor and drag it to
a new location.

Fo

This completes the procedure.

2013 PTC

Module 10 | Page 17

Using Units with 2-D Plots


In Mathcad, you can plot a function or data with units.
To plot a function or data with units:
Define the data or function.
Plot the data. Include the units in
the axis expression.
Click outside of the plot region.

Figure 2 Data Plot

te

rn

al

se

nl

Figure 1 Dimensioned Input Data

In

Using Units with 2-D Plots

rP
TC

In Mathcad, you can plot a function or data with units. To plot a function, or
data, with units:
Define the data or function.
Plot the data. Include the units in the axis expression.
Click outside the plot region.

Fo

The tick marks are not associated with units. Only the axis
expressions can have units.

Module 10 | Page 18

2013 PTC

PROCEDURE - Using Units with 2-D Plots


Task 1:

Plot a 2-D plot.

rn

Insert Plot

al

2. Insert an x-y plot region.


Select the Plots tab.
In the Traces group, click

se

nl

1. Create the data matrices for Shear, in kip, and Position, in ft, as
shown.

rP
TC

In

te

Select XY Plot
. A blank
x-y plot region appears.

Fo

3. Type Shear in the y-axis


placeholder. Type Position in
the x-axis placeholder. Click
outside of the plot region.

2013 PTC

If units are not included


in the plot arguments,
the data is plotted
using default units.

Module 10 | Page 19

Task 2:

Change the plot units.

1. Place the cursor to the right of


the N in the y-axis placeholder.
2. Press BACKSPACE to delete the
N. Type kip in the placeholder.
3. Place the cursor to the right of
the m in the x-axis placeholder.

nl

4. Press BACKSPACE to delete the


m. Type ft in the placeholder.
Click outside of the region.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

Module 10 | Page 20

2013 PTC

11
y

Module

nl

Project Day 1

se

Module Overview

Using Mathcad and the skills that you have learned so far complete one of
the projects in this module.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Define variables.
Create and evaluate equations.
Use operators.
Define range variables.
Create and use matrices.
Create a 2D plot.

2013 PTC

Module 11 | Page 1

Structural Engineering Project Day 1


In this project, you analyze a simply supported beam.

5.

nl
O
Figure 1 Beam Section

rP
TC

In

te

6.

se

4.

3.

al

2.

Calculate reactions, moment,


slope, and deflection at the
supports.
Input the deflection equation
for the deflection along the
length of the beam.
Differentiate the deflection
equation to derive the equation
for slope, moment, and shear.
Plot the deflection, slope,
moment, and shear.
Calculate the average shear
stress at the intersection
between the flange and the
web at the location of maximum
shear.
Format the Mathcad document
with headers and footers.

rn

1.

Complete the following exercise


steps:

Figure 2 Beam Loading

Fo

Structural Engineering Project Day 1


In this project, you analyze a simply supported beam. The beam section is a
914x305x201 I beam and has the following properties:

t=20.2 mm
h=903.3 mm
b=303.3 mm
s= 15.1 mm
Ix=325253 cm4
E=120 kN/mm2

The beam is a simply supported beam with the following dimensions and load:
L=15 m
a= 5 m
W=18 kN
Module 11 | Page 2

2013 PTC

Complete the following exercise steps:


1.
2.
3.
4.
5.

Fo

rP
TC

In

te

rn

al

se

nl

6.

Calculate reactions, moment, slope, and deflection at the supports.


Input the deflection equation for the deflection along the length of the
beam.
Differentiate the deflection equation to derive the equation for slope,
moment, and shear.
Plot the deflection, slope, moment, and shear.
Calculate the average shear stress at the intersection between the
flange and the web at the location of maximum shear.
Format the Mathcad document with headers and footers.

2013 PTC

Module 11 | Page 3

Mechanical Engineering Project Day 1


In this project, you calculate the critical speed of a shaft bearing
with an asymmetrical load, and how the critical speed varies
with load location.
Complete the following exercise
steps:

y
nl
Figure 1 Shaft

Figure 2 Load Diagram

In

te

rn

al

3.
4.

2.

Define the variables and


calculate the critical speed of
the shaft.
Calculate how the critical
speed varies with load location.
Plot the results.
Format the Mathcad document
with headers and footers.

se

1.

Mechanical Engineering Project Day 1

Youngs Modulus, E = 210 GPa


Outer Diameter, D = 10 cm
Inner Diameter, d = 9 cm
Shaft Length, l = 1 m

Fo

rP
TC

In this project, you calculate the critical speed of a shaft bearing with an
asymmetrical load, and how the critical speed varies with load location. The
shaft has the following properties:

The shaft has the following load properties:


Mass, M = 10 kg
Load Location, a = 50 cm
Complete the following exercise steps:
1.
2.
3.
4.

Define the variables and calculate the critical speed of the shaft.
Calculate how the critical speed varies with load location.
Plot the results.
Format the Mathcad document with headers and footers.

Module 11 | Page 4

2013 PTC

12
y

Module

nl

3-D Plotting

se

Module Overview

In this module, you learn how to plot data and functions on a 3-D plot.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Plot data in 3-D.
Plot functions in 3-D.
Format a 3-D plot and axes.

2013 PTC

Module 12 | Page 1

Plotting Functions in 3-D


You can create 3-D plots from a function of two variables.
The following data types can be
plotted:

nl

A function of two variables.


A vector-valued function.

In

te

rn

al

se

Figure 1 Function Plot

Figure 2 Vector-Valued
Function Plot

rP
TC

Plotting Functions in 3-D


You can create 3-D plots from a function of two variables. The following data
types can be plotted:

Fo

A function of two variables.


A vector-valued function. The vector-valued function can have either one
or two variables and must contain three elements defining the x, y, and z
coordinates.
When you define a function and graph it in three dimensions, you are creating
a QuickPlot with a default domain of -10 to 10. Once the function is plotted
you can do the following:
Change the plot domain.
Change the trace type.
Check for singularities in the default domain.
Occasionally, the function being plotted has a singularity over the default
domain in both independent variables. When this function is plotted as
a QuickPlot, Mathcad issues an error message. It is not possible to
use range variables to control the domain of the plot. Therefore, the
ranges must be modified.
Module 12 | Page 2

2013 PTC

PROCEDURE - Plotting Functions in 3-D


Task 1:

Plot a function in three dimensions.

1. Define the function shown.

2. Insert a 3D plot region.


Select the Plots tab.
In the Traces group, click

nl

Insert Plot

rn

al

3. Type the function name only,


S, with no arguments, in the
placeholder. Click outside the
plot to display the surface plot.

se

Select 3D Plot
. A blank
plot region appears.

rP
TC

In

te

A QuickPlot always
appears over the
default domain of
10 to 10 for both
independent variables.

Change the plot domain.

Fo

Task 2:

1. Click in the plot region inserted


in task 1.
2. Click the x axis in the axis
selector. The x axis that appears
in both the axis selector and in
the plot is highlighted in blue.

2013 PTC

Module 12 | Page 3

nl

3. Click the tick mark values and


edit them, as shown.

In

Change the default domain to not include any values that cause a
singularity in the plotted function.

rP
TC

Task 3:

te

rn

al

se

4. Click outside the region to view


the modified plot.

1. Define the function shown.

Fo

2. Insert a blank 3D plot region and


type the function name, Sing, no
arguments, in the placeholder.
Review the resulting error
message.

Module 12 | Page 4

2013 PTC

3. Click the appropriate axis in the


axis selector and modify the x
and y axis ranges as follows:
x axis Range from 2 to 5
y axis Range from 3 to 5

nl

4. Click outside the plot region to


view the modified results.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

2013 PTC

Module 12 | Page 5

Formatting a 3-D Plot


Mathcad provides many options for formatting a 3-D plot.
3-D plot formatting options include:
Appearance.
Axes.
View control.
Suppressing the plot arguments.

se

nl

In

Formatting a 3-D Plot

Figure 2 View Control

te

rn

al

Figure 1 Formatted 3-D Plot

rP
TC

Mathcad provides many options for formatting a 3-D plot. 3-D plot formatting
options include the following:
Appearance.
Axes.
View Control.
Suppressing the plot arguments.

Fo

Appearance

Appearance options are located on the Plots tab, in the Styles group. These
options enable you to add color to the traces and perform other basic
formatting changes. The following options are available:

Fill options
Line options
Symbol options
Color options

If there is more than one plot in the graph, these options are specific to each
plot. You can fill each plot with its own color, lines, and configure other
options.
You can also define the grid size per trace in the x and y directions by
selecting the number of points in the Traces group.
Module 12 | Page 6

2013 PTC

Axes
Axes options are located on the Plots tab, in the Axes group, and in the plot
region. You can modify the axis tick marks and tick mark values.
To modify a specific axis click the axis using the Axis Selector in the
upper-right corner of the plot. The Editable Axis, located on the right side of
the plot, can then be used to edit the tick mark values.

View Control

nl

To modify the view and orientation of the plot use the View Control located in
the upper-left corner of the plot. The View Control options enable you to spin,
pan, zoom, or reset the view of the plot.

Suppressing the Plot Arguments

se

To clean up the appearance of a 3-D plot, suppress the display of the plot
argument(s) on the bottom of the plot. To toggle the arguments on and off:

Select the Plots tab.

In the Axes group, click Axis Expressions

Fo

rP
TC

In

te

rn

al

Suppressing the arguments gives a cleaner look to the plot within the
Mathcad document.

2013 PTC

Module 12 | Page 7

Plotting Data in 3-D


You can store data in various formats. The format that is passed
to the 3-D plot operator affects how the plot is rendered.
You can plot data as:

se

nl

A three column matrix.


An m x n matrix.

rP
TC

In

te

rn

al

Figure 1 A Three Column


Matrix Plot

Figure 2 An m x n Matrix Plot

Fo

Plotting Data in 3-D

You can store data in various formats. The format that is passed to the 3-D
plot operator affects how the plot is rendered.
You can plot data as:
A three column matrix. The three columns in the matrix represent the x,
y, and z coordinates.
An m x n matrix. Mathcad plots each element as an elevation in the z-axis
versus its respective row, x-axis, and column, y-axis, index.

Module 12 | Page 8

2013 PTC

PROCEDURE - Plotting Data in 3-D


Task 1:

Plot a three column matrix.

1. Define the matrix, as shown.

nl

2. Insert a 3D plot region.


Select the Plots tab.
In the Traces group, click

se

Insert Plot

al

Select 3D Plot
. A blank
plot region appears.

Fo

rP
TC

In

te

rn

3. Type the matrix name M in the


placeholder. Click outside the
plot to display the data plot.

4. Review the plot. Note the following:


Each column in the matrix represents the x, y, and z coordinates.
Each row represents one point.
The points are formatted to appear larger than the default. Click in
the plot region and you can format this as follows:
Select the Plots tab.
.
In the Styles group, click Trace Thickness
Select the thickness required to display the data points.

2013 PTC

Module 12 | Page 9

Task 2:

Plot data using an m x n matrix.

1. Define the matrix, as shown.

nl
O

se

Insert Plot

2. Insert a 3D plot region.


Select the Plots tab.
In the Traces group, click

al

Select 3D Plot
. A blank
plot region appears.

rP
TC

In

te

rn

3. Plot the data.


Type the matrix name MM in
the placeholder. Click outside
the plot to display the data plot.
To format the plot click in the
plot region and select the
Plots tab.
In the Styles group, click

Fo

and select the


Symbol
circular dot.
In the Styles group, click Line
and select (none).

Style

You can increase the


trace thickness for
better visibility.
4. Review the plot. Note that each point is plotted as an elevation in the
z-axis versus its respective row, x-axis, and column, y-axis, index.
This completes the procedure.

Module 12 | Page 10

2013 PTC

Plotting Multiple Traces


You can plot multiple traces on a single plot.

se

nl

You can also add traces to an


existing plot.

al

Figure 1 Multiple Traces

rn

Plotting Multiple Traces

te

You can plot multiple traces on a single plot, or add traces to an existing plot.

Fo

rP
TC

In

By default, the second trace appears as the same type as the first. You can
then modify each plot to the appropriate type.

2013 PTC

Module 12 | Page 11

PROCEDURE - Plotting Multiple traces


Task 1:

Plot multiple traces on a single plot.

1. Define the functions shown.

nl
O

se

Insert Plot

2. Insert a 3D plot region.


Select the Plots tab.
In the Traces group, click

te

rn

3. Type the function name only,


P, with no arguments, in the
placeholder.

al

Select 3D Plot
. A blank
plot region appears.

rP
TC

In

4. Add a second trace.


Select the Plots tab.
In the Traces group, click

Fo

. A second
Add Trace
placeholder appears.
Type the function name only,
Q, with no arguments, in the
placeholder. Click outside
the plot to display the surface
plots.
A QuickPlot always
appears over the
default domain of
10 to 10 for both
independent variables.

Module 12 | Page 12

2013 PTC

Task 2:

Format the traces.

1. Change the plot to symbols for the first trace.


Click in the plot region and select the first trace, P.
Select the Plots tab.
and select the dot symbol.
and select (none).

and select red.

se

In the Styles group, click Trace Color

In the Styles group, click Line Style

2. Change the color of the second trace.


Select the second trace, Q in the plot region.
Select the Plots tab.

nl

In the Styles group, click Symbol

rP
TC

In

te

rn

al

3. Click outside the plot region to


display the plot.

Fo

This completes the procedure.

2013 PTC

Module 12 | Page 13

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 12 | Page 14

2013 PTC

13
y

Module

nl

Boolean Conditions

se

Module Overview

In this module, you learn how to use Boolean operators to create equations,
conditional statements, and Piecewise Continuous functions.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Use Boolean operators.
Use Piecewise Continuous functions.

2013 PTC

Module 13 | Page 1

Using Boolean Operators


You can use Boolean operators to evaluate Boolean expressions
and specify constraints in solve blocks.
You can locate Boolean operators by
selecting the Math tab and clicking

from the Operators


Operators
and Symbols group. You can use
them to:

rn

al

se

nl

Write equations used in solving


systems of equations.
Create conditional statements.
Document equations which do not
need to be evaluated.

te

Figure 1 The Boolean Operators

In

Using Boolean Operators

rP
TC

You can use Boolean operators to evaluate Boolean expressions and specify
constraints in solve blocks. You can locate Boolean operators by selecting
from the Operators and Symbols
the Math tab and clicking Operators
group. They include Comparison and Logical operators. You can use them to:

Fo

Write equations used in solving systems of equations.


Create conditional statements.
Document equations which do not need to be evaluated.

Module 13 | Page 2

2013 PTC

Writing Equations Using Boolean Operators


All equations used inside a solving construct must use Boolean
operators.

The Equal To
operator is
the most commonly used Boolean
operator when solving a system of
equations.

nl

Figure 1 Boolean Equal


to Operator

se

Figure 2 Evaluation Operator

Writing Equations Using Boolean Operators

al

All equations used inside a solving construct must use Boolean operators.

te

rn

The Equal To
operator is the most commonly used Boolean operator
when solving a system of equations. You can use it to express equality
between two sides of an equation. A Boolean Equal To operator appears as
a bold equal sign to distinguish it from the Evaluation operator.

Fo

rP
TC

In

Mathcad does not evaluate equations created with Boolean operators unless
they are used in a Mathcad program or another construct requiring a Boolean
condition. Therefore, it is ideal to use Boolean operators for documenting
equations.

2013 PTC

Module 13 | Page 3

Creating Conditional Statements


Boolean operators, unlike other operators, can only return a
zero or one.
Mathcad returns the following results
for a conditional statement:

nl

If the expression using the


Boolean operator is true, the
Boolean operator returns a one.
If the expression using the
Boolean operator is false, the
Boolean operator returns a zero.

se

Figure 1 True Expression

al

Creating Conditional Statements

Figure 2 False Expression

rn

Boolean operators, unlike other operators, can only return a zero or one. They
are useful in performing tests or comparisons within conditional expressions.

In

te

If the expression using the Boolean operator is true, the Boolean operator
returns a one.

rP
TC

If the expression using the Boolean operator is false, the Boolean operator
returns a zero.
Boolean expressions are those whose results are either true or false. For
example, 1 > 2 is Boolean because its value is false, represented as a 0 in
Mathcad. The Boolean operators enable you to set up expressions, which
you can evaluate like any other Mathcad expression.

Fo

You can use Boolean operators to write functions that are not uniform over a
range. You can then integrate and differentiate these functions.

Module 13 | Page 4

2013 PTC

Using Piecewise Continuous Functions


A function that is not uniform over its range is known as a
Piecewise function.
To create Piecewise Continuous
functions using Boolean operators:

nl

Define a range of values over


which the function is to be
evaluated.
Define the function using Boolean
operators.
Graph the function to validate the
results.

rP
TC

In

te

rn

al

se

Figure 1 Piecewise Continuous


Function

Figure 2 Piecewise Continuous


Function Graph

Using Piecewise Continuous Functions

Fo

A function that is not uniform over its range is known as a Piecewise function.
Mathcad has six Piecewise Continuous built-in functions.
To create Piecewise Continuous functions using Boolean operators:
Define a range of values over which the function is to be evaluated.
Define the function using Boolean operators.
Graph the function to validate the results.

2013 PTC

Module 13 | Page 5

PROCEDURE - Using Piecewise Continuous Functions


Task 1:

Define the range and function to use in the Piecewise Continuous


function.

1. Define the range shown, over


which you will evaluate the
function.

nl

You can insert


operators or constants
by selecting the Math
tab. In the Operators
and Symbols group,
select the desired
operator or constant.

U
al

te

rn

You can type in or


insert functions in the
worksheet by selecting
the Functions tab. In
the Functions group,
click All Functions

se

2. Define the function shown to


use in the Piecewise Continuous
function.

rP
TC

In

. Expand the
appropriate group,
and select the desired
function.

Fo

3. Define the Piecewise Continuous


function.
Type the function name and
arguments g(x).
Insert the Definition
operator.
Insert the if function.
Select the Functions tab.
In the Functions group, click
.
All Functions
Expand the Piecewise
Continuous group, and
select the if function.
4. Complete the placeholders as
shown.

Module 13 | Page 6

2013 PTC

5. Graph the functions f(x) and g(x)


to validate.

nl

A symbol was selected


for the g(x) trace to
make identification
clearer.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

2013 PTC

Module 13 | Page 7

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 13 | Page 8

2013 PTC

14
y

Module

nl

Symbolics

se

Module Overview

In this module, you learn how to use Mathcad symbolic features.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Use symbolic calculation features.
Use symbolic algebra.

2013 PTC

Module 14 | Page 1

Symbolics
Mathcad can perform operations on symbolic expressions,
expressions that contain variables or mathematical symbols,
and return results in symbolic form.
You can perform symbolic
calculations on:

Variables
Functions

nl

Symbolic calculations can return


results in terms of:

Floating point numbers.


Undefined variables and functions.

se

Figure 1 Numeric Evaluation

al

Figure 2 Symbolic Evaluation

rn

Symbolics

rP
TC

In

te

All the calculations shown in Mathcad to this point have been numeric.
Numeric calculations require that all variables and functions involved be
defined to the left or above where the calculation is made. They always
return answers in terms of floating point numbers. Numeric calculations
rely on built-in algorithms and tolerances to perform calculations quickly
and accurately.
Mathcad can also perform operations on symbolic expressions, expressions
that contain variables or mathematical symbols, and return results in symbolic
form.

Fo

You can perform symbolic calculations on variables and functions, which


may or may not be defined in the worksheet. They can also return results in
terms of floating point numbers, or undefined variables and functions. They
also may reveal relationships among variables that may not be apparent
from numeric results.
Symbolic evaluations are performed by clicking the Symbolic Evaluation

operator. You can use the Symbolic Evaluation operator to evaluate


expressions containing Mathcad operators, including integrals, derivatives,
matrix operations (most matrix functions), summations, and products.
Mathcad simplifies the expression by performing arithmetic and combining
like terms. If the variables used in the expressions have an assigned value
you receive a numeric result.
Examples:
Derivatives
Module 14 | Page 2

2013 PTC

Indefinite Integrals

Definite Integrals

Fo

rP
TC

In

te

rn

al

se

nl

When evaluating a definite integral, note that the symbolic


answer is exact. Numeric evaluation results in an approximate,
floating point answer.

2013 PTC

Module 14 | Page 3

PROCEDURE - Symbolics
Task 1:

Evaluate a result symbolically.

1. Type the expression to be


evaluated symbolically, as
shown.

nl

You can symbolically


evaluate expressions
that have variables not
assigned to numeric
values.

se
U

rn

.
group, click Symbolics
Select Symbolic Evaluation

al

the Symbolic Evaluation


operator.
Select the Math tab.
In the Operators and Symbols

2. Position the cursor to the right of


the expression, as shown. Insert

te

rP
TC

In

The Symbolic
Evaluation operator
can also be inserted
by selecting the Math
tab. In the Operators
and Symbols group,

Fo

click Operators
and select Symbolic
Evaluation

3. Click outside the region.

This completes the procedure.

Module 14 | Page 4

2013 PTC

Symbolic Calculation
When you evaluate an expression with the Symbolic Evaluation
operator, Mathcad simplifies the result by performing arithmetic
and combining like variables.
Symbolic keywords provide an
additional level of control over
symbolic evaluation.

nl

Figure 1 Symbolic Evaluation

se

Figure 2 Symbolic Evaluation


With Keyword

Symbolic Calculation

te

rn

al

When you evaluate an expression with the Symbolic Evaluation operator,


Mathcad simplifies the result by performing arithmetic and combining like
variables. It is a live operator, meaning that if you make a change to the
worksheet anywhere above or to the left of the expression, Mathcad updates
the result automatically. It also uses previously defined functions and
variables to reduce expressions where appropriate.

rP
TC

In

To perform more complex symbolic operations, you can insert a keyword that
specifies the operation before the symbolic equals sign. Symbolic keywords,
located in the Operators and Symbols group, Symbolic section, provide an
additional level of control over symbolic evaluation.
Evaluating a definite integral, using the Symbolic Evaluation operator, results
in a symbolic expression as shown in Figure 1.

Fo

You can have the result appear as a floating point approximation by using the
keyword float as shown in Figure 2.
When you apply a keyword to an expression containing a variable that has an
assigned value, Mathcad first replaces the variable with its value and then
applies the keyword. If you do not want Mathcad to substitute the assigned
value of a variable before applying the keyword you can use one of the
following clear functions:
clear(x,y,..) Clears variables both symbolically and numerically.
clearsym(x,y,...) Clears variables symbolically but not numerically. The
subscript sym is a literal subscript.

2013 PTC

Module 14 | Page 5

PROCEDURE - Symbolic Calculation


Task 1:

Use a symbolic keyword.

1. Type the expression shown to be


symbolically evaluated.

nl

2. Position the cursor to the right of


the expression. Insert the float
keyword.
Select the Math tab.
In the Operators and Symbols

U
al

rn

You can insert any


keyword by selecting
the Math tab, clicking

se

group, click Symbolics


Select float.

In

te

and
Symbolics
selecting the desired
keyword.

rP
TC

3. Type 3 in the placeholder and


click outside the expression to
evaluate.
Task 2:

Use more than one symbolic keyword to return a detailed solution


to an equation.

Fo

1. Type the expression shown to be


symbolically evaluated.
2. Position the cursor to the right of
the expression. Insert the solve
keyword.
3. Position the cursor to the right of
the solve keyword and type ,xx.
4. Position the cursor to the right
of solve,xx and insert the fully
keyword.

Module 14 | Page 6

2013 PTC

5. Click outside the expression to


evaluate. The detailed result
shows the value of yy for which
the solution is undefined.

Task 3:

Use the explicit keyword.

nl

1. Type the variable definitions and


the calculation as shown for
which the intermediate steps are
to be displayed.

2. Position the cursor to the right of the expression and insert the
explicit keyword.

rP
TC

In

te

rn

al

se

You can use the explicit keyword to replace specified


variables in an expression with their assigned values,
without performing any other operations. The explicit
command replaces each variable specified with its
assigned value. It does not replace any other variables
with their values, or perform any other numeric or symbolic
calculations on the expression.

Fo

3. Position the cursor to the right of the explicit keyword and type ,a,b,c
and click outside the region to evaluate.
If you evaluate a variable that is defined by an expression
containing other variables with assigned values, explicit
substitutes the expression in terms of the variables, not
their assigned values.

This completes the procedure.

2013 PTC

Module 14 | Page 7

Symbolic Algebra
You can use keywords to algebraically simplify, expand, or
factor expressions.
Mathcad contains the following
algebraic keywords:
simplify
expand
factor

nl

Figure 1 The simplify Keyword

Figure 3 The factor Keyword

Figure 2 The expand Keyword

se

Symbolic Algebra

You can use the following keywords to algebraically simplify, expand, or


factor expressions.

Fo

rP
TC

In

te

rn

al

simplify Simplifies an expression by performing arithmetic, cancelling


common factors, and using basic trignometric and inverse function
identities.
expand Expands all powers and products of sums in an expression.
factor Factors an expression into a product, if the entire expression can
be written as a product.

Module 14 | Page 8

2013 PTC

15
y

Module

nl

Solving

se

Module Overview

al

Mathcad supports many functions for solving a single equation in one


unknown through large systems of linear, and nonlinear equations, with
multiple unknowns. Mathcad also offers two built-in functions to numerically
and symbolically locate the roots of functions of single independent variables.

rn

Objectives

Fo

rP
TC

In

te

After completing this module, you will be able to:


Numerically and symbolically solve for roots of equations.
Numerically and symbolically solve systems of linear equations.
Numerically and symbolically solve systems of nonlinear equations.

2013 PTC

Module 15 | Page 1

Solving for Roots of Equations


Mathcad enables you to numerically and symbolically solve for
the roots of functions of single independent variables.
There are two built-in functions to
numerically solve for the roots of
functions of a single independent
variable.
The root function.
The polyroots function.

nl

You can solve for roots symbolically


by using the solve keyword on the
symbolic key word toolbar.

rn

al

se

Figure 1 The Root Function

Figure 3 Symbolic Roots

te

Figure 2 The Polyroots Function

In

Solving for Roots of Equations

rP
TC

Mathcad enables you to numerically solve for the roots of functions of single
independent variables.
Mathcad offers two built-in functions to numerically locate the roots of
functions of single independent variables:
The root function.
The polyroots function.

Fo

The Root Function

You can use the root function for all types of functions. You can use it in
two formats:
A two-argument case, which uses a guess value to search for the root.
A four-argument case, which uses a range over which to search for the root.
The root function, two-argument case, has the format:
root(f(t),t)
where:
f(t) is the function.
t is the guess value for the root of the function.
You can make a guess by assigning the independent variable before the
function, and using this variable in the function definition. Mathcad attempts
to provide a solution near the guess value. Different guesses may yield
Module 15 | Page 2

2013 PTC

different results, or may return the same result. The results depend on the
guess value and its location with respect to the actual root. It is useful to plot
the functions prior to evaluating the root.
The root function, four-argument case, has the format:
root(f(t),t,A,B)
where:

f(t) is the function.


t is the independent variable of the function.
A and B define the interval in which Mathcad searches for the root.

nl

No guess values are required for this format. The values of the function
at each endpoint of the range must be of opposite sign. This ensures that
there is a root in the range. You can evaluate multiple roots of a function by
giving different boundary conditions.

se

The Polyroots Function

al

The polyroots function has the format:

The polyroots function finds all the roots of a polynomial function.

rn

polyroots(v)
where:

te

v is a vector containing the coefficients of the polynomial.

In

The Symbolic Root Function

rP
TC

Mathcad provides the ability to solve for roots symbolically by selecting the
Math tab. In the Operators and Symbols group click Symbolics
click the solve keyword.

and

The following apply when solving for roots symbolically:

Fo

Mathcad does not require you to specify =0 when solving symbolically


for roots.
The roots are returned in a vector.
No guess value is required.
Results can include complex values.
Results can be in terms of other variables.
The solve keyword is not limited to polynomials.
If an equation has a periodic solution the solve keyword returns a single
value from the set of solutions. To view a detailed solution, add the modifier
fully after the keyword solve, separated by a comma.

2013 PTC

Module 15 | Page 3

PROCEDURE - Solving for Roots of Equations


Task 1:

Utilize the root function, two-argument case.

1. Type in the function shown below.


To insert any operator, select the Math tab, click Operators

nl

, and select the operator to insert.

se

2. Assign a guess value for the


independent variable of the
function.

al

3. Insert the root function.


Select the Functions tab.
In the Functions group, click

rn

.
Solving
Select root.

In

te

4. Complete the placeholders as shown. Delete the remaining two


placeholders.
operator to evaluate.

rP
TC

5. Insert the Evaluation

Utilize the root function, four-argument case.

Fo

Task 2:

1. Type in the function shown below.

2. Insert the root function.


Select the Functions tab.
In the Functions group, click
.
Solving
Select root.

Module 15 | Page 4

2013 PTC

3. Complete the placeholders as shown.


operator to evaluate.

4. Insert the Evaluation

Utilize the polyroots function.

Task 3:

nl

The values of the function at each endpoint of the range


must be of opposite sign. This ensures that there is a root
in the range. You can evaluate additional roots using a
different range in the function statement.

se

1. Type in the function.

rn

al

2. Define the coefficient matrix as


shown.

In

te

To insert a
matrix, select the
Matrices/Tables tab,
click Insert Matrix

rP
TC

, and select the


desired matrix.

Fo

3. Insert the polyroots function.


Select the Functions tab.
In the Functions group, click
.
Solving
Select polyroots.

4. Type coeff in the placeholder.


5. Insert the Evaluation

2013 PTC

operator to evaluate.

Module 15 | Page 5

Task 4:

Symbolically solve for roots.

1. Type in the function as shown.

2. Insert the solve keyword.


Select the Math tab.
.

In the Operators and Symbols group, click Symbolics


Select solve.

In

te

rn

al

se

nl

3. Type ,x after the solve keyword and click outside the region to
evaluate.

Fo

rP
TC

This completes the procedure.

Module 15 | Page 6

2013 PTC

Numerically Solving Systems of Linear Equations


Mathcad provides functions for solving systems of linear
equations with multiple unknowns.
Mathcad can solve a linear system
of equations by:

In

te

rn

al

se

nl

Using Isolve, a built-in function.


Using a solve block.

Figure 2 A Solve Block

rP
TC

Figure 1 The lsolve Function

Numerically Solving Systems of Linear Equations


Mathcad provides functions for solving systems of linear equations with
multiple unknowns. Mathcad can solve a linear system of equations by:

Fo

Using Isolve, a built-in function.


Using a solve block.

The lsolve Function


Mathcad can solve a linear system of equations using the built-in function
lsolve. The system must be written in matrix notation.
The format for the lsolve function is:
lsolve (M,v)
where:
M is the matrix of coefficients for the linear system.
v is the vector of constants for the linear system.
To solve a system of equations using lsolve:
1.

Rewrite the system in matrix form, using a coefficient matrix and a


constant matrix.

2013 PTC

Module 15 | Page 7

2.

The numbers used in the function can be real or complex, and the
use of units is supported.
Assign a matrix containing the unknown variables to the function lsolve,
and evaluate the results.

lsolve returns the solution for the linear system of equations written in matrix
form.

Solve Blocks

nl

You can also solve a linear system using a solve block. Using solve blocks
enables you to write the problem using natural mathematical notation, so the
constraints, functions, and initial values are easier to identify, both for you
and for others reading your document.

A solve block is a special construct in Mathcad which:

se

Solves systems of linear and nonlinear equations.


Maximizes and minimizes functions subject to constraints.
Solves systems of ordinary differential equations.

You can numerically evaluate solve blocks, and units are supported within a
solve block.

rn

al

Each solve block includes guess values, a set of constraints, and a solving
function. All solve blocks follow a similar setup. The difference is the function
that you use to close the solve block.

Fo

rP
TC

In

te

The solve block first evaluates the constraints using the guess values to
check for errors and determine the domain of the solution. This can dictate
whether real or complex solutions are returned. If the problem is treated as
real and complex results are encountered during the solution, absolute values
are taken. If the type is complex, complex results are carried out as is. To
find a complex solution, you must provide a complex guess. Mathcad does
not look in the complex plain without a complex guess.

Module 15 | Page 8

2013 PTC

PROCEDURE - Numerically Solving Systems of Linear


Equations
Scenario

se

In

te

rn

al

1. Rewrite the system in matrix


form, using a coefficient matrix,
M, and a column matrix of
constants, v.

Use the built-in lsolve function to solve the system of equations.

Task 1:

nl

Numerically solve the following system of linear equations using the built-in
lsolve function and a solve block.

rP
TC

2. Insert the lsolve function.


Select the Functions tab.
In the Functions group, click

Fo

.
Solving
Select lsolve.

3. Type the variable names of the


coefficient matrix, M, and the
column matrix of constants, v, in
the placeholders.
4. Retroactively assign a matrix
containing the unknown variables
to the function lsolve and
evaluate the results.
The Isolve function
enables you to use real
or complex numbers
and supports the use
of units.

2013 PTC

Module 15 | Page 9

Task 2:

Use a solve block to solve the system of equations.

1. Define any constant variables and functions in the equation set.


This example does not have any constants to define.

nl

2. Click in a blank area of the


worksheet and insert a solve
block.
Select the Math tab.
In the Regions group, click

Fo

rP
TC

In

te

rn

3. In the Guess Values section of


the solve block, type a guess
value for each variable to be
solved, as shown.

al

se

. A solve
Solve Block
block region appears.

Module 15 | Page 10

2013 PTC

4. In the Constraints section of


the solve block, define the
constraints shown using Boolean
operators.

nl
O
se
U

In

te

rn

al

5. In the Solver section of the solve


block, close the solve block by
assigning the unknown variables
to the Find built-in function, as
shown.
The Find built-in function
returns a solution that
satisfies Mathcad's internal
convergence tolerance,
defined by the built-in variable
TOL.

You can use the


following operators:
Equal To
Greater Than
Greater Than or
Equal To
Less Than
Less Than or Equal
To

rP
TC

You can also write the


solve block in matrix
form.

Fo

6. Evaluate the solution.


Your answer may not
display exactly zero.
This display depends
on the Results setting.
The Results setting is
located in the Results
group on the Math
Formatting tab.

This completes the procedure.

2013 PTC

Module 15 | Page 11

Numerically Solving Systems of Nonlinear


Equations
You can also use a solve block to solve systems of nonlinear
equations.
You can solve nonlinear systems
using the following format for the
solve block:

In

te

rn

al

se

nl

Guess values
Constraint listing
Solution statement

Figure 1 Nonlinear Solve Block

rP
TC

Numerically Solving Systems of Nonlinear Equations


You can also use a solve block to solve systems of nonlinear equations using
the following format for the solve block:

Fo

Guess values
Constraint listing
Solution statement

The solve block returns one solution, even if the system has multiple
solutions. Mathcad uses the guess values as a starting point to find the
solution. Different guesses may yield different solutions.
To find a complex solution, you must provide a complex guess. Mathcad
does not look in the complex plain without a complex guess.

Module 15 | Page 12

2013 PTC

PROCEDURE - Numerically Solving Systems of


Nonlinear Equations
Task 1:

Use a solve block to solve the system of nonlinear equations.

1. Define any constant variables


and functions in the equation set.
This example does not
have any constants to
define.

se

nl

2. In a blank area of the worksheet,


insert a solve block.
Select the Math tab.
In the Regions group, click

Fo

rP
TC

In

te

rn

al

3. In the Guess Values section of


the solve block, type the guess
values, as shown.

. A blank
Solve Block
solve block region appears.

2013 PTC

Module 15 | Page 13

4. In the Constraints section


of the solve block, define
the constraints shown, using
Boolean operators.

rP
TC

In

te

rn

Find returns a solution


that satisfies Mathcad's
internal convergence
tolerance, defined by
the built-in variable
TOL.

al

5. Close the solve block by


assigning the unknown variables
to the built-in function Find.

se

nl

You can use the


following operators:
Equal To
Greater Than
Greater Than or
Equal To
Less Than
Less Than or Equal
To

Fo

6. Evaluate the result.

This completes the procedure.

Module 15 | Page 14

2013 PTC

Symbolically Solving Systems of Equations


Mathcad enables you to solve a system of linear or nonlinear
equations symbolically.

Symbolically Solving Systems of Equations

nl

Figure 1 The Solve Keyword

To solve a system of equations


symbolically use the solve keyword.

se

Mathcad enables you to solve a system of linear or nonlinear equations


symbolically. To solve a system of equations symbolically use the solve
keyword.

Fo

rP
TC

In

te

rn

al

When solving a system of equations symbolically be aware of the complexity


of the problem. It is much harder to solve a system of equations symbolically
than numerically. Solving systems of equations, inequality equations, or
periodic equations may produce some special results that do not have
meaning when evaluated numerically.

2013 PTC

Module 15 | Page 15

PROCEDURE - Symbolically Solving Systems of


Equations
Task 1:

Solve a system of equations symbolically.

1. Insert a 2x1 matrix.


Select the Matrices/Tables
tab.
In the Matrices and Tables
group, click Insert Matrix

nl

.
Click and drag to select a 2x1
matrix.

3. Insert the solve keyword.


Select the Math tab.

se

2. Type the equations shown in the


placeholders.

rn

al

In the Operators and Symbols group, click Symbolics


Select solve.

rP
TC

In

te

4. Type ,x,y after the solve keyword.

Fo

5. Click outside the region to evaluate.

The variables to be solved for, x and y, could also be placed in


a 2x1 matrix as shown.

This completes the procedure.

Module 15 | Page 16

2013 PTC

Modifying the Convergence and Constraint


Tolerance
Mathcad enables you to customize a solve block.
You can customize a solve block by:

Modifying the convergence


tolerance.
Modifying the constraint tolerance.

nl

Figure 1 The Convergence and


Constraint Tolerance

The Convergence Tolerance

se

The Find function attempts to return an answer with an error satisfying the
built-in convergence tolerance, which is 0.001 by default. Mathcad enables
you to change the tolerance as required.

rn

al

You can globally modify the convergence tolerance by selecting the


Calculation tab. In the Worksheet Setting group, click TOL and select the
tolerance required. To locally modify the convergence tolerance, define it
in the worksheet.

te

The Constraint Tolerance

rP
TC

In

The constraint tolerance, which is 0.001 by default, controls how close a


constraint in a solve block must be met. Mathcad enables you to change the
tolerance as required.
You can globally modify the convergence tolerance by selecting the
Calculation tab. In the Worksheet Setting group, click CTOL and select
the tolerance required. To locally modify the constraint tolerance, define it
in the worksheet.

Fo

Tightening both tolerances may lead to a better solution, but keep in mind that
it may also place an unreasonable expectation on the solver and generate
an error.

2013 PTC

Module 15 | Page 17

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 15 | Page 18

2013 PTC

16
y

Module

nl

Optimization

se

Module Overview

Mathcad supports functions for solving constrained and unconstrained


optimization problems.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Solve a constrained optimization problem.
Solve an unconstrained optimization problem.

2013 PTC

Module 16 | Page 1

Constrained Optimization
Constrained optimization in Mathcad requires a solve block
construct because you specify the constraints that the variables
must satisfy.
Constrained optimization requires:

An objective function to optimize and constraints that must be satisfied


within the optimization.
Guess values for each independent variable.

nl

To solve a constrained optimization problem:

Define the objective function to optimize.


Define guess values for the variables.
Define the constraints.
To close the solve block, assign a vector of the variables to the function
maximize or minimize.
Evaluate the results.

al

se

rn

Constrained Optimization

te

Constrained optimization in Mathcad requires a solve block construct


because you must specify the constraints that the variables must satisfy.

In

Constrained optimization requires:

rP
TC

An objective function to optimize and constraints that must be satisfied


within the optimization.
Guess values for each independent variable.
To solve a constrained optimization problem:

Fo

Define the objective function to optimize.


Define guess values for the variables.
Define the constraints.
Inequality constraints, using Boolean operators, are permitted.
To close the solve block, assign a vector of the variables to the function
maximize or minimize.
Note that the objective function used in the maximize or minimize
function is defined outside of the solve block.
Evaluate the results.
After solving a problem, validate that constraints were met and use the
variables selected to solve the problem to evaluate the function.

Module 16 | Page 2

2013 PTC

PROCEDURE - Constrained Optimization


Task 1:

Solve a constrained optimization problem.

nl

1. Define the constant, weight of steel, and objective function, shaft


weight.

In

te

rn

al

. A blank
Solve Block
solve block regions appears.

se

2. Insert a solve block.


Select the Math tab.
In the Regions group, click

Fo

rP
TC

3. In the Guess Values section of


the solve block, define guess
values for the variables.

2013 PTC

Module 16 | Page 3

nl

4. In the Constraints section of the


solve block, define the deflection,
length, and diameter constraints
shown.

se
U

al

rn

You can insert the


minimize function
by selecting the
Functions tab. In
the Functions group,

5. In the Solver section, close the


solve block by assigning a vector
of the variables shown to the
function minimize.

In

te

,
click Solving
and select minimize.

Fo

rP
TC

6. Evaluate the results.

7. Validate the constraints and


evaluate the function.

This completes the procedure.

Module 16 | Page 4

2013 PTC

Unconstrained Optimization
You can solve unconstrained optimization problems in Mathcad
with or without using a solve block.
To solve an unconstrained optimization problem:

Define the objective function.


Define guess values for each independent variable.
Assign the independent variables to the maximize or minimize function.
Evaluate the function.

nl

Unconstrained Optimization

se

In Mathcad, you can solve unconstrained optimization problems with or


without using a solve block. To solve an unconstrained optimization problem:

In

te

rn

al

Define the function to be optimized (referred to as the objective function).


Define guess values for each independent variable.
Assign the independent variables to the maximize or minimize function,
depending on the type of optimization.
The maximize and minimize functions return the values of the variables
specified that make the function take on its largest or smallest value
respectively.
Evaluate the function at the point found to determine the maximum or
minimum.

rP
TC

Avoid using unconstrained optimization on a function that does not have a


maximum or minimum. Mathcad issues an error message if this occurs. If
possible, it is a best practice to confirm the result with a plot. To view the point
and the function, plot the maximum or minimum point and the function.

Fo

The algorithms used in the unconstrained optimization solution attempt to


determine the solution, starting at the guess value, and follow the steepest
gradient to find the local max or min.

2013 PTC

Module 16 | Page 5

PROCEDURE - Unconstrained Optimization


Task 1:

Solve an unconstrained optimization problem using a solve block.

1. Define the function to be optimized (referred to as the objective


function).

nl

2. Insert a solve block.


Select the Math tab.
In the Regions group, click

rn

al

se

. A blank
Solve Block
solve block appears.

Fo

rP
TC

In

te

3. In the Guess Values section of


the solve block, define guess
values for each independent
variable, u and v, as shown.

Module 16 | Page 6

2013 PTC

4. In the Solver section, assign the


independent variables u and v
to the maximize function and
evaluate the variables.
You can insert the
maximize function
by selecting the
Functions tab. In
the Functions group,

nl

and
click Solving
select maximize.

Solve an unconstrained optimization problem without a solve


block.

rP
TC

Task 2:

In

te

rn

al

se

5. Evaluate the resulting variable


values and function to determine
the maximum.

Fo

1. Define the function to be optimized (referred to as the objective


function).

2. Define guess values for each


independent variable.

2013 PTC

Module 16 | Page 7

3. Assign the independent variables to the minimize function and


evaluate, as shown.

nl

4. Evaluate the function at the point


found to determine the minimum
function value, as shown.

Fo

rP
TC

In

te

rn

al

se

This completes the procedure.

Module 16 | Page 8

2013 PTC

17
y

Module

nl

Differential Equations

se

Module Overview

Mathcad supports functions for solving ordinary differential equations.

Objectives

Fo

rP
TC

In

te

rn

al

After completing this module, you will be able to:


Solve an ordinary differential equation.

2013 PTC

Module 17 | Page 1

Ordinary Differential Equations


Mathcad can numerically solve ordinary differential equations
using the solve block approach.
Ordinary differential equations
(ODEs) depend on a single
independent variable, usually time, t.
Consider the spring-mass system
shown.

nl

Figure 1 Spring-Mass System

se

Figure 2 Ordinary Differential Equation for the Spring-Mass System

Ordinary Differential Equations

al

Mathcad can numerically solve ordinary differential equations using the solve
block approach.

In

Mathcad can solve:

te

rn

Mathcad provides a numerical approximation of the exact solution to the


differential equation. The solution is provided at a sequence of time steps
over a specified finite range of values. Currently, it is not possible to find a
general or symbolic solution to an ordinary differential equation.

Fo

rP
TC

A single ordinary differential equation.


A system of ordinary differential equations.
Differential algebraic equations.
Linear or nonlinear ordinary differential equations.
Higher order systems.
Initial value problems (IVPs).
Boundary value problems (BVPs).
Ordinary differential equations (ODEs) depend on a single independent
variable, usually time, t. Consider the spring-mass system shown.
Where:
The displacement function is x(t).
The forcing function is F(t).
The mass is M.
The spring constant is k.
The damping coefficient is c.
The ODE representing this system is given by the equation shown.
You can insert operators and derivatives by selecting the Math tab, clicking
Operators
Module 17 | Page 2

, and selecting the desired operator or derivative.


2013 PTC

You can also write the ODE representing the system by clicking the Prime
operator. Where each prime applied to x represents a derivative with
respect to t.

Fo

rP
TC

In

te

rn

al

se

nl

You can use a solve block to solve an ODE, system of ODEs, or differential
algebraic equations. The setup is the same as the solve block approach
presented in previous modules.

2013 PTC

Module 17 | Page 3

PROCEDURE - Ordinary Differential Equations


Task 1:

Solve an ordinary differential equation using a solve block.

rP
TC

In

te

rn

al

se

nl

1. Define constants for Mass, Spring Constant, k, Damping Coefficient,


c, and forcing function F(t) for the system shown. Units are not
permitted.

2. Insert a solve block.


Select the Math tab.
In the Regions group, click

Fo

. A blank
Solve Block
solve block region appears.

Module 17 | Page 4

2013 PTC

3. In the Constraints section of the


solve block, define the differential
equation and initial conditions.

nl
O
se
U

Fo

rP
TC

In

te

rn

al

4. Close the solve block with a


function name only (do not use
arguments) assigned to the
odesolve function.
For an ODE with a single
unknown function, odesolve
requires two arguments and one
optional argument.
The first argument is a
function, or column vector of
functions, as they appear in
the solve block.
The second argument is the
right endpoint of the solution
interval, in this case 20.
The argument of the initial
conditions determines the left
endpoint.
The last argument is
optional. It is the number
of approximating points to use
over the interval.
If the optional argument is
omitted, as it is here, Mathcad
defaults the number of points to
1000.

You may use derivative


or prime notation for
the ODE, but Mathcad
requires prime notation
for any initial conditions
of the derivatives.

To insert the odesolve


function, select the
Functions tab, click
Differential Equation
Solving
, and
select odesolve.
Delete any unused
placeholders.

2013 PTC

Module 17 | Page 5

Task 2:

Mathcad interpolates a function through the data points returned


by odesolve. To utilize the solution, you can perform one of the
following steps:

1. Evaluate the function at the


single points shown.

al

se

nl

2. Evaluate the function over the


range of points shown. Define a
range variable, range, and use it
in the function evaluation.

Fo

rP
TC

In

te

rn

3. Plot the function over the solution domain. Define a range variable, t,
as shown, to define the domain of the plot.

This completes the procedure.

Module 17 | Page 6

2013 PTC

18
y

Module

nl

Programming

se

Module Overview

Mathcad supports a local programming capability. The programming features


enable you to loop and create conditional statements within a program
structure.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Create a program.
Use conditional statements.
Use looping constructs.

2013 PTC

Module 18 | Page 1

Creating a Program
Mathcad's programming operators enable the extension of
Mathcad's functionality when writing customized functions and
processes for calculations.
You can access Mathcad's programming operators by selecting the Math
.

nl

tab, and clicking Programming

se

Figure 1 Programming Operators

Creating a Program

te

rn

al

In Mathcad, you can type a program in the programming operator, which is


a multi-step container for Mathcad program-control operators. You can use
specific programming operators to specify local assignments to variables
or functions, loop over calculations, conditionally evaluate branches, add
breakpoints, trap errors, and return values.

In

Mathcad provides several programming operators. These operators enable


the extension of Mathcad's functionality when writing customized functions
and processes for calculations.

rP
TC

You can access Mathcad's programming operators by selecting the Math


tab, and clicking Programming

With a Mathcad program, you can use:

Fo

If/else conditional statements.


For loops.
While loops.
You cannot type in any of these commands from the keyboard; typing "for"
results in an error. Instead, you must use either a keyboard shortcut or insert
the operator.
Mathcad evaluates the sequence of statements in a program in the order
specified by the programming operators and then returns the result of the
last step. Although you can write a program as a series of expressions,
Mathcad enables you to group a calculation using a program and return
only the results you want. You can also incorporate features similar to those
found in other higher-level languages, such as conditional branches, error
handling, and recursive calls.

Module 18 | Page 2

2013 PTC

PROCEDURE - Creating a Program


Task 1:

Start a program in Mathcad.

1. Type the function name


NewProg(a,b) and insert a
definition operator.

nl
O
se
U

al

2. Insert a programming construct.


Select the Math tab.
In the Operators and Symbols
group, click Programming

When typing a function


name, the arguments
are the variables
passed to the program
from the Mathcad
worksheet. You can
also use a variable
name.

Select Program

rn

.
.

rP
TC

In

te

You can insert


programming
operators by selecting
the Math tab, clicking

Fo

,
Programming
and selecting the
desired programming
operator.

Task 2:

Assign a local program definition.

1. Click in the top placeholder of the


program started in the previous
task.
In each placeholder,
you can insert:
A local variable or
function definition.
A programming
operator, such as a
for loop.

2013 PTC

Module 18 | Page 3

2. Insert a Local Assignment


operator. A left pointing arrow
with two placeholders appears.

nl
O
se
U
al

rn

All assignments
made using the Local
Assignment operator
are local to the program
and are not recognized
outside of the program.
Definitions made
outside and before
the program are not
overwritten inside the
program.

3. Type the expression shown in


the right placeholder, and the
variable c in the left placeholder.
The expression, a/10, is now
locally assigned to the variable
c. Press SPACEBAR until the
entire expression highlights.

rP
TC

In

te

4. Press ENTER. A new line


appears with a placeholder.

5. Insert a Local Assignment


operator and type in the
expression shown.

Fo

6. Press SPACEBAR until the


bottom line highlights. Press
ENTER to add a new line.
To insert a line below
the selected line, place
the cursor to the right
of the line selected. If
it appears to the left
of the line selected,
Mathcad inserts the
line above the selected
line.

Module 18 | Page 4

2013 PTC

Task 3:

End a program in Mathcad.

nl
O
se
U

rn

al

2. The last line of a program


displays what is returned to the
Mathcad worksheet from the
program. The last line of the
program may contain:
A variable.
An expression.
A function.
A vector or matrix containing
variables or functions as
elements.
In the placeholder, type the
variable d.

1. Using the program modified in


the previous task, click in the last
placeholder.

rP
TC

In

te

To return multiple
values from a program,
place the values in a
vector or matrix on the
last line of a program.
Task 4:

Evaluate a program in Mathcad.

Fo

1. Define the variables being


passed to the program.
You can define the
variables before or
after the program
definition, or as
part of the program
evaluation.

2. Type the name of the program,


including the variables in
parentheses. Insert the
Evaluation
operator.
Click outside of the region to
evaluate.
This completes the procedure.

2013 PTC

Module 18 | Page 5

Conditional Statements
Mathcad provides operators to enable conditional program
branching.
The operators that enable conditional
branching are:

if
else
else if
also if

nl

Conditional Statements

al

if
else
else if
also if

rn

se

Mathcad provides operators to enable conditional program branching. The


operators that enable conditional branching are:

Fo

rP
TC

In

te

You can use conditional statements to execute or skip certain calculations.


They use Boolean conditions to direct a program execution. The Boolean
condition must be a comparison or expression that evaluates to 0 (false) or
1 (true).

Module 18 | Page 6

2013 PTC

PROCEDURE - Conditional Statements


Scenario
The program will accept a number sent to the program. If the number is
odd it will return the word True. If the number is even it will return the word
False. A built-in function mod (modulus) is used in this program. The function
mod divides the first argument of the function by the second argument of the
function. The function returns the remainder of this integer division. The
remainder has the same sign as the first argument. Therefore:

nl

mod(x,2) of even numbers is 0.


mod(x,2) of positive odd numbers is 1.
mod(x,2) of negative odd numbers is -1.

Use the if programming operator.

al

1. Type in the name of the program,


including argument, IsOdd(x),

Task 1:

se

Create this program twice, once using only if programming operators and
once using a combination of if and else operators.

rn

and insert a Definition


operator.

rP
TC

In

te

2. Click in the placeholder displayed


and insert a program construct.
Select the Math tab.
In the Operators and Symbols
group, click Programming
.

Fo

Select Program

You can insert


programming
operators by selecting
the Math tab, clicking

Programming
and selecting the
desired operator.

2013 PTC

Module 18 | Page 7

3. Insert a Local Assignment


operator and type in the
expression shown.

To create the string


variable False, click
in the placeholder
and press the double
quotation key (). Type
False.

se

nl

4. Press SPACEBAR until the first


expression highlights. Press
ENTER to create a new line.
Insert the if operator.

5. Type the expressions in the placeholders, as shown.

al

You can type the mod function in the placeholder or


insert it by selecting the Function tab. In the Functions

te

rn

. Expand the Number


group, click All Functions
Theory/Combinatorics category and select mod. You can
insert all other operators by selecting the Math tab, clicking

Fo

rP
TC

In

, and selecting the desired operator. The


Operators
equal sign (=) is a Boolean operator.

Module 18 | Page 8

2013 PTC

6. Press SPACEBAR until the entire if construct highlights. Press


ENTER and type the variable word in the placeholder.
The value returned by the program is the variable on the last line of
the program. In this case, the last line contains the variable word.

al

se

nl

To execute multiple statements when the Boolean condition


defined by the if statement is true:
Press SPACEBAR until the second line of the if construct
highlights.
Press ENTER as many times as needed to add additional
lines. Mathcad stacks the statements to be executed
below the condition.

Use the else programming operator.

rP
TC

Task 2:

In

te

rn

7. Evaluate the program using


varying inputs, as shown.

1. Type in the name of the program,


including argument, IsOdd(x),

Fo

and insert a Definition


operator.

2013 PTC

Module 18 | Page 9

2. Click in the placeholder displayed


and insert a program construct.
Select the Math tab.
In the Operators and Symbols
group, click Programming
.
Select Program

nl
O

se

Programming
and selecting the
desired operator.

You can insert program


operators by selecting
the Math tab, clicking

rn

al

3. Insert the if operator.

In

te

4. Complete the placeholders as


shown.

rP
TC

5. Press SPACEBAR until the entire


if construct highlights. Press
ENTER.

Fo

6. Insert the else operator in the


placeholder.

7. Complete the placeholders as


shown.

Module 18 | Page 10

2013 PTC

8. Evaluate the program using


varying inputs, as shown.

Fo

rP
TC

In

te

rn

al

se

nl

This completes the procedure.

2013 PTC

Module 18 | Page 11

Looping Constructs
Mathcad looping constructs enable you to iterate any
combination of expressions in a way that is difficult to execute
with range variables or other constructs.
Two program looping constructs are
available:

nl

For loops.
While loops.

rP
TC

In

te

rn

al

se

Figure 1 A For Looping Construct

Figure 2 A While Looping


Construct

Fo

Looping Constructs

A loop is a block of code that causes one or more statements comprising the
body of the loop to iterate until a termination condition occurs. There are
two kinds of loops within Mathcad:
A for loop.
A while loop.
When using these constructs, do not type the words for and while. This does
not produce the operators.
You can use a for loop to iterate a calculation, or set of calculations, a fixed
number of times. The for loop construct contains three placeholders, with
the bottom placeholder indented. On the first line of the construct, the first
placeholder contains an index. The second placeholder contains a range, a
vector, or a list. The symbol shown between the placeholders reads " is an
element of " and is used because the index can be an element of a range, a
vector, or a list of numbers. The second line of the construct, the indented
Module 18 | Page 12

2013 PTC

placeholder, contains one or more statements to be executed within the loop.


When multiple placeholders are added within a loop, Mathcad creates a
double vertical black bar within the loop to indicate that the calculations are
part of the loop.
It is possible to nest for loops within one another. When using a nested for
loop to iterate over the rows and columns of an array, be sure that your index
starts at the array origin value for your sheet. Perform a quick check by
evaluating the built-in ORIGIN variable in your worksheet.

nl

Like for loops, you can use while loops to iterate a calculation or set of
calculations. Unlike for loops, while loops repeat based on the evaluation of
a Boolean condition. While a condition is met, the steps contained in the
loop repeat.

se

A while loop has two placeholders, one of which is indented. The placeholder
on the first line of the construct contains a condition that must be satisfied
to execute the statement(s) on the second line of the construct. Like the
conditional placeholder that appears to the right of an if operator, the
conditional placeholder here must also contain an expression or statement
which evaluates to true (1) or false (0). You can use comparative Boolean
operators to form conditional statements.

al

While loops are useful for converging processes. To avoid an infinite loop,
keep in mind that:

In

te

rn

The condition must initially be true for the loop to execute.


The condition must involve a variable or variables whose values are
changed within the body of the loop; otherwise, the condition would always
remain true or false.

Fo

rP
TC

If an infinite loop occurs, press ESC. Mathcad prompts you to interrupt


processing. Click OK to terminate the loop. You can disable evaluation of
the program by modifying the condition in the while loop before executing the
program again.

2013 PTC

Module 18 | Page 13

PROCEDURE - Looping Constructs


Task 1:

Use a for loop to program the Fibonacci series.

nl
O
se
U

rn

, and
Programming
selecting the desired operator.

al

2. Type in the program definition


and the first lines of the program,
as shown. You can insert
programming operators by
selecting the Math tab, clicking

1. By definition, the first two


numbers in the Fibonacci series
are both 1.0. After that, each
element in the series is the sum
of the previous two elements.
Set the origin for your worksheet
equal to 1.0.
Select the Calculation tab.
In the Worksheet Setting
group, click ORIGIN.
Select 1.

In

te

You use the following


in the program shown:
The equal signs
are comprised of

Fo

rP
TC

the Equal To
operator.
The subscripts are
comprised of the
Matrix Index
operator.
The word return
is a Programming
operator.

Module 18 | Page 14

2013 PTC

se
U

rP
TC

In

te

rn

al

4. In the first line of the for loop,


type i in the left placeholder. In
the right placeholder, type the
range 3..n.

nl

3. Highlight the last line of the


program and press ENTER. Click
in the placeholder displayed and
insert the for operator.

5. In the last line of the for loop,


type the expression shown.

Fo

Select the Matrix Index


operator to create the subscripts.
Press SPACEBAR to highlight
the entire for loop and press
ENTER to add the final program
line.
It is necessary to
highlight the entire
loop; otherwise,
Mathcad adds a line
inside the loop.

2013 PTC

Module 18 | Page 15

6. Click in the placeholder on the


last line of the program and
insert the return operator. Type
v with a subscript of n in the
placeholder. Select the Matrix

nl

Index
operator to create
the subscript.

Use a while loop to program Newton's method for finding the


root of a number.

te

rn

1. Type in the program definition


and the first two lines of the
program. Add a new line.

al

Task 2:

se

7. Evaluate the program, as shown.

rP
TC

In

You can insert math


operators by selecting
the Math tab, clicking
, and
Operators
selecting the desired
operator.

Fo

2. Click in the empty placeholder


and insert a while operator.

3. Click in the placeholder on the


second line of the while loop and
press ENTER to add another line
to the while loop construct.

Module 18 | Page 16

2013 PTC

4. Type the expressions in the


while loop placeholders, as
shown. When you finish, press
SPACEBAR until the while loop
highlights.

rn

al

6. Evaluate the program, as shown.


Note that the program results
compare favorably to the results
from the square root operator.

se

nl

5. Press ENTER to add a new line.


Insert the return operator. Type
rnew in the placeholder.

Fo

rP
TC

In

te

This completes the procedure.

2013 PTC

Module 18 | Page 17

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 18 | Page 18

2013 PTC

19
y

Module

nl

Data Exchange

se

Module Overview

Mathcad enables you to import and export data to and from a worksheet in
a variety of formats.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Import data into Mathcad.
Export data from Mathcad.

2013 PTC

Module 19 | Page 1

Importing Data
Mathcad works with files and functionality from other
applications, such as Excel and Matlab.
There are a variety of methods that
you can use to import data into
Mathcad:

Copy and paste into Mathcad from


Excel.
Import data.
Import data from Excel.

se

nl

Figure 1 Importing Data

al

Figure 2 Importing Data from Excel

rn

Importing Data

In

te

Mathcad works with files and functionality from other applications, such as
Excel and Matlab. There are a variety of methods that you can use to import
data and functionality into Mathcad:

Fo

rP
TC

Copy and paste into Mathcad from Excel.


Copying data into a table creates a local copy of the data within the
Mathcad worksheet. When you use this method, there is no dependency
on an external file and the Mathcad array does not update if you make
changes to the external file.
Import data.
The READFILE function enables you to read data from Excel, delimited
text, and fixed width text files.
Import data from Excel.
The READEXCEL function enables you to read data from Excel.

Module 19 | Page 2

2013 PTC

PROCEDURE - Importing Data


Task 1:

Copy data in Excel and paste into Mathcad.

1. Browse to the Excel file


datastep_07.xlsx, and open the
file.

2. Copy rows 12 through 15 and


columns A and B to the clipboard.

te

rn

al

se

nl

3. Right-click in a blank area of the


Mathcad worksheet and select
Paste. The data is pasted into
Mathcad as a table.

Fo

rP
TC

In

4. Click in the top-left placeholder


and type A1. Click in the top-right
placeholder and type A2.

2013 PTC

Module 19 | Page 3

5. Evaluate A1 and A2 as shown.

nl

Import data into Mathcad using the READFILE function.

Task 2:

Copying data into


a table creates a
local copy of the data
within the Mathcad
worksheet. There is
no dependency on an
external file and the
Mathcad array does
not update if you make
changes to the external
file.

se

1. Assign a variable name to the data file name and path.

al

Type in the variable name File and insert a Definition


operator.
Select the Input/Output tab.
.

te

rn

In the Data Import/Export group, click Data Filename


The Browser dialog box appears. Browse to the file
interpolation.prn. Click Open.

rP
TC

In

Your file path is where you stored your file.

2. Assign the function READFILE to a variable name.


operator.

Fo

Type the variable name In and insert a Definition


Select the Functions tab.

.
In the Functions group, click File Access
Select the READFILE function.
Complete the first two placeholders as shown. Delete the remaining
placeholders.
The second argument is a string variable with a value that
can be delimited, fixed, or Excel.

Module 19 | Page 4

2013 PTC

Import data into Mathcad using the READEXCEL function.

Task 3:

nl

3. Evaluate the matrix In, as shown.

te

rn

al

and insert a Definition


operator.
Select the Input/Output tab.
In the Data Import/Export
group, click READEXCEL

se

1. Assign a variable name to the


data file name and path.
Type in the variable name EX

rP
TC

In

.
The READEXCEL dialog box
appears. Browse to the Excel
file datastep_07.xlsx. Click
Open.
Select rows 1 through 4 and
columns A and B.
Click Insert.

Fo

2. The file is assigned to the variable EX. Evaluate the variable EX as


shown.

This completes the procedure.

2013 PTC

Module 19 | Page 5

Exporting Data
Mathcad supports writing data stored in a vector or matrix to
a data file.
Mathcad provides multiple file output
options for exporting data to a data
file:
Tab delimited text.
Comma separated values.
Microsoft Excel.

nl

Figure 1 WRITEFILE Function

Exporting Data

se

Mathcad provides multiple file output options for exporting data to a data file:

Tab delimited text.


Comma separated values.
Microsoft Excel.

Fo

rP
TC

In

te

rn

al

It is critical to store the data you want to output as a vector or matrix and not a
range or sequence of numbers. This file output link is dynamic. Each time
you recalculate the worksheet, Mathcad writes out the vector or matrix again.
This ensures that the output file reflects any changes to the variable.

Module 19 | Page 6

2013 PTC

PROCEDURE - Exporting Data


Task 1:

Export data to a data file.

1. Create the following matrix in


Mathcad.

nl

2. Type the variable name OUT

and insert a Definition


operator.

se

3. In the placeholder, type the function WRITEFILE(OUT.xlsx,M). Use


the double quotation () key to type the filename as a string variable .

In

te

rn

al

This expression outputs your matrix to an Excel file,


OUT.xlsx, located in your current working directory. To
determine your current working directory, type CWD= in
your Mathcad worksheet.

Fo

rP
TC

4. Browse to your current working


directory and open the Excel file
OUT.xlsx.
This file output link is
dynamic. Each time
you recalculate the
worksheet, Mathcad
writes out the vector or
matrix again. This
ensures that the
output file reflects
any changes to the
variable.

This completes the procedure.

2013 PTC

Module 19 | Page 7

Using the Excel Component


An Excel component is an embedded Excel table inserted within
a Mathcad worksheet.

se

nl

The Excel component enables the


exchange of data with an Excel
worksheet.

Figure 1 Excel Component

Using the Excel Component

rn

al

The Excel component enables the exchange of data with an Excel worksheet
embedded as an object in a Mathcad worksheet. Using the Excel component
enables you to exchange data and use Excels functionality.

In

te

You can send values in your worksheet to Excel, use Excel functionality
to manipulate them, and then send new values back to your Mathcad
worksheet, as shown in Figure 1.

rP
TC

The Excel component is a local copy of the spreadsheet. You can save
the data in an Excel component as an external Excel file. There is no
link between the Mathcad Excel component and the saved Excel file. Any
changes made in the Mathcad Excel component are not reflected in the
external file and vice versa.

Fo

You must have Excel 2003 or later installed on your system to


insert an Excel component.

Module 19 | Page 8

2013 PTC

PROCEDURE - Using the Excel Component


Task 1:

Input a matrix from Mathcad into an Excel component.

nl

1. Create the matrix, M, shown.

se

2. In a blank area of the worksheet, below the matrix definition, insert an


Excel component.
Select the Input/Output tab.
.

In the Data Import/Export group, click Excel Component

from the drop-down menu. A

Fo

rP
TC

In

te

rn

al

Select Insert Excel Component


blank Excel component appears.

2013 PTC

Module 19 | Page 9

3. Click in the Inputs region of the component and insert an Input


expression.
Select the Input/Output tab.
.

In the Data Import/Export group, click Excel Component


Select Insert Input Expression
blank input expression appears.

from the drop-down menu. A

nl

An input expression can also be inserted by right-clicking


in the Inputs region of the component and selecting Insert
Input Expression.

4. Type M in the placeholder and click outside the Excel component.

se

The input expression can also be typed in directly. Use a

Fo

rP
TC

In

te

rn

al

operator to specify the cell range string


Matrix Index
in the subscript location. If you are writing to the first Excel
worksheet you do not have to specify the worksheet name.
The subscript A1 is equivalent to the subscript shown.

Module 19 | Page 10

2013 PTC

Task 2:

Calculate the sum of each row using Excel functionality and return
the results to Mathcad.

1. To access the full functionality of Excel, double-click the component to


invoke in-place activation of the object. The Excel worksheet opens.
2. Type the following:
In the D1 cell, type =SUM(A1:C1).
In the D2 cell, type =SUM(A2:C2).
In the D3 cell, type =SUM(A3:C3).

te

rn

al

se

nl

3. Close the Excel application and return to the Mathcad worksheet. The
additions are listed in the Excel component.

rP
TC

In

4. Click in the Outputs region of the component and insert an Output


expression.
Select the Input/Output tab.
In the Data Import/Export group, click Excel Component

Fo

Select Insert Output Expression


A blank output expression appears.

2013 PTC

from the drop-down menu.

An output expression can also be inserted by right-clicking


in the Outputs region of the component and selecting Insert
Output Expression.

Module 19 | Page 11

5. Type RowSum in the left placeholder.


6. Modify the excel subscript by typing D1:D3 as the script variable.
The output expression can also be typed in directly. Use a

In

te

rn

7. Click in a blank area of the


worksheet, below the Excel
component. Type RowSum= to
display the results.

al

se

nl

operator to specify the cell range string


Matrix Index
in the subscript location.

Fo

rP
TC

This completes the procedure.

Module 19 | Page 12

2013 PTC

20
y

Module

nl

Data Analysis

se

Module Overview

Mathcad supports the analysis of data. Within Mathcad, you can smooth,
interpolate, and regress data.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Smooth data.
Interpolate data.
Regress data.

2013 PTC

Module 20 | Page 1

Data Analysis
Mathcad supports a variety of data analysis options.
The data analysis options supported
in Mathcad include:

nl

Smoothing
Interpolation
Regression

In

te

rn

al

se

Figure 1 Smoothed Data

Figure 2 Interpolated Data

Figure 3 Regressed Data

rP
TC

Data Analysis

Mathcad supports a variety of data analysis options, including:

Fo

Smoothing
Kernel
Median
Super
Interpolation
Linear
Cubic Spline
Regression
Linear
Polynomial
General

You can find the applicable built-in functions by selecting the Functions tab.
Most of the functions used in data analysis are listed in one of the following
categories:
Curve Fitting and Smoothing
Module 20 | Page 2

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

Data Analysis
Interpolation and Prediction

2013 PTC

Module 20 | Page 3

Smoothing Data
A data smoother takes a set of data and returns a new set that
contains less noise than the original set; however, it still retains
the basic shape and properties of the original data.
Mathcad provides three smoothing
functions.

se

nl

medsmooth
ksmooth
supsmooth

rP
TC

In

te

rn

al

Figure 1 Function: medsmooth

Figure 2 Function: ksmooth

Figure 3 Function: supsmooth

Smoothing Data

Fo

A data smoother takes a set of data and returns a new set that contains
less noise than the original set; however, it still retains the basic shape and
properties of the original data.
Mathcad provides three smoothing functions.

Function: medsmooth
The median smoothing function (medsmooth) takes a window of data
around a given data point and replaces that point with the median of
the values in the window. This function is the most robust of the three
smoothing functions. It is least likely to be affected by false data points.
Function: ksmooth
The kernel smoothing function (ksmooth) uses a Gaussian kernel to
compute and return local weighted averages of y. This function is most
useful when the data lies along a band of relatively constant width.

Module 20 | Page 4

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

Function: supsmooth
The super smoothing function (supsmooth) uses a local smoother that
returns a localized linear fit. This function is most useful when the data
lies scattered along a band whose width fluctuates. The supsmooth
function adaptively selects different bandwidths for different portions
of the data.

2013 PTC

Module 20 | Page 5

PROCEDURE - Smoothing Data


Task 1:

Import a set of data to use in the smoothing functions.

1. Assign a variable name to the data file name and path.


Type in the variable name Smooth and insert a Definition
operator.
Select the Input/Output tab.

se

Your file path is where you stored your file.

nl

.
In the Data Import/Export group, click Data Filename
The Browser dialog box appears. Browse to the file smoothdata.prn.
Click Open.

al

2. Assign the function READFILE to a variable name.

te

rn

Type the variable name Data1 and insert a Definition


operator.
Select the Functions tab.

rP
TC

In

In the Functions group, click File Access


.
Select the READFILE function.
Complete the first two placeholders as shown. Delete the remaining
placeholders.

Fo

The second argument is a string variable that may have one


of the following values: delimited, fixed, or Excel.

3. Using the Matrix Column


operator, extract the first column
of the data and assign it to the
variable X1. Extract the second
column of the data and assign it
to the variable Y1.
Remember to set
ORIGIN equal to 1.

Module 20 | Page 6

2013 PTC

Task 2:

Smooth a set of data using median smoothing.

1. Assign the medsmooth function to a variable Msmooth.


Type Msmooth and insert a Definition
Select the Functions tab.

operator.

nl

In the Functions group, click Curve Fitting and Smoothing


Select medsmooth.
Type in the arguments Y1,5 as shown. Delete any unused
placeholders.

te

rn

al

se

The modified data vector contains the same number of data


points as the original data. The arguments represent the
following:
First argument: A real vector of data, vy.
Second argument: The window size, n. The window size
must be an odd integer less than the number of elements
in the data vector, vy.

Fo

rP
TC

In

2. Plot the original data and the


smoothed data on an x-y plot.

2013 PTC

Module 20 | Page 7

Task 3:

Smooth a set of data using kernal smoothing.

1. Assign the ksmooth function to a variable Ksmooth.


Type Ksmooth and insert a Definition
Select the Functions tab.

operator.

In the Functions group, click Curve Fitting and Smoothing


Select ksmooth.
Type in the arguments X1,Y1,0.1, as shown.

In

te

rn

al

se

nl

The modified data vector contains the same number of data


points as the original data. The arguments represent the
following:
First argument: A real vector of data, vx, in ascending
order.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.
Third argument: The bandwidth of the smoothing window
b. Bandwidth is usually set to a few times greater than
the spacing between data points on the x-axis, depending
on the desired degree of smoothing.

Fo

rP
TC

2. Plot the original data and the


smoothed data on an x-y plot.

Module 20 | Page 8

2013 PTC

Task 4:

Smooth a set of data using super smoothing.

1. Assign the supsmooth function to a variable Ssmooth.


Type Ssmooth and insert a Definition
Select the Functions tab.

operator.

In the Functions group, click Curve Fitting and Smoothing


Select supsmooth.
Type in the arguments X1,Y1 as shown.

rn

al

se

nl

The modified data vector contains the same number of data


points as the original data. The arguments represent the
following:
First argument: A real vector of data, vx, in ascending
order.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.

Fo

rP
TC

In

te

2. Plot the original data and the


smoothed data on an x-y plot.

This completes the procedure.

2013 PTC

Module 20 | Page 9

Interpolating Data
Interpolation draws lines, or polynomial curves, between data
points to predict values that are not in the data set.
Mathcad supports several types
of interpolation. The following two
types are discussed here:

se

nl

Linear Interpolation
Cubic Spline Interpolation

rP
TC

In

te

rn

al

Figure 1 Linear Interpolation

Figure 2 Cubic Spline


Interpolation

Interpolating Data

Fo

Interpolation draws lines, or polynomial curves, between data points to


predict values not in the data set. Interpolation methods attempt to connect
all points, making no effort to describe the data using a set of parameters.
Mathcad supports several types of interpolation. The following two types
are discussed here:
Linear interpolation linterp function.
To find the interpolated value for x, linterp connects the two points
on either side of the x value with a straight line, and returns the
corresponding value of y that lies on the straight line for the given value
of x. You can evaluate the function at a given value of x, or over a range.
Linear interpolation is a straightforward process, but you should note the
following properties:
The resulting curve is not differentiable at any of the known data
values.
Module 20 | Page 10

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

Do not use the linterp function to determine extrapolated values. Use


the predict function.
Cubic Spline interpolation cspline function.
You can use cubic spline interpolation to obtain a smooth differentiable
curve where each section is represented by a cubic polynomial of the
form: ax3 + bx2 + cx + d.
You can use cubic splines to create well-behaved, differentiable
functions. Though they are not represented as closed form expressions,
you can use them in many of the same types of mathematical analyses.
Cubic spline interpolation is a two-step process, and involves both the
cspline and interp functions.
Mathcad initially uses the cspline function and requires that the second
derivative at each point is determined by the straight line through
the nearest two points. The output of the cspline function is a vector
containing the values of the second derivative of the desired spline at
each point of x. This vector is then used by the interp function.
The interp function is then used to construct interpolated points from
the output of the cspline function.

2013 PTC

Module 20 | Page 11

PROCEDURE - Interpolating Data


Task 1:

Import a set of data and create a range variable to use in the


interpolation functions.

1. Assign a variable name to the data file name and path.

nl

In the Data Import/Export group, click Data Filename


The Browser dialog box appears. Browse to the file
interpolation.prn. Click Open.

Type in the variable name Inter and insert a Definition


operator.
Select the Input/Output tab.

se

Your file path is where you stored your file.

al

2. Assign the function READFILE to a variable name.

In

te

rn

Type the variable name Data2 and insert a Definition


operator.
Select the Functions tab.

rP
TC

.
In the Functions group, click File Access
Select the READFILE function.
Complete the first two placeholders as shown. Delete the remaining
placeholders.

Fo

The second argument is a string variable that may have one


of the following values: delimited, fixed, or Excel.

3. Using the Matrix Column


operator, extract the first column
of the data and assign it to the
variable X2. Extract the second
column of the data and assign it
to the variable Y2.
Remember to set
ORIGIN equal to 1.

Module 20 | Page 12

2013 PTC

4. Create a range variable, range2. Use the built-in functions min and
max as shown.

Task 2:

Interpolate a set of data using a linear interpolation function.

1. Assign the linterp function to a function LIN(range2).

nl

operator.

Type LIN(range2) and insert a Definition


Select the Functions tab.

se

. The Functions
In the Functions group, click All Functions
dialog box appears on the left side of your worksheet.
Expand the Interpolation and Prediction category and select linterp.
Type in the arguments X2,Y2,range2 as shown.

rP
TC

In

te

rn

al

The arguments represent the following:


First argument: A real vector of data, vx, in ascending
order.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.
Third argument: The value of the independent variable at
which you want an interpolated value or range of values.

Fo

2. Plot the original data and the


interpolated data on an x-y plot.

2013 PTC

Module 20 | Page 13

Task 3:

Interpolate a set of data using the cubic spline interpolation


function cspline.

1. Assign the cspline function to a variable vs to create an intermediate


set of data to be used by the interp function.
Type vs and insert a Definition
Select the Functions tab.

operator.

nl

In the Functions group, click All Functions


. The Functions
dialog box appears on the left side of your worksheet.
Expand the Interpolation and Prediction category and select
cspline.
Type in the arguments X2,Y2 as shown.

Fo

rP
TC

In

te

rn

al

se

The arguments represent the following:


First argument: A real vector of data, vx, in ascending
order.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.

Module 20 | Page 14

2013 PTC

2. Assign the interp function to a function CSinterp(range2).


Type CSinterp(range2) and insert a Definition
Select the Functions tab.

operator.

In the Functions group, click All Functions


. The Functions
dialog box appears on the left side of your worksheet.
Expand the Interpolation and Prediction category and select interp.
Type in the arguments vs,X2,Y2,range2 as shown.

te

rn

al

se

nl

The arguments represent the following:


First argument: A vector of spline coefficients returned by
the spline function cspline.
Second argument: A real vector of data, vx, in ascending
order.
Third argument: A real vector of data, vy. The vectors vx
and vy must be the same size.
Fourth argument: The value of the independent variable
at which you want an interpolated value or range of
values.

Fo

rP
TC

In

3. Plot the original data and the


interpolated data on an x-y plot.

This completes the procedure.

2013 PTC

Module 20 | Page 15

Regressing Data
Parametric, or regression, methods approximate the parameters
of a function to a set of data.
Mathcad supports several types of
regression methods. The following
are discussed here:

se

nl

Linear Regression
Polynomial Regression

rP
TC

In

te

rn

al

Figure 1 Linear Regression

Figure 2 Polynomial Regression

Regressing Data

Fo

Regression methods approximate the parameters of a function to a set of


data. You can predict new points in the data set using the resulting function.
The model may attempt to represent the physics that generated the data, or it
may be a representation of the points in space.
Mathcad supports several types of regression. The following two types are
discussed here:

Linear regression line function.


The line function finds the least squares and best fit line through a set
of x-y data. Least squares regression calculates a final fitted line that
minimizes the distance between each point in the data set and the final
fitted line. The output of the line function is a vector containing the
values of the coefficients for a line of the form, y = mx + b.
Polynomial regression polyfit function.
Polynomial regression fits a polynomial that minimizes the vertical
distance of all data points to a polynomial curve of degree n. You use
Module 20 | Page 16

2013 PTC

Fo

rP
TC

In

te

rn

al

se

nl

the polyfit function for polynomial regression to determine a single


polynomial that best approximates the entire set of data.
You can use the polyfitc function to obtain the coefficients of the
regressed function. The output of polyfitc is a vector containing the
polynomial coefficients and other values. You can extract the coefficients
to generate the polynomial.
If only a numerical evaluation is required, use the polyfit function. You
use the polyfit function to construct the regressed points.

2013 PTC

Module 20 | Page 17

PROCEDURE - Regressing Data


Task 1:

Import a set of data and create a range variable to use in the


regression functions.

1. Assign a variable name to the data file name and path.

Type in the variable name Reg and insert a Definition


operator.
Select the Input/Output tab.

nl

.
In the Data Import/Export group, click Data Filename
The Browser dialog box appears. Browse to the file regression.prn.
Click Open.

se

Your file path is where you stored your file.

rn

al

2. Assign the function READFILE to a variable name.

In

te

Type the variable name Data3 and insert a Definition


operator.
Select the Functions tab.

rP
TC

.
In the Functions group, click File Access
Select the READFILE function.
Complete the first two placeholders as shown. Delete the remaining
placeholders.

Fo

The second argument is a string variable that may have one


of the following values: delimited, fixed, or Excel.

3. Using the Matrix Column


operator, extract the first column
of the data and assign it to the
variable X3. Extract the second
column of the data and assign it
to the variable Y3.
Remember to set
ORIGIN equal to 1.

Module 20 | Page 18

2013 PTC

4. Create a range variable, range3. Use the built-in functions min and
max as shown.

Task 2:

Regress a set of data using the linear regression function line.

Type Coeff and insert a Definition


Select the Functions tab.

nl

operator.

1. Assign the line function to a variable Coeff.

se

In the Functions group, click Curve Fitting and Smoothing


Select line.
Type in the arguments X3,Y3 as shown.

In

te

rn

al

The arguments represent the following:


First argument: A real vector of data, vx.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.

rP
TC

2. The Coeff vector contains the


y intercept and the slope of the
best fit line for the given data.

Fo

Using the Matrix Index


operator, extract the first element
of the vector and assign it to the
variable Int. Extract the second
element of the vector and assign
it to the variable Lslope.

3. Type the linear regression function shown using the calculated


intercept and slope.

2013 PTC

Module 20 | Page 19

Regress a set of data using the polynomial regression function


polyfit.

se

1. Assign the polyfit function to a variable Preg.

nl

Task 3:

4. Plot the original data and the


regressed data on a x-y plot.

Type Preg and insert a Definition


Select the Functions tab.

operator.

te

rn

al

In the Functions group, click All Functions


. The Functions
dialog box appears on the left side of your worksheet.
Expand the Design of Experiments category and select polyfit.
Type in the arguments X3,Y3,4 as shown.

Fo

rP
TC

In

The arguments represent the following:


First argument: A real vector of data, vx, in ascending
order.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.
Third argument: The order of the regressed polynomial.

2. Plot the original data and the


regressed data on a x-y plot. Plot
both the R1 and R2 functions
evaluated using the variable
range.

Module 20 | Page 20

2013 PTC

3. To obtain the coefficients of the regressed function, assign the polyfitc


function to a variable P.
Type P and insert a Definition
Select the Functions tab.

operator.

. The Functions
In the Functions group, click All Functions
dialog box appears on the left side of your worksheet.
Expand the Design of Experiments category and select polyfitc.
Type in the arguments X3,Y3,4 as shown.

rn

al

se

nl

The arguments represent the following:


First argument: A real vector of data, vx, in ascending
order.
Second argument: A real vector of data, vy. The vectors
vx and vy must be the same size.
Third argument: The order of the regressed polynomial.

rP
TC

In

te

4. Evaluate the variable P to view the coefficients. The second column


contains the coefficients listed in increasing powers of x, beginning
with the coefficient of x0.

Fo

This completes the procedure.

2013 PTC

Module 20 | Page 21

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 20 | Page 22

2013 PTC

21
y

Module

nl

Project Day 2

se

Module Overview

Use the skills that you have learned so far in Mathcad to complete one of
the projects in this module.

al

Objectives

Fo

rP
TC

In

te

rn

After completing this module, you will be able to:


Create a spec table.
Create a program.
Create and use matrices and matrix functions
Import data.

2013 PTC

Module 21 | Page 1

Structural Engineering Project Day 2


In this project, you import a table of beam sections for the beam
used in the Structural Engineering Day 1 project and select the
sections that satisfies given design criteria.
Complete the following exercise steps:
Import a table of beam sections.
Select sections that satisfy given design criteria.
For the sections that satisfy the given design criteria calculate the
maximum stress.

nl

1.
2.
3.

Structural Engineering Project Day 2

al

Import a table of beam sections.


Select sections that satisfy given design criteria.
Maximum allowable deflection: ymax = 4 mm
Maximum width of beam: bmax = 300 mm
For the sections that satisfy the given design criteria calculate the
maximum stress.

Fo

rP
TC

In

3.

te

rn

1.
2.

Complete the following exercise steps:

se

In this project, you import a table of beam sections for the beam used in the
Structural Engineering Day 1 project and select the sections that satisfies
given design criteria.

Module 21 | Page 2

2013 PTC

Mechanical Engineering Project Day 2


In this project, you set a threshold limit for the critical speed
and vary the inner and outer diameter of the shaft used in the
Mechanical Engineering Day 1 project.
Complete the following exercise steps:
Set a threshold for the rpm.
Create a spec table varying the inner and outer diameter of the shaft.
Create a program to determine which combination of inner and outer
diameter satisfies the threshold rpm limit.
Plot the thickness of the shaft verses the critical speeds at each
thickness.

se

Mechanical Engineering Project Day 2

4.

nl

1.
2.
3.

In this project, you set a threshold limit for the critical speed and vary the
inner and outer diameter of the shaft used in the Mechanical Engineering
Day 1 project.

rn

Fo

rP
TC

4.

te

2.
3.

Set a threshold for the rpm.


Rlimit=nc2=1.946x104 rpm
Create a spec table varying the inner and outer diameter of the shaft.
Create a program to determine which combination of inner and outer
diameter satisfies the threshold rpm limit.
Plot the thickness of the shaft verses the critical speeds at each
thickness.

In

1.

al

Complete the following exercise steps:

2013 PTC

Module 21 | Page 3

y
nl
O
se
U
al
rn
te
In
rP
TC
Fo
Module 21 | Page 4

2013 PTC

Challenge Exercise Solutions

A
nl

Appendix

se

Module Overview

Fo

rP
TC

In

te

rn

al

This module contains solutions to the challenge exercises used throughout


this course. The solutions are presented in a step-by-step format.

2013 PTC

Appendix A | Page 1

You might also like