Mathcad Training Book
Mathcad Training Table of Contents. Introdudtion. Solve Function Mathcad Toolbars Navigating the Resource Center Working with Mathcad Regions. Expressions & Variables Defining Variables Defining Functions Defining Vectors and Matrices Solving Quadratics Solving an Equation in a Single Unknown Solving a Linear System of Equations Solving a Nonlinear System of Equations Solving Each of a Family of Equations Solve Blocks with Inequality Constraints. Graph Linear Programming Creating Graphs Vectors and Matrices Array Algebra Operations on a Square Matrix Joining Matrices Defining Nested Arrays 5. UNITS Using Units Data Import & Export Handling Data Files Displaying Nested Arrays 6. Animation Vectorizing an Expression Array Size and Scope Animating a Graph Animations Component & MathML Components in Mathcad Using the Excel Component Using the SmartSketch Component Developing MathML Web Sites
Mathcad Toolbars The Main Menu math, graphics, symbolic functions. The Standard Toolbar opening and file saving spell checking Resource Center Electronic Books print and print preview built-in functions and units. QuickSheets The Formatting Toolbar View->Tool Bar->Formatting The Status Toolbar View->Status Bar status alerts, tips, keyboard shortcuts, Caps Lock, Num Lock page number. The Resource Center Navigational Controls Resource Center or other Mathcad Electronics Books Browsing. Navigating the Resource Center The Math Toolbar View->Tool Bar->Math Tool Main Menu. Calculator toolbar Graph toolbar Matrix toolbar Evaluation toolbar Calculus toolbar Boolean toolbar Programming toolbar Greek toolbar Symbolic toolbar
Navigating the Resource Center Navigating the Resource Center Resource Center home page Web Toolbar. (.).. Prints the current document..
Working with Mathcad Regions Mathcad equation, text paragraph, plot region. region math text. Text region : Text.. ["]... Mathcad Format menu. Formatting Math and Text. Edit menu Copy, Cut, Paste, Find, Replace, Check Spelling A math region x : A text region The assignment at left was created by typing x: Moving Regions region drag-select? cursor..? H cursor.? Hold. Hint: If you want to grab a group of regions, but want to deselect one of them, just [shift] [click] on individual regions or use [shift][click] to select regions one by one. Moving Regions from the Resource Center Window Deleting and Pasting Regions Aligning Regions Resource Center Electronic Book wokrsheet EDIT Copy Paste Copy : Ctrl+C, Paste : Ctrl+V EDIT Cut. Cut : Del. Format menu Align Regions paragraph. Align
Defining Variables Entering Math Type See on screen + Keystroke Button Example Keystroke Button Example + + /.5 - * ^ Building Expressions Type See on screen f(x):x+6[spacebar]*(x^[spacebar]-). The first time you pressed [Spacebar], you selected. [Spacebar].. [Spacebar]. Type See on screen x^[spacebar] +[Spacebar] /5[Enter] + [Spacebar].
Defining Variables :,,, Data... abc,, a, abc,... Type See on screen x: x : abc : : a : abc : :. Type See on screen x:; x :.. x :.. 5 fx ( ) ( x 5) [;]semicolon (.. ) [x ] x. : + 5 x x fx ( ) -5 -.5 :.. Type See on screen x:,.; x :,... Type See on screen x:,.;.8 x :,....8 data:-,-8; data :, 8.. n:,9; n :, 9.. Here the range goes down! x data n -. -8 9
Defining Functions : fx (): a x.. x a. Type f(x):x^ x : See on screen fx ( ) : x fx ( ) f ( ) x : fx () 9. 9 a :.. fa () 9 f(x) x argument. Insert menu -> Function Trig and Logs ln( 6).58 csc( 5 deg) Matrix Functions identity( ) cols( identity( 6) ) 6
Defining Vectors and Matrices vector? Type v:? [Ctrl] m Toolbar Matrix..? rows column v :.? Click on Insert or OK. 8?. Vector : subscript operatorng ( [ ) or Calculator toolbar. < > Type See on screen v[ v. v[ v. v[ range variable Type v 8 See on screen i:; i :.. v[i v i. -. Type See on screen i:;5 i :.. 5 wrong[i: wrong i : wrong wrong T ( ) Mathcad th st. Mathcad.
argumen b : 5 a : fv ( ) : v 9 b v + a v : i :.. fv i ( ) Cross product [Ctrl]8 v w Determinant M Column [Ctrl]6 M. -.i. fx ( ) : x button on the Vector and Matrix toolbar. matrix operator v fv ( ) Operation Keystroke Button Display Dot product [Shift]8 v w M : 6 5 9 8 Purpose Number of columns Number of rows Largest value in matrix Eigenvalues of a matrix Example cols( M) rows( M) max( M) 9 eigenvals( M).56.6.98
Creating and Using Graphs Graph Graph Toolbar Graph X-Y Plot Insert menu, @. [Enter]. sin( d).. 6. 6. Graphing a Function Using Range Variables d fx ( ) : x + 8 x f(x):-x^[spacebar]+8*x- Independent variable x :.. x:; f( x) 6 8 6 6 8 x Graphing Two or More Functions fx ( ) : sin( x) f(x):sin(x) gt (): t g(t):t^ x :, 9.9.. x:-,-9.9; t :,.9.. t:-,-.9;? Type @ in some blank space. f( x) gt () 5 5 x, t? In the middle placeholder on the horizontal axis, type x,t.? In the middle placeholder on the vertical axis, type f(x),g(t).? Type [Enter].
Graphing Vector Elements money_spent : ( 6 8.5 ) T i :.. money_spent i i:; money_spent[i 6 8.6..8 6. 8 Graphing a Function of Vector Elements fx ( ) : x f(x):x^ x : (..56 9.9 ) T index variable i :.. i:; 6 fx ( i ) 8.. 6.8. x i
Array Algebra Vector addition / scalar multiplication: Enter vectors: + v : w : v + 5 i 8 Results: v w 5 6 + i v + w 8 5 + i Negative: Transpose: v T ( 5 ) w 6 i 8 Complex conjugate: w 6 i 8 Dot product: v w.5 + 6i Cross product: v w 5 i 58 + 6i Magnitude: w 88.6 w w 88.5.5i Sum of components: v 6 Enter matrix: M : 5 Transpose: M T 9 6 8 5 Determinant: M 5 Powers: 8 M 6 9 5 65 6 6
Inverse:. M.8.6....8.. M M M M Solve linear system Mx v with inverse: x : M v x.8 6.8.9 M x 5 Enter array: α : v α : M α : w Results: α {,} {,} {,} α 5 α 5 α 6 + i 8
Operations on a Square Matrix Enter a square matrix with real values: M : 8 5 9 9 Maximum and Minimum Values: max( M) 9 min( M) 5 Eigenvectors: eigenvecs( M).95.88..8.85.6.56..66.56..5..98.8.569 Eigenvalues: eigenvals( M).99 8.68.6.98 Joining Matrices This QuickSheet shows how to join matrices together with the stack and augment functions Input matrices: M : 5 6 8 9 A : 9 B : 9 Use stack to place one matrix above another: stack( A, B) 9 9 Use augment to place one matrix beside another: augment( M, A) 5 6 8 9 9
Defining Nested Arrays This QuickSheet illustrates four ways to define nested arrays. Using range variables: m :.. n :.. M m, n : identity( m + ) M, ( ) M, M, Using the Matrix command under the Insert menu: u : v : ( ) V : u v V Defining element by element: B : B : identity( ) B : ( B v) V ( ) B B B ( {,} )
Vectorizing an Expression Input matrices: A : B : 6 5 8 5 6 ( A B) 8 5 8 8 A 9 9 9 A B 6 5 6 9 A B A 9 6 5 5 5 6 6 Array Size and Scope This QuickSheet illustrates how to find information about a matrix or vector. Input matrix: M : 5 6 cols( M) rows( M) Returns number of rows and columns in M min( M) max( M) 6 Returns largest and smallest values in M Input vector: v : 5 length( v) last( v) Number of elements in v Index of last element in v
Solving Quadratics polyroots Quadratic polynomial f(x) ax + bx + c coefficients : a, b, c a : v b : : ( c b a) T c : 8 r : polyroots( v) Roots r fx ( ) : a x + b x + c r r fr ( ) fr ( ) 5 f(x) and Its Real Roots r r 5 5 5 5 Solving an Equation in a Single Unknown Root function. fx ( ) : function f(x) guess value fx ( ) : x + e x x : soln : root( f( x), x)
Solution: soln. Real Solution of f(x) soln Solving a System of Linear Equations n lsolve function : w, x, y, z. w.5 w. 8. w +. x + 6.6 y. z.8 x. x. y + 6.5 z. w + 9. x +.9 y. z. + 8. y + 8.9 z... M :..5. 8...8 9.. 6.6..9 8.. 6.5. 8.9 non-singular matrix corresponding to the n equations in n unknowns:.. v :... soln : lsolve( M, v) soln.9.95.6.95 w x y z
Solving a Nonlinear System of Equations Solve Block n. guess values : n unknowns: x : Given y : z : x y x y + y 5 z + z + z e z vec : Find( x, y, z) Solve Block Given,,,, Find(x,y,,,) Solution: vec..95.68 Solving Each of a Family of Equations fx ( ) g( x, a) fx ( ) : e x gxa (, ) : a x x a x :,.99.. f( x) gx (, ) gx5 (, ) gx (, ) 5 A plot like this helps you guess the value of the (negative) root of the equation. x
root Sax (, ) : root( f( x) g( x, a), x) a a :.. Initial guess: x : ( ) x a : S a, x a Answers: a x a fx a -. -.5 ( ) gx ( a, a) -.? -5 -.? -5 Solve Blocks with Inequality Constraints Intersection of a circle and a line (unconstrained case): Guess values: x : y : Given x + y 6 Circle x + y Line One solution xval yval : Find( x, y) xval. Guess values: x : y : yval. 6 x x 6 x Unconstrained Case x, x Another solution Given x + y 6 x + y
xval yval : Find( x, y) xval.55 yval.55 These are all the solutions, as the plot indicates: x :.5,.9...5 ξ :,.99.. Now introduce an additional constraint of the form x > a, where a is constant. The shaded region below is now eliminated from consideration. a : η :,.6.. a ζ :,.6.. Constrained case (x>a) ξ ζ 6 x 6 x x, x, ξ, η Intersection of a circle and a line (constrained case): Guess values: x : y : Given x + y 6 x + y Circle Line x > a Added constraint xval yval : Find( x, y) xval.56 yval.56
Linear Programming This QuickSheet illustrates the solution of linear programming problems. Problem with Two Variables fx ( ) : x + x Objective function M : v : Constraint coefficients Constraint Set Boundary t t + t Graph of feasible region x : 6 t Initialization Given M x v Solve block x Maximize( f, x) 5 5 Solution Problem with Six Variables fx ( ) : 8 x + x + x + 6 x + x + 9 x 5 Objective function M : 5 9 5 5 8 8 56 9 9 v : 6 5 5 Constraint coefficients
x 5 : Initialization Given M x v x Solve block x Minimize( f, x).6. Solution.8
Handling Data Files Introduction Mathcad ASCII text, Excel, Lotus --, and MATLAB format. data file Mathcad worksheet Import Export. data. Writing to a Data File File Write component : to write data stored in a Mathcad variable data data file.. Insert menu Component.. dialog box File Read Write.. Write to a File.. file format (Formatted Text, Tab Delimited Text, Excel, Lotus --, etc.). path file name. 5. Click Finish. 6. data variable name placeholder tabarray is a tab delimited text file. tabarray.txt xlarray is an Excel file. xlarray.xls i :.. B < > tabarray.txt B B j :....9 j B i, j : i xlarray.xls B B Note: data component right mouse button. Reading from a Data File data file Mathcad File Read component.. Insert menu Component... dialog box File Read Write.
. Read from a File...: (tabarray.txt or xlarray.xls.) 5. Click Finish. 6. data variable name placeholder Read : tabarray.txt cols( Read) 5 a : Read, rows( Read) a. Importing from a Data File data file Link data Input Table component.. Choose Component from the Insert menu.. Choose Input Table and click Finish.. Fill in the placeholder that appears with the variable name to hold the data. For example, type Import. You'll see this: Import : Import. Click on the table, and then click on it with the right mouse button and choose Import from the pop-up menu. 5. Use the dialog to specify the file you want to import. Note: To edit the numbers in an Input Table, just click on the table. To resize the table, click on it and use the sizing handles to drag the borders. Using Functions to Read from and Write to ASCII Data Files ASCII data file, File Read, Write component. WRITEPRN ("output.prn") : B C : READPRN ("output.prn")
Using APPENDPRN APPENDPRN data file data. D : APPENDPRN ("output.prn") : D READPRN ("output.prn")..6
Animating a Graph Creating Animations Mathcad plot. Animation FRAME Animating the Graph. View menu Animate. animate.... dialog box Animate animation.. 5..avi drag.. hyperlink. Animation Setup fx ( ) FRAME : x x :,.99.. The graph is plotted below with FRAME. This will be a parabola that gets steeper as FRAME increases. FRAME is divided by to make the changes more gradual. f( x) 5.5.5 x ( ) fx ( ) : sin FRAME πx FRAME a : FRAME f( x)...6.8 ( ) fx ( ) : sin a πx x a
Using the Excel Component Component Excel "Creat empty excel worksheet" "from file" "Display as icon" Input Output : The Excel spreadsheet shown below contains annual totals of sunspots from to 995. Input Table component. Table 95 Data : 5 Data T.?.?.?.?.? Data T 5 6 8 9 5 6 6 58 9 8 year count : excel component year count: Data : ( Data Data ) Annual Sunspot Count count 5 8 85 9 95 year
Using the SmartSketch Component : Mathcad SmartSketch CAD drawing Link Mathcad Link CAD drawing drawing. ang : 5deg 9 5 excel component ang Mathcad SmartSketch LE CAD drawing. Click.
Developing MathML Web Sites Mathcad on-line file MathML. MathML WEB World Wide Web Consortium XML. MathML/HTML Browser. : Netscape. or greater, or IE 5. or greater, and the IBM techexplorer TM plugin or Active-X component. Creating a MathML Web Site Step : Creating Mathcad Files: Writing with Mathcad Steps and. Add Hyperlinks and Prepare a Table of Contents Step : Prepare a template file Step 5: Set your HTML Output Preferences View Preferences : MathML out-put PNG : is a lossless format so may result in clearer images for graphs and drawings JPEG : smaller or compatible with older browser versions. Object data : external data files (.dat) Inline data : file size online.. Note : graphs, data tables MathML HTML. object data Mathcad. Step 6: Choose File Save As