SlideShare a Scribd company logo
1 of 13
Download to read offline
PTC Academic Program
Learn. Create. Collaborate. Succeed.
Programming with Mathcad Prime™
Written By Chris Hartmann, Anji Seberino & Roger Yeh
These materials are ©2011 , Parametric Technology Corporation (PTC)
All rights reserved under copyright laws of the United States and other countries.
PTC, the PTC Logo, Mathcad and all PTC product names and logos are trademarks or registered
trademarks of PTC and/or its subsidiaries in the United States and in other countries.
Conditions of Use
Copying and use of these materials for educational purposes is fully authorized for any person(s).
Acknowledgments
The authors gratefully acknowledge the support of the Mathcad Business Unit and the PTC Academic
Program.
Questions or Corrections
Please direct inquiries or questions regarding the contents of this tutorial to the Mathcad Academic
Program at MathcadEducation@ptc.com. Suggestions for improvement or further development will be
gladly accepted.
PTC Academic Program
Learn. Create. Collaborate. Succeed.
Programming with Mathcad Prime
Mathcad Prime is an environment for Computational Thinking – an approach to calculation, data
analysis and problem solving that uses the capabilities of a computer to construct better solutions. When
used appropriately computational thinking:
 Helps to illustrate the solution to a problem more clearly
 Produces meaningful answers to a challenging problems more quickly
 Off-loads some of the complexities of a problem to a computer in ways that enable better human
insight into the nature of a problem in order to further the solution process
Mathcad Prime possesses a simple and easy to use Programming capability that allows users to write
multistep functions directly on a worksheet alongside equations, tables, graphs, and text.
Mathcad Prime’s Programming Commands
Using Mathcad’s programming capabilities in math and science coursework can help students understand
concepts more deeply. It also helps introduces them to some computer programming basics.
In this tutorial we will focus on two different ways to use Mathcad’s Programming capabilities to Go
Beyond the Basics in math and science courses:
1. Formalizing Mathematical Relationships
2. Modeling Mathematical Processes
Each example will introduce a small number of Mathcad’s Programming capabilities in order to help you
to build up your proficiency in writing Functions on a Mathcad worksheet.
Programming with Mathcad Prime | pg. 2
Formalizing Mathematical Relationships
When working on a Mathcad Prime worksheet, the expression of a formula is equivalent to writing a one-
line computer program. I will illustrate this idea by showing two different ways to define the
mathematical relationship between a diameter of a circle and the circumference and area measurements of
the circle.
In a Mathcad worksheet it would be typical to use formulas to calculate the Area and Circumference of a
circle using assignment statements such as those shown below.
Writing a computer program on a Mathcad worksheet is a lot like defining and evaluating formulas like
those above. Once defined, the formulas above instruct Mathcad to perform all of the steps in the
definition and return a result. Similarly, Mathcad programs report the last result calculated or assigned
in the program. Returning this result is a lot like reporting the final result after following order of
operations in a numerical expression.
We can use Mathcad’s Programming tools to create the formulas above as Mathcad programs. Although
we do not need to write programs to perform these calculations, we will use this simple example to
introduce the Local Assignment () operator and the Program Structure (|) symbol on Mathcad’s
Programming Toolbar.
Local assignment in simple Mathcad programs
When writing computer programs it is good programming practice to reduce the memory requirements of
a program by defining variables that only exist while the program is running. Similarly, in a Mathcad
worksheet it is good practice to carefully manage the variable definitions one uses. Since variable
definitions are live everywhere down and to the right of the initial assignment in a Mathcad Worksheet,
Local Assignment in programs reduces the total number of live variable definitions.
In the box below, a simple one-line Mathcad program is used to calculate the circumference of a circle
using the measure of a diameter. This example demonstrates how the Local Definition operator works in a
Mathcad worksheet.
Programming with Mathcad Prime | pg. 3
Local Definition
In the image at right the formula for circumference of a
circle is defined in a Mathcad Program using Mathcad
Prime’s Local Definition operator . In this case
the use of the Local Definition helps to clarify the
meaning of the program named C. C accepts a single
parameter, the measurement of a diameter of the circle.
During program execution Circumference is calculated
using the formula π*D. C returns the value of
Circumference, the last value calculated. But, since it is
defined locally, the value of Circumference is undefined
outside of the program definition. Therefore,
Circumference is undefined on the worksheet and
returns an error when evaluated.
Follow these steps to create a Mathcad program that calculates the area of a circle given its
Diameter as an input parameter:
Step 1: Type the following keystrokes to give the program a name and a parameter:
A(D: You should see this on the worksheet:
Step 2: Mathcad shows that it is waiting for the program to be defined on the right side of the assignment
statement by leaving the blue cursor in the placeholder. Follow these steps to insert the first line of the
program:
Left-click to select the Math ribbon
Left-click on the Programming icon
Left-click the Insert Program Structure
icon on the Programming menu
Type: radius in the placeholder
Left-click on the Programming icon on the Math ribbon
Left-click on the Local Assignment Operator icon on the
Programming menu
Type: D/2 in the placeholder. Hit the Right Arrow key once to
advance the cursor and then hit the ENTER key. A new Program
line will appear as shown.
Programming with Mathcad Prime | pg. 4
Step 3: Follow these instructions to add the second line of the program:
Type Area in the placeholder
Left-Click on the Local Assignment operator icon on the Programming toolbar
Left-Click on the Constants icon on Mathcad’s Math ribbon
Left-Click on the symbol for π to insert the value for this constant
Type *radius^2 to finish the definition of the formula for Area and then hit the ENTER key
Left-Click outside of the Math region to complete the definition of the program
Using a Mathcad Program
Once defined, a Mathcad program can be called
anywhere below the program definition in the worksheet
using an evaluation statement. A is a program to find the
area of a circle. The program has two steps: (1) calculate
the radius of the circle and (2) calculate the area using
the formula π*radius2
.
We can call (or evaluate the) the program on the
worksheet by typing:
A(2m=
Or
A(0.375ft=
If we attempt to evaluate radius outside of the function,
we receive an error message since it is a locally defined
variable.
Notes about Program A (Area of a Circle)
A is a simple Mathcad program that can also be written as a single line statement, rather than a multiline
program. We have used this example to introduce two important Mathcad Programming tools: new
Program structure ( | ) and Local Assignment (  ). The new Program structure icon allows for multi-line
function definitions. The Local Assignment operator enables variable names to be created and used within
a Mathcad function. These local variables do not exist outside of the program definition on the worksheet.
The presentation of A in this tutorial highlights the ways that Mathcad’s programming capabilities allow
for both clear communication and efficient notation. In this program the use of local variables for radius
This result will initially
appear in meters.
Change m to ft and the
result converts
automatically.
Programming with Mathcad Prime | pg. 5
and Area in the function definition clearly identifies the purpose of the program. The use of A as the name
of the function makes it easy to call the function as often as necessary within a worksheet.
Programming Practice: Formalizing Mathematical Relationships
Hero’s Formula can be used to calculate the area of a triangle when you know the lengths of all three
sides of the triangle. The image below shows how to use Hero’s Formula in a Mathcad worksheet.
Task: Use Mathcad’s Programming capabilities to create a function called HeroF that takes the lengths of
the 3 sides of a triangle as input parameters as shown at left below. The program should return the
calculation of the area of the triangle as shown in the two examples at right.
Square Root Symbol
The “” backslash key is the hotkey for
the square root symbol in Mathcad.
Programming with Mathcad Prime | pg. 6
Modeling a Mathematical Process
Many mathematical concepts can be modeled in multiple ways, one of which is through iteration
(repeating the same step over and over). For instance, the concept of the mathematical mean (a.k.a.
average) of a set of numbers is often informally defined as “add up all the numbers in a list and then
divide by the number of terms in the list.” Such a definition can be programmed quite literally using
Mathcad’s Programming capabilities. I will use this example to demonstrate how to create a looping
structure in a Mathcad function.
In this part of the tutorial I will introduce the steps necessary to create the following function:
Averaginator is a function that follows the informal definition of a mathematical average in the above
paragraph. One goal of this part of this tutorial is to show how a program can be used to mimic a process
in a step-by-step manner.
Step 1: Define the Program Name and Parameters List
Type Averaginator(Terms,List: to create the left side of the assignment statement for the program
Left-Click on the Math ribbon and then Left-Click on the Programming icon
Left-Click on | to insert a new Program Structure in the function definition
Step 2: Define a local variable count to control the execution of the loop
Type count in the placeholder on the first line of the program
Left-click on the Programming menu and then left-click on  to insert a Local Assignment symbol
Type 0 and hit Enter to add a new line to the function definition
List will be a matrix
containing 1 or
more numbers
In this example we will count from 0 because
count will be used to control the execution of the
loop and as a matrix subscript to access the
terms in the list of values to be averaged.
Programming with Mathcad Prime | pg. 7
Step 3: Define a local variable to keep track of the sum of the terms in List
Type sum in the placeholder on the second line of the program
Left-click on the Programming menu and then left-click on  to insert a Local Assignment symbol
Type 0 and hit Enter to add a new line to the function definition
Step 4: Create a for loop in the program to calculate the average of the terms in List
With the blue cursor in the placeholder on the third line Left-Click on the Programming icon
Left-Click on for in the Programming toolbar. Mathcad will insert a template for defining a for loop
Step 5: Complete the values in the template for the for loop
In the first placeholder type count, the name given to our local variable for controlling the loop
Create a range variable: In the second placeholder type 0,
Mathcad will insert a template for a range variable as shown below:
In the first empty placeholder for the range variable type 1
In the second placeholder for the range variable type Terms - 1
Left-Click in the placeholder for the body of the for loop
Important Note: The list of terms to be averaged will
be passed to the program as an nx1 matrix, so count
will also be used as a matrix subscript to refer to
each element in the matrix. By default, Mathcad
defines the first position in an array as position 0.
The for loop template has placeholders
for the name of the counter variable, the
range of values for the counter, and the
body of the loop. The body can be one
or more lines.
Programming with Mathcad Prime | pg. 8
Step 6: Enter the expression to sum the terms in the List matrix as a line in the body of the for loop
Type sum in the placeholder of the body of the for loop
Insert a Local Assignment operator
Type sum+List[count to complete the definition of sum
Step 7: Calculate the average (mean) as the sum divided by the number of terms
Use the right arrow key to move the blue cursor to the right until it extends to the full height of the for
loop template. You should only need to hit it twice. If necessary, you can place the cursor outside of the
for loop with your mouse.
Hit the Enter key to create a new line in the function
definition
In the placeholder type Mean
Insert a Local Assignment Operator
Type Sum/Terms in the open placeholder
Click in the worksheet outside the Averaginator region
Step 8: In the main body of the Mathcad worksheet define a variable containing a 5x1 matrix
Type DataList:
Left-Click on the Matrices/Tables tab
Left-Click on the Insert Matrix icon and drag select a 5x1 matrix
Type 5 numerical values into the matrix placeholders
Programming with Mathcad Prime | pg. 9
Step 9: Test the Averaginator Program
Beneath the definition of the Averaginator function and the DataList variable type:
Averaginator(5,DataList)=
Try the Averaginator Program using different values in the DataList!
Try the Averaginator Program using a different size data set!
(Review Step 8 if you forget how to create a Matrix variable)
The Averaginator function will calculate
the mean of the values in any n x 1
matrix as long as the program is called
using the syntax
Averaginator(n,Matrix Name)
You can even use units
in the data list!
Programming with Mathcad Prime | pg. 10
Programming Practice: Modeling a Mathematical Process
Cooper’s Is it a factor? Algorithm
While I was writing this tutorial, I took a break to help my 10-year-old son learn how to identify if a given
number is a factor of a target number. As he described his process to me, I realized that it would be
relatively easy to recreate his thinking process as a Mathcad program. Here is the gist of his strategy in
English and as a Mathcad program:
1. Starting with the given number itself, work your
way through the multiples of the given number until
you reach a number that is greater than or equal to the
target number.
2. If you reach the exact target number, write down
the number of multiples because that is another factor
of the target number
3. If you exceed the target number, then the given
number is not a factor of the target number
Task Notes:
1. A while loop is a conditional loop. It is created in a similar way as you create a for loop. In the
IsFactor program above the while loop runs until product is greater than or equal to target.
2. Inside the while loop an if statement is used to determine if the product is currently equal to the
target value. You need to use the if command from the Mathcad Prime programming palette to
insert an if statement into a program.
3. The return command is a special command that ends the execution of the program and returns
the value given in the return statement. In this case we use return to return the value of the other
factor or the value 0 if the given term is not a factor of the target.
Task: Create a Mathcad program that determines if a given number is a factor of a target number. You
may recreate the program above for practice, or write your own program from scratch.
Programming with Mathcad Prime | pg. 11
Summary
1. In this tutorial you have learned some basic Mathcad Programming capabilities. Mathcad makes
it easy to include computer programs in a worksheet alongside text, numerical calculations,
tables, and graphs.
2. The following skills were emphasized in this tutorial:
o Defining a Mathcad program to perform a mathematical calculation or process
o Using local variable assignment to create self-documenting programs
3. The following Mathcad Programming tools were introduced in a tutorial:
o Program Structure “|”
o Local Assignment “”
o For loop
4. The following Mathcad Programming tools were shown in a demonstration:
o While loop
o if statement
o return statement
5. To learn more about writing programs using Mathcad Prime see the Programming Tutorial that
is available from the Getting Started tab on the Mathcad Prime ribbon.
Great job completing this tutorial!

More Related Content

What's hot

The Butterfly Valve Assembly Pro E vaibhavkumar vaghani
The Butterfly Valve Assembly Pro E vaibhavkumar vaghaniThe Butterfly Valve Assembly Pro E vaibhavkumar vaghani
The Butterfly Valve Assembly Pro E vaibhavkumar vaghaniVaibhavkumar Vaghani
 
Chapter 5 beams design
Chapter 5  beams designChapter 5  beams design
Chapter 5 beams designSimon Foo
 
resistance spot welding
resistance spot weldingresistance spot welding
resistance spot weldingShaff Fx
 
Lecture 12 equivalent frame method
Lecture 12 equivalent frame methodLecture 12 equivalent frame method
Lecture 12 equivalent frame methodalialhussainawi
 
Chapter02.structural design using staad pro
Chapter02.structural design using staad proChapter02.structural design using staad pro
Chapter02.structural design using staad proKenylNguyen
 
Deflection in beams
Deflection in beamsDeflection in beams
Deflection in beamsYatin Singh
 
Anchor bolt load capacities F1554
Anchor bolt load capacities F1554Anchor bolt load capacities F1554
Anchor bolt load capacities F1554John Schuepbach
 
Finite Element Analysis - UNIT-5
Finite Element Analysis - UNIT-5Finite Element Analysis - UNIT-5
Finite Element Analysis - UNIT-5propaul
 
Design of Water Tank for the Town of Population 50000 and Analysis by- Staad Pro
Design of Water Tank for the Town of Population 50000 and Analysis by- Staad ProDesign of Water Tank for the Town of Population 50000 and Analysis by- Staad Pro
Design of Water Tank for the Town of Population 50000 and Analysis by- Staad ProIRJET Journal
 
22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...
22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...
22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...Hossam Shafiq II
 
Stl cnx - weld - solutions to design of weldments - blodgett
Stl   cnx - weld - solutions to design of weldments - blodgettStl   cnx - weld - solutions to design of weldments - blodgett
Stl cnx - weld - solutions to design of weldments - blodgettDurim Bajrami
 

What's hot (20)

The Butterfly Valve Assembly Pro E vaibhavkumar vaghani
The Butterfly Valve Assembly Pro E vaibhavkumar vaghaniThe Butterfly Valve Assembly Pro E vaibhavkumar vaghani
The Butterfly Valve Assembly Pro E vaibhavkumar vaghani
 
Chapter 5 beams design
Chapter 5  beams designChapter 5  beams design
Chapter 5 beams design
 
Robot khmer engineer
Robot khmer engineerRobot khmer engineer
Robot khmer engineer
 
CSI ETABS & SAFE MANUAL: Slab Analysis and Design to EC2
CSI ETABS & SAFE MANUAL: Slab Analysis and Design to EC2CSI ETABS & SAFE MANUAL: Slab Analysis and Design to EC2
CSI ETABS & SAFE MANUAL: Slab Analysis and Design to EC2
 
resistance spot welding
resistance spot weldingresistance spot welding
resistance spot welding
 
report
reportreport
report
 
Steel warehouse design report
Steel warehouse design reportSteel warehouse design report
Steel warehouse design report
 
Lecture 12 equivalent frame method
Lecture 12 equivalent frame methodLecture 12 equivalent frame method
Lecture 12 equivalent frame method
 
Chapter02.structural design using staad pro
Chapter02.structural design using staad proChapter02.structural design using staad pro
Chapter02.structural design using staad pro
 
Wf column sizes
Wf column sizesWf column sizes
Wf column sizes
 
Press fit force calculation
Press fit force calculationPress fit force calculation
Press fit force calculation
 
Deflection in beams
Deflection in beamsDeflection in beams
Deflection in beams
 
Anchor bolt load capacities F1554
Anchor bolt load capacities F1554Anchor bolt load capacities F1554
Anchor bolt load capacities F1554
 
Finite Element Analysis - UNIT-5
Finite Element Analysis - UNIT-5Finite Element Analysis - UNIT-5
Finite Element Analysis - UNIT-5
 
Design of Water Tank for the Town of Population 50000 and Analysis by- Staad Pro
Design of Water Tank for the Town of Population 50000 and Analysis by- Staad ProDesign of Water Tank for the Town of Population 50000 and Analysis by- Staad Pro
Design of Water Tank for the Town of Population 50000 and Analysis by- Staad Pro
 
22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...
22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...
22-Design of Four Bolt Extended Endplate Connection (Steel Structural Design ...
 
Etabs (atkins)
Etabs (atkins)Etabs (atkins)
Etabs (atkins)
 
Presentation 5-tekla
Presentation 5-teklaPresentation 5-tekla
Presentation 5-tekla
 
Stl cnx - weld - solutions to design of weldments - blodgett
Stl   cnx - weld - solutions to design of weldments - blodgettStl   cnx - weld - solutions to design of weldments - blodgett
Stl cnx - weld - solutions to design of weldments - blodgett
 
Bolted connections
Bolted connectionsBolted connections
Bolted connections
 

Viewers also liked

Mathcad puro
Mathcad   puroMathcad   puro
Mathcad puroomar8
 
Tema 11. M_Loli
Tema 11. M_LoliTema 11. M_Loli
Tema 11. M_LoliA. Casas
 
Paisaje Natural Academia
Paisaje Natural  AcademiaPaisaje Natural  Academia
Paisaje Natural Academiaguestad2a4bb
 
Manual de mathcad 14 en español
Manual de mathcad 14 en españolManual de mathcad 14 en español
Manual de mathcad 14 en españolinfante1992
 
Comentario mapa histórico
Comentario mapa históricoComentario mapa histórico
Comentario mapa históricoJavier Bernal
 
Paisaje por Van Gogh
Paisaje por Van GoghPaisaje por Van Gogh
Paisaje por Van GoghAna Municio
 
1os Medios Paisaje Chileno
1os  Medios Paisaje Chileno1os  Medios Paisaje Chileno
1os Medios Paisaje Chilenojegocon
 

Viewers also liked (20)

Mathcad
MathcadMathcad
Mathcad
 
Mathcad puro
Mathcad   puroMathcad   puro
Mathcad puro
 
Tutorial mathcad
Tutorial mathcadTutorial mathcad
Tutorial mathcad
 
Tema 11. M_Loli
Tema 11. M_LoliTema 11. M_Loli
Tema 11. M_Loli
 
Paisaje Natural Academia
Paisaje Natural  AcademiaPaisaje Natural  Academia
Paisaje Natural Academia
 
Mathcad -eurocodes-save time! 1401
Mathcad -eurocodes-save time! 1401Mathcad -eurocodes-save time! 1401
Mathcad -eurocodes-save time! 1401
 
Manual de mathcad 14 en español
Manual de mathcad 14 en españolManual de mathcad 14 en español
Manual de mathcad 14 en español
 
Mathcad vs excel presentation 1311
Mathcad vs excel presentation 1311Mathcad vs excel presentation 1311
Mathcad vs excel presentation 1311
 
Comentario mapa histórico
Comentario mapa históricoComentario mapa histórico
Comentario mapa histórico
 
Bodegones
BodegonesBodegones
Bodegones
 
UD 10 La crisis del siglo XVII
UD 10 La crisis del siglo XVIIUD 10 La crisis del siglo XVII
UD 10 La crisis del siglo XVII
 
Unidad 10. La vida en grecia
Unidad 10. La vida en greciaUnidad 10. La vida en grecia
Unidad 10. La vida en grecia
 
Book คู่มือโปรแกรมสำเร็จรูป mathcad mathematica​ matlap maple
Book คู่มือโปรแกรมสำเร็จรูป mathcad mathematica​ matlap mapleBook คู่มือโปรแกรมสำเร็จรูป mathcad mathematica​ matlap maple
Book คู่มือโปรแกรมสำเร็จรูป mathcad mathematica​ matlap maple
 
El paisaje
El paisaje El paisaje
El paisaje
 
Ud 11 MN. El antiguo Egipto
Ud 11 MN. El antiguo EgiptoUd 11 MN. El antiguo Egipto
Ud 11 MN. El antiguo Egipto
 
UD 9. El siglo XVI. La hegemonía española.
UD 9. El siglo XVI. La hegemonía española.UD 9. El siglo XVI. La hegemonía española.
UD 9. El siglo XVI. La hegemonía española.
 
Paisaje por Van Gogh
Paisaje por Van GoghPaisaje por Van Gogh
Paisaje por Van Gogh
 
Artistas Chilenos
Artistas ChilenosArtistas Chilenos
Artistas Chilenos
 
Paisajistas
PaisajistasPaisajistas
Paisajistas
 
1os Medios Paisaje Chileno
1os  Medios Paisaje Chileno1os  Medios Paisaje Chileno
1os Medios Paisaje Chileno
 

Similar to Programming with Mathcad Prime

Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...IRJET Journal
 
8.1 alogorithm & prolem solving
8.1 alogorithm & prolem solving8.1 alogorithm & prolem solving
8.1 alogorithm & prolem solvingKhan Yousafzai
 
MATLAB Assignment Help
MATLAB Assignment HelpMATLAB Assignment Help
MATLAB Assignment HelpEssay Corp
 
Math cad 14 user manual
Math cad 14 user manualMath cad 14 user manual
Math cad 14 user manualPeter Tran
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit orderMalikireddy Bramhananda Reddy
 
Anything but simple Mathematica
Anything but simple MathematicaAnything but simple Mathematica
Anything but simple MathematicaSergeiPronkevich
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 90681061992
 
Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Severus Prime
 
Mml micro project Building a Basic statistic calculator using r programming ...
Mml micro project Building a Basic statistic calculator  using r programming ...Mml micro project Building a Basic statistic calculator  using r programming ...
Mml micro project Building a Basic statistic calculator using r programming ...SakshamDandnaik
 
Map reduce in Hadoop BIG DATA ANALYTICS
Map reduce in Hadoop BIG DATA ANALYTICSMap reduce in Hadoop BIG DATA ANALYTICS
Map reduce in Hadoop BIG DATA ANALYTICSArchana Gopinath
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with MathematicaMiles Ford
 
I am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfI am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfmallik3000
 

Similar to Programming with Mathcad Prime (20)

Mathcad
MathcadMathcad
Mathcad
 
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
 
8.1 alogorithm & prolem solving
8.1 alogorithm & prolem solving8.1 alogorithm & prolem solving
8.1 alogorithm & prolem solving
 
Matlab demo
Matlab demoMatlab demo
Matlab demo
 
C AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDYC AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDY
 
MATLAB Assignment Help
MATLAB Assignment HelpMATLAB Assignment Help
MATLAB Assignment Help
 
Mathcad users guide
Mathcad users guideMathcad users guide
Mathcad users guide
 
Math cad 14 user manual
Math cad 14 user manualMath cad 14 user manual
Math cad 14 user manual
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
 
Flowcharting and Algorithm
Flowcharting and Algorithm Flowcharting and Algorithm
Flowcharting and Algorithm
 
Anything but simple Mathematica
Anything but simple MathematicaAnything but simple Mathematica
Anything but simple Mathematica
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 9068
 
Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System
 
Mml micro project Building a Basic statistic calculator using r programming ...
Mml micro project Building a Basic statistic calculator  using r programming ...Mml micro project Building a Basic statistic calculator  using r programming ...
Mml micro project Building a Basic statistic calculator using r programming ...
 
Map reduce in Hadoop BIG DATA ANALYTICS
Map reduce in Hadoop BIG DATA ANALYTICSMap reduce in Hadoop BIG DATA ANALYTICS
Map reduce in Hadoop BIG DATA ANALYTICS
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
 
AutoMapper
AutoMapperAutoMapper
AutoMapper
 
I am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfI am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdf
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 

More from Caroline de Villèle

Mathcad 15 m045 à lire en premier
Mathcad 15 m045 à lire en premierMathcad 15 m045 à lire en premier
Mathcad 15 m045 à lire en premierCaroline de Villèle
 
Nexter munitions reduces significantly cost and time of r&d developments with...
Nexter munitions reduces significantly cost and time of r&d developments with...Nexter munitions reduces significantly cost and time of r&d developments with...
Nexter munitions reduces significantly cost and time of r&d developments with...Caroline de Villèle
 
Mathcad Prime 3.1 à lire en premier
Mathcad Prime 3.1   à lire en premierMathcad Prime 3.1   à lire en premier
Mathcad Prime 3.1 à lire en premierCaroline de Villèle
 
Trucs et astruces relatifs à PTC Mathcad Prime
Trucs et astruces relatifs à PTC Mathcad PrimeTrucs et astruces relatifs à PTC Mathcad Prime
Trucs et astruces relatifs à PTC Mathcad PrimeCaroline de Villèle
 
PTC® Mathcad® 15.0 M030 features
PTC® Mathcad® 15.0 M030 featuresPTC® Mathcad® 15.0 M030 features
PTC® Mathcad® 15.0 M030 featuresCaroline de Villèle
 
Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...
Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...
Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...Caroline de Villèle
 
Standardizing Engineering Calculations in a Product Development System
Standardizing Engineering Calculations in a Product Development SystemStandardizing Engineering Calculations in a Product Development System
Standardizing Engineering Calculations in a Product Development SystemCaroline de Villèle
 
Parametric Equations with Mathcad Prime
Parametric Equations with Mathcad PrimeParametric Equations with Mathcad Prime
Parametric Equations with Mathcad PrimeCaroline de Villèle
 
Formation standard - Principes de base de mathcad 15
Formation standard - Principes de base de mathcad 15Formation standard - Principes de base de mathcad 15
Formation standard - Principes de base de mathcad 15Caroline de Villèle
 
Bonnes pratiques : la hiérarchie des exigences
Bonnes pratiques : la hiérarchie des exigencesBonnes pratiques : la hiérarchie des exigences
Bonnes pratiques : la hiérarchie des exigencesCaroline de Villèle
 
RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...
RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...
RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...Caroline de Villèle
 
Pourquoi mettre en péril vos calculs critiques??
Pourquoi mettre en péril vos calculs critiques??Pourquoi mettre en péril vos calculs critiques??
Pourquoi mettre en péril vos calculs critiques??Caroline de Villèle
 
Repousser les limites des mathématiques : études de cas concernant les défis ...
Repousser les limites des mathématiques : études de cas concernant les défis ...Repousser les limites des mathématiques : études de cas concernant les défis ...
Repousser les limites des mathématiques : études de cas concernant les défis ...Caroline de Villèle
 

More from Caroline de Villèle (20)

Ptc mathcad prime 4.0 brochure
Ptc mathcad prime 4.0 brochurePtc mathcad prime 4.0 brochure
Ptc mathcad prime 4.0 brochure
 
Mathcad 15 m045 à lire en premier
Mathcad 15 m045 à lire en premierMathcad 15 m045 à lire en premier
Mathcad 15 m045 à lire en premier
 
Nexter munitions reduces significantly cost and time of r&d developments with...
Nexter munitions reduces significantly cost and time of r&d developments with...Nexter munitions reduces significantly cost and time of r&d developments with...
Nexter munitions reduces significantly cost and time of r&d developments with...
 
Mathcad Prime 3.1 à lire en premier
Mathcad Prime 3.1   à lire en premierMathcad Prime 3.1   à lire en premier
Mathcad Prime 3.1 à lire en premier
 
Trucs et astruces relatifs à PTC Mathcad Prime
Trucs et astruces relatifs à PTC Mathcad PrimeTrucs et astruces relatifs à PTC Mathcad Prime
Trucs et astruces relatifs à PTC Mathcad Prime
 
PTC® Mathcad® 15.0 M030 features
PTC® Mathcad® 15.0 M030 featuresPTC® Mathcad® 15.0 M030 features
PTC® Mathcad® 15.0 M030 features
 
Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...
Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...
Making the Case for PTC Mathcad®: How a Small Investment Can Lead to Gains in...
 
a disaster waiting to happen
a disaster waiting to happena disaster waiting to happen
a disaster waiting to happen
 
Pushing the Mathematical Envelope
Pushing the Mathematical EnvelopePushing the Mathematical Envelope
Pushing the Mathematical Envelope
 
Standardizing Engineering Calculations in a Product Development System
Standardizing Engineering Calculations in a Product Development SystemStandardizing Engineering Calculations in a Product Development System
Standardizing Engineering Calculations in a Product Development System
 
Calculations e book
Calculations e bookCalculations e book
Calculations e book
 
Mathcad 15 overview
Mathcad 15 overviewMathcad 15 overview
Mathcad 15 overview
 
Parametric Equations with Mathcad Prime
Parametric Equations with Mathcad PrimeParametric Equations with Mathcad Prime
Parametric Equations with Mathcad Prime
 
Ptc Mathcad & Technip
Ptc Mathcad & Technip Ptc Mathcad & Technip
Ptc Mathcad & Technip
 
Formation standard - Principes de base de mathcad 15
Formation standard - Principes de base de mathcad 15Formation standard - Principes de base de mathcad 15
Formation standard - Principes de base de mathcad 15
 
Mathcad 15 en quelques mots
Mathcad 15 en quelques motsMathcad 15 en quelques mots
Mathcad 15 en quelques mots
 
Bonnes pratiques : la hiérarchie des exigences
Bonnes pratiques : la hiérarchie des exigencesBonnes pratiques : la hiérarchie des exigences
Bonnes pratiques : la hiérarchie des exigences
 
RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...
RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...
RÉSOUDRE LE COMPROMIS DES CALCULS TECHNIQUES ...
 
Pourquoi mettre en péril vos calculs critiques??
Pourquoi mettre en péril vos calculs critiques??Pourquoi mettre en péril vos calculs critiques??
Pourquoi mettre en péril vos calculs critiques??
 
Repousser les limites des mathématiques : études de cas concernant les défis ...
Repousser les limites des mathématiques : études de cas concernant les défis ...Repousser les limites des mathématiques : études de cas concernant les défis ...
Repousser les limites des mathématiques : études de cas concernant les défis ...
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Programming with Mathcad Prime

  • 1. PTC Academic Program Learn. Create. Collaborate. Succeed. Programming with Mathcad Prime™
  • 2. Written By Chris Hartmann, Anji Seberino & Roger Yeh These materials are ©2011 , Parametric Technology Corporation (PTC) All rights reserved under copyright laws of the United States and other countries. PTC, the PTC Logo, Mathcad and all PTC product names and logos are trademarks or registered trademarks of PTC and/or its subsidiaries in the United States and in other countries. Conditions of Use Copying and use of these materials for educational purposes is fully authorized for any person(s). Acknowledgments The authors gratefully acknowledge the support of the Mathcad Business Unit and the PTC Academic Program. Questions or Corrections Please direct inquiries or questions regarding the contents of this tutorial to the Mathcad Academic Program at MathcadEducation@ptc.com. Suggestions for improvement or further development will be gladly accepted.
  • 3. PTC Academic Program Learn. Create. Collaborate. Succeed. Programming with Mathcad Prime Mathcad Prime is an environment for Computational Thinking – an approach to calculation, data analysis and problem solving that uses the capabilities of a computer to construct better solutions. When used appropriately computational thinking:  Helps to illustrate the solution to a problem more clearly  Produces meaningful answers to a challenging problems more quickly  Off-loads some of the complexities of a problem to a computer in ways that enable better human insight into the nature of a problem in order to further the solution process Mathcad Prime possesses a simple and easy to use Programming capability that allows users to write multistep functions directly on a worksheet alongside equations, tables, graphs, and text. Mathcad Prime’s Programming Commands Using Mathcad’s programming capabilities in math and science coursework can help students understand concepts more deeply. It also helps introduces them to some computer programming basics. In this tutorial we will focus on two different ways to use Mathcad’s Programming capabilities to Go Beyond the Basics in math and science courses: 1. Formalizing Mathematical Relationships 2. Modeling Mathematical Processes Each example will introduce a small number of Mathcad’s Programming capabilities in order to help you to build up your proficiency in writing Functions on a Mathcad worksheet.
  • 4. Programming with Mathcad Prime | pg. 2 Formalizing Mathematical Relationships When working on a Mathcad Prime worksheet, the expression of a formula is equivalent to writing a one- line computer program. I will illustrate this idea by showing two different ways to define the mathematical relationship between a diameter of a circle and the circumference and area measurements of the circle. In a Mathcad worksheet it would be typical to use formulas to calculate the Area and Circumference of a circle using assignment statements such as those shown below. Writing a computer program on a Mathcad worksheet is a lot like defining and evaluating formulas like those above. Once defined, the formulas above instruct Mathcad to perform all of the steps in the definition and return a result. Similarly, Mathcad programs report the last result calculated or assigned in the program. Returning this result is a lot like reporting the final result after following order of operations in a numerical expression. We can use Mathcad’s Programming tools to create the formulas above as Mathcad programs. Although we do not need to write programs to perform these calculations, we will use this simple example to introduce the Local Assignment () operator and the Program Structure (|) symbol on Mathcad’s Programming Toolbar. Local assignment in simple Mathcad programs When writing computer programs it is good programming practice to reduce the memory requirements of a program by defining variables that only exist while the program is running. Similarly, in a Mathcad worksheet it is good practice to carefully manage the variable definitions one uses. Since variable definitions are live everywhere down and to the right of the initial assignment in a Mathcad Worksheet, Local Assignment in programs reduces the total number of live variable definitions. In the box below, a simple one-line Mathcad program is used to calculate the circumference of a circle using the measure of a diameter. This example demonstrates how the Local Definition operator works in a Mathcad worksheet.
  • 5. Programming with Mathcad Prime | pg. 3 Local Definition In the image at right the formula for circumference of a circle is defined in a Mathcad Program using Mathcad Prime’s Local Definition operator . In this case the use of the Local Definition helps to clarify the meaning of the program named C. C accepts a single parameter, the measurement of a diameter of the circle. During program execution Circumference is calculated using the formula π*D. C returns the value of Circumference, the last value calculated. But, since it is defined locally, the value of Circumference is undefined outside of the program definition. Therefore, Circumference is undefined on the worksheet and returns an error when evaluated. Follow these steps to create a Mathcad program that calculates the area of a circle given its Diameter as an input parameter: Step 1: Type the following keystrokes to give the program a name and a parameter: A(D: You should see this on the worksheet: Step 2: Mathcad shows that it is waiting for the program to be defined on the right side of the assignment statement by leaving the blue cursor in the placeholder. Follow these steps to insert the first line of the program: Left-click to select the Math ribbon Left-click on the Programming icon Left-click the Insert Program Structure icon on the Programming menu Type: radius in the placeholder Left-click on the Programming icon on the Math ribbon Left-click on the Local Assignment Operator icon on the Programming menu Type: D/2 in the placeholder. Hit the Right Arrow key once to advance the cursor and then hit the ENTER key. A new Program line will appear as shown.
  • 6. Programming with Mathcad Prime | pg. 4 Step 3: Follow these instructions to add the second line of the program: Type Area in the placeholder Left-Click on the Local Assignment operator icon on the Programming toolbar Left-Click on the Constants icon on Mathcad’s Math ribbon Left-Click on the symbol for π to insert the value for this constant Type *radius^2 to finish the definition of the formula for Area and then hit the ENTER key Left-Click outside of the Math region to complete the definition of the program Using a Mathcad Program Once defined, a Mathcad program can be called anywhere below the program definition in the worksheet using an evaluation statement. A is a program to find the area of a circle. The program has two steps: (1) calculate the radius of the circle and (2) calculate the area using the formula π*radius2 . We can call (or evaluate the) the program on the worksheet by typing: A(2m= Or A(0.375ft= If we attempt to evaluate radius outside of the function, we receive an error message since it is a locally defined variable. Notes about Program A (Area of a Circle) A is a simple Mathcad program that can also be written as a single line statement, rather than a multiline program. We have used this example to introduce two important Mathcad Programming tools: new Program structure ( | ) and Local Assignment (  ). The new Program structure icon allows for multi-line function definitions. The Local Assignment operator enables variable names to be created and used within a Mathcad function. These local variables do not exist outside of the program definition on the worksheet. The presentation of A in this tutorial highlights the ways that Mathcad’s programming capabilities allow for both clear communication and efficient notation. In this program the use of local variables for radius This result will initially appear in meters. Change m to ft and the result converts automatically.
  • 7. Programming with Mathcad Prime | pg. 5 and Area in the function definition clearly identifies the purpose of the program. The use of A as the name of the function makes it easy to call the function as often as necessary within a worksheet. Programming Practice: Formalizing Mathematical Relationships Hero’s Formula can be used to calculate the area of a triangle when you know the lengths of all three sides of the triangle. The image below shows how to use Hero’s Formula in a Mathcad worksheet. Task: Use Mathcad’s Programming capabilities to create a function called HeroF that takes the lengths of the 3 sides of a triangle as input parameters as shown at left below. The program should return the calculation of the area of the triangle as shown in the two examples at right. Square Root Symbol The “” backslash key is the hotkey for the square root symbol in Mathcad.
  • 8. Programming with Mathcad Prime | pg. 6 Modeling a Mathematical Process Many mathematical concepts can be modeled in multiple ways, one of which is through iteration (repeating the same step over and over). For instance, the concept of the mathematical mean (a.k.a. average) of a set of numbers is often informally defined as “add up all the numbers in a list and then divide by the number of terms in the list.” Such a definition can be programmed quite literally using Mathcad’s Programming capabilities. I will use this example to demonstrate how to create a looping structure in a Mathcad function. In this part of the tutorial I will introduce the steps necessary to create the following function: Averaginator is a function that follows the informal definition of a mathematical average in the above paragraph. One goal of this part of this tutorial is to show how a program can be used to mimic a process in a step-by-step manner. Step 1: Define the Program Name and Parameters List Type Averaginator(Terms,List: to create the left side of the assignment statement for the program Left-Click on the Math ribbon and then Left-Click on the Programming icon Left-Click on | to insert a new Program Structure in the function definition Step 2: Define a local variable count to control the execution of the loop Type count in the placeholder on the first line of the program Left-click on the Programming menu and then left-click on  to insert a Local Assignment symbol Type 0 and hit Enter to add a new line to the function definition List will be a matrix containing 1 or more numbers In this example we will count from 0 because count will be used to control the execution of the loop and as a matrix subscript to access the terms in the list of values to be averaged.
  • 9. Programming with Mathcad Prime | pg. 7 Step 3: Define a local variable to keep track of the sum of the terms in List Type sum in the placeholder on the second line of the program Left-click on the Programming menu and then left-click on  to insert a Local Assignment symbol Type 0 and hit Enter to add a new line to the function definition Step 4: Create a for loop in the program to calculate the average of the terms in List With the blue cursor in the placeholder on the third line Left-Click on the Programming icon Left-Click on for in the Programming toolbar. Mathcad will insert a template for defining a for loop Step 5: Complete the values in the template for the for loop In the first placeholder type count, the name given to our local variable for controlling the loop Create a range variable: In the second placeholder type 0, Mathcad will insert a template for a range variable as shown below: In the first empty placeholder for the range variable type 1 In the second placeholder for the range variable type Terms - 1 Left-Click in the placeholder for the body of the for loop Important Note: The list of terms to be averaged will be passed to the program as an nx1 matrix, so count will also be used as a matrix subscript to refer to each element in the matrix. By default, Mathcad defines the first position in an array as position 0. The for loop template has placeholders for the name of the counter variable, the range of values for the counter, and the body of the loop. The body can be one or more lines.
  • 10. Programming with Mathcad Prime | pg. 8 Step 6: Enter the expression to sum the terms in the List matrix as a line in the body of the for loop Type sum in the placeholder of the body of the for loop Insert a Local Assignment operator Type sum+List[count to complete the definition of sum Step 7: Calculate the average (mean) as the sum divided by the number of terms Use the right arrow key to move the blue cursor to the right until it extends to the full height of the for loop template. You should only need to hit it twice. If necessary, you can place the cursor outside of the for loop with your mouse. Hit the Enter key to create a new line in the function definition In the placeholder type Mean Insert a Local Assignment Operator Type Sum/Terms in the open placeholder Click in the worksheet outside the Averaginator region Step 8: In the main body of the Mathcad worksheet define a variable containing a 5x1 matrix Type DataList: Left-Click on the Matrices/Tables tab Left-Click on the Insert Matrix icon and drag select a 5x1 matrix Type 5 numerical values into the matrix placeholders
  • 11. Programming with Mathcad Prime | pg. 9 Step 9: Test the Averaginator Program Beneath the definition of the Averaginator function and the DataList variable type: Averaginator(5,DataList)= Try the Averaginator Program using different values in the DataList! Try the Averaginator Program using a different size data set! (Review Step 8 if you forget how to create a Matrix variable) The Averaginator function will calculate the mean of the values in any n x 1 matrix as long as the program is called using the syntax Averaginator(n,Matrix Name) You can even use units in the data list!
  • 12. Programming with Mathcad Prime | pg. 10 Programming Practice: Modeling a Mathematical Process Cooper’s Is it a factor? Algorithm While I was writing this tutorial, I took a break to help my 10-year-old son learn how to identify if a given number is a factor of a target number. As he described his process to me, I realized that it would be relatively easy to recreate his thinking process as a Mathcad program. Here is the gist of his strategy in English and as a Mathcad program: 1. Starting with the given number itself, work your way through the multiples of the given number until you reach a number that is greater than or equal to the target number. 2. If you reach the exact target number, write down the number of multiples because that is another factor of the target number 3. If you exceed the target number, then the given number is not a factor of the target number Task Notes: 1. A while loop is a conditional loop. It is created in a similar way as you create a for loop. In the IsFactor program above the while loop runs until product is greater than or equal to target. 2. Inside the while loop an if statement is used to determine if the product is currently equal to the target value. You need to use the if command from the Mathcad Prime programming palette to insert an if statement into a program. 3. The return command is a special command that ends the execution of the program and returns the value given in the return statement. In this case we use return to return the value of the other factor or the value 0 if the given term is not a factor of the target. Task: Create a Mathcad program that determines if a given number is a factor of a target number. You may recreate the program above for practice, or write your own program from scratch.
  • 13. Programming with Mathcad Prime | pg. 11 Summary 1. In this tutorial you have learned some basic Mathcad Programming capabilities. Mathcad makes it easy to include computer programs in a worksheet alongside text, numerical calculations, tables, and graphs. 2. The following skills were emphasized in this tutorial: o Defining a Mathcad program to perform a mathematical calculation or process o Using local variable assignment to create self-documenting programs 3. The following Mathcad Programming tools were introduced in a tutorial: o Program Structure “|” o Local Assignment “” o For loop 4. The following Mathcad Programming tools were shown in a demonstration: o While loop o if statement o return statement 5. To learn more about writing programs using Mathcad Prime see the Programming Tutorial that is available from the Getting Started tab on the Mathcad Prime ribbon. Great job completing this tutorial!