Mathcad Lecture #3 In-class Worksheet Functions

Similar documents
Mathcad Lecture #1 In-class Worksheet Mathcad Basics

Advanced features of the Calculate signal tool

Lecture 2 FORTRAN Basics. Lubna Ahmed

Catholic Central High School

Programming in MATLAB Part 2

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types

Mathematical Operations

SENIOR HIGH MATH LEAGUE April 24, GROUP IV Emphasis on TRIGONOMETRY

Methods CSC 121 Fall 2014 Howard Rosenthal

6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design

Lecture 14. Daily Puzzle. Math in C. Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =?

SCIENTIFIC CALCULATOR OPERATION GUIDE < EL-531TG/531TH/531TS >

(Type your answer in radians. Round to the nearest hundredth as needed.)

Calculators ARE NOT Permitted On This Portion Of The Exam 28 Questions - 55 Minutes

CT 229 Java Syntax Continued

Python Numbers. Learning Outcomes 9/19/2012. CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17

Module 01: Introduction to Programming in Python

Python Lists: Example 1: >>> items=["apple", "orange",100,25.5] >>> items[0] 'apple' >>> 3*items[:2]

3.4 System Dynamics Tool: Nova Tutorial 2. Introduction to Computational Science: Modeling and Simulation for the Sciences

Program Structure and Format

Logic, Words, and Integers

Numerical Modelling in Fortran: day 2. Paul Tackley, 2017

CSI31 Lecture 5. Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial

MINI LESSON. Lesson 1a Introduction to Functions

Math 180 Written Homework Solutions Assignment #1 Due Thursday, September 4th at the beginning of your discussion class.

Choose the correct answer below. 2. Convert the angle to a decimal in degrees.

Integration. Edexcel GCE. Core Mathematics C4

Julia Calculator ( Introduction)

MATLAB for Chemical engineer

Bits, Words, and Integers

ANSYS AIM Tutorial Turbulent Flow Over a Backward Facing Step

Chapter 4: Basic C Operators

Name Date Class F 63 H 0.63 B 2.5 D G 6.3 I A 18 C F 60 H 0.6 B 1.8 D 0.018

MAINE ASSOCIATION OF MATH LEAGUES RULES GOVERNING QUESTIONS, ANSWERS, AND GRADING

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

XQ: An XML Query Language Language Reference Manual

9. Elementary Algebraic and Transcendental Scalar Functions

Solutions to: Unit Conversions and Significant Figures Problem Set S.E. Van Bramer (9/10/96)

2009 Fall Startup Event Thursday, September 24th, 2009

Java Classes: Math, Integer A C S L E C T U R E 8

MathsGeeks

Microwell Mixing with Surface Tension

Computer Programming ECIV 2303 Chapter 6 Programming in MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering

Activity Overview A basic introduction to the many features of the calculator function of the TI-Nspire

LECTURE 0: Introduction and Background

Introduction to C Language

APS Sixth Grade Math District Benchmark Assessment NM Math Standards Alignment

Built-in Types of Data

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

16.69 TAYLOR: Manipulation of Taylor series

An Introduction to Maple and Maplets for Calculus

ELEMENTARY MATLAB PROGRAMMING

Outline. Midterm Review. Using Excel. Midterm Review: Excel Basics. Using VBA. Sample Exam Question. Midterm Review April 4, 2014

Using Free Functions

C Functions. 5.2 Program Modules in C

Differentiation and Integration

Catholic Central High School

Copyright ABB Limited. All Rights Reserved.

9 Using Equation Networks

Wood Stave Average value, regardless of age 120. Large sizes, good workmanship, steel forms 140

During the timed portion for Part A, you may work only on the problems in Part A.

Ten Years of Field Experience with Flashing Two-Phase LNG Expanders GASEX 2012

7.1 It is well known that the formula for converting a temperature in Celsius to Fahrenheit is. o F = 9 5 o C (7.10)

MA 114 Worksheet #17: Average value of a function

CS 115 Data Types and Arithmetic; Testing. Taken from notes by Dr. Neil Moore

Questions Q1. (a) Find the values of the constants A, B and C. (4) b) Hence find

John Perry. Spring 2017

Introduction to Computer Programming with MATLAB Calculation and Programming Errors. Selis Önel, PhD

Math 124 Final Examination Winter 2016 !!! READ...INSTRUCTIONS...READ!!!

3.4 System Dynamics Tool: Vensim Tutorial 2. Introduction to Computational Science: Modeling and Simulation for the Sciences

Significant Figures & Scientific Notation

CS 115 Lecture 4. More Python; testing software. Neil Moore

1. Classify each number as one or more of the following: natural number, integer, rational number; or irrational number. ,,,,,

PTC Mathcad Prime 3.0

Variable and Data Type 2

MYSQL NUMERIC FUNCTIONS

Standard Practice for Using Significant Digits in Geotechnical Data 1

12-7 Volume of Pyramids, Cones, and Spheres

Python Programming: An Introduction to Computer Science

Strömningslära Fluid Dynamics. Computer laboratories using COMSOL v4.4

SENIOR HIGH MATH LEAGUE April 24, 2001 SECTION I: ONE POINT EACH

4/30/2015 Assignment Previewer

COP 4516: Math for Programming Contest Notes

5.1 Angles & Their Measures. Measurement of angle is amount of rotation from initial side to terminal side. radians = 60 degrees

MATH DICTIONARY. Number Sense. Number Families. Operations. Counting (Natural) Numbers The numbers we say when we count. Example: {0, 1, 2, 3, 4 }

Tuesday 22 January 2008 Afternoon Time: 1 hour 30 minutes

Methods CSC 121 Spring 2017 Howard Rosenthal

Quantifier Pro User Guide

1. How Mathematica works

VERSION RELEASE NOTES... 2 VERSION RELEASE NOTES... 3 VERSION RELEASE NOTES... 5

LinReg 2.06 Manual. DePauw University: Physics Department 120 Physics I and 130 Physics II

Methods CSC 121 Fall 2016 Howard Rosenthal

Outline. Data and Operations. Data Types. Integral Types

Chapter 12 Review Period:

6.001 Notes: Section 6.1

Review of Calculus, cont d

The Standard Module - Ventilation Systems

Compressible Flow in a Nozzle

Porous Reactor with Injection Needle

Transcription:

Mathcad Lecture #3 In-class Worksheet Functions At the end of this lecture, you should be able to: find and use intrinsic Mathcad Functions for fundamental, trigonometric, and if statements construct compound if functions using AND, OR, XOR, NO operators create user-defined functions construct use-defined functions with appropriate units decide when a user-defined function is needed 1. Intrinsic Mathcad Functions Mathcad has a myriad of mathematical functions. You have already used several of them which are available on the calculator tool palette. Several common functions are found in the table to the right. You can see all the functions available, as well as a description of each, by clicking on the f(x) button Practice 1. Calculate the following: floor of π, ceil of π, the remainder of dividing π by 3. 2. Round π to 5 decimal places. 3. Let x = 0.9 and calculate the following: e x, log 10 (x), log 2 (x), ln(x) rigonometric Functions All trigonometric function are available and are obtained by typing the name followed by ()'s. x is assumed to be in radians unless specified otherwise. 2. User-Defined Functions One of the powerful features of Mathcad is the ability to define your own functions. his is very helpful when doing engineering calculations and will be used often. Syntax o create a function: 1. ype the desired function name 2. ype (x) where x is the variable of the function. 3. ype : to give you := 4. Define the expression in terms of x. Note: you can use more then one variable in a function, simply separate each with a comma. Demonstration

Key Points 1. R g does not appear in the parameter list of the function so it must be defined previously. 2. 3. Parameters names (selected when a function if defined) correspond to the variable names from some governing equation. (e.g. For V=NR/P, N is given the name N moles ) o obtain a numerical answer, the function is given numbers as inputs. Important Point 1 he parameter names in the argument list of the function are really just place holders. When I evaluate the function, I can use other variables which contain the numerical values I want to use in evaluation. Notice that I can use the name function over and over to give me the volume of an ideal gas given any temperature and pressure. he temperature and pressure can be numbers (as done above) or variable names. he variable names do not have to be the same name as when the function was defined. Important Point 2 If you pass a function variables or numbers with incorrect units, the function will either not evaluate or return incorrect units. 3. Creating Functions Which Require Specific Units In engineering, we often need physical properties, such as heat capacities, to do design calculations. We usually obtain these by looking up an equation in a handbook. For example, the heat capacity of liquid water is dependent upon the temperature and can be found using the following equation. Cp( ) F BU lbmol F 18.4613 0.013584 7.2404510 5 2 1.8733510 7 3 2.1481510 10 4 he / F of the equation means the temperature must be in units of F. he BU/(lbmol* F) means the heat capacity returned by the equation is in those units. Our challenge is to write a Mathcad function that always returns the correct heat capacity based upon the equation given above. Before creating the function lets look at how Mathcad handles units and unit conversions.

Demonstration A 18.4613 B 0.01358 C 7.2404510 5 D 1.8733510 7 E 2.1481510 10 If you don't place units in, the function doesn't know what units the temperature is in. We write the expression to force the number passed to the function to always be in F. Key Points: he term in ()'s forces Mathcad to convert any temperature passed to the function into F as required by the original expression. Multiplying the entire expression by the correct units allows us to use the function in subsequent calculations and let Mathcad do the unit conversions. Practice

he Reynold s number is a dimensionless quantity used to characterize fluid flow. For a circular pipe, the Dv Reynold s number is defined as Re, where and are the density and viscosity of the fluid, D is the diameter of the pipe, and v is the velocity of the fluid through the pipe. Calculate the Reynold s number if water, at 2 degrees Celsius, travels down a 2 in diameter pipe at 3 m/s. he density and viscosity of water can be found from the expressions below. he molecular weight of water is 18.02 gm/mol. K 3703.6 exp 52.843 5.8660ln( ) 5.879 10 Pa s 6 2 9 3 13 4 C lbmol ft 3 7.98187 0.00138771 2.8747610 29 10.0000 1.9484510 3.7242810 A1 52.843 B1 3703.6 C1 5.8660 D1 5.87910 29 A2 7.98187 B2 0.00138771 C2 2.8747610 6 D2 1.9484510 9 E2 3.7242810 13 4. he if function Syntax if(condition, true, false) rue and false can be functions, text, letters, numbers, etc. Different conditions can be found on the Boolean tool palette. Demonstration Compound Logical Expressions Operator Symbol on ool Palette Description And ^ Returns 1 if both x and y are non-zero (true). Returns 0 otherwise. Or Returns 1 if either x or y are non-zero (true). Returns 0 otherwise. Exclusive or, xor Returns 1 if either x or y, but not both, are non-zero (true). Returns 0 otherwise. Not Returns 1 if x is zero (false). Returns 0 otherwise

Less than Returns 1 if x < y, 0 otherwise Greater than Returns 1 if x > y, 0 otherwise Equal to = Returns 1 if x + y, 0 otherwise Not Equal to Returns 1 if x does not equal y, 0 otherwise Demonstration Imagine that the temperature of the reactor must be kept above 170 C to keep the reaction going and below 200 C to prevent excessive pressure from forming in the vessel. Write a simple logical function to determine if the reaction temperature is in the correct range. Practice Write a logical function to turn on a drainage pump if the liquid height in a holding tank exceeds 3.1 meters and inlet flow rate exceeds 24.5 gal/min. If both of these conditions are met, the output from the function should equ 1.0, otherwise the output should equal 0 (zero). Extra Practice For x between 0 and 1, the series expansion of ln(1+x) is ln(1 x) n i1 ( 1) i1 x i i he series is exact if n =, but such a computation is computationally impossible. Construct a function named ln1x which accepts two parameters (x and n) and calcualtes ln(1+x) according to the seried above. Do a small parametric study to determine now many terms are needed to obtain accuracy out to the 6th decimal place. Check the results against the instrinsic Mathcad function.

Functions Description exp(x), e x he number e raised to the power of x. log(x,[b]) Base b logarithm of x. (b=10 by default) ln(x) Natural logarithm of x x! Factorial of x. max(a,b,c, ) he value of the largest argument. min(a,b,c, ) he value of the smallest argument. mean(a,b,c, ) he average of a,b,c, floor(x) he largest integer less than or equal to x. ceil(x) he smallest integer greater than or equal to x. he number x rounded to n decimal places. If n is omitted, x is round(x,n) rounded to the nearest integer. If n<0, x is rounded to the lefts of the decimal point. trunc(x) he integer part of x mod(x,y) he reminder of dividing x by y if(condition,true,false) If condition is true (non-zero), returns true. If condition is false, returns false. (calculus toolbar) n i1 f ( i), summation (calculus toolbar) n f ( i), product i1