An introduction to numerical methods using mathcad pdf
Wherever appropriate, the use of Mathcad functions offering shortcuts and alternatives to otherwise long and tedious numerical solutions is also demonstrated. It provides excellent coverage of numerical methods while simultaneously demonstrating the general applicability of MATLAB to problem solving. This textbook also provides a reliable source of reference material to practicing engineers, scientists, and students in other junior and senior-level courses where MATLAB can be effectively utilized as a software tool in problem solving.
The principal goal of this book is to furnish the background needed to generate numerical solutions to a variety of problems. Specific applications involving root-finding, interpolation, curve-fitting, matrices, derivatives, integrals and differential equations are discussed and the broad applicability of MATLAB demonstrated.
This book employs MATLAB as the software and programming environment and provides the user with powerful tools in the solution of numerical problems. Wherever appropriate, the use of MATLAB functions offering shortcuts and alternatives to otherwise long and tedious numerical solutions is also demonstrated.
At the end of every chapter a set of problems is included covering the material presented. To access Mathcad's built-in functions, go to the Insert menu as shown in Figure 1. Use the Arithmetic Palette See Figure 1. The basic 2. This will evaluate any function of z for z values from zero to 1 in increments of 0. The array of computational and formatting capabilities available can be seen by clicking on each of the menus. The Math Toolbar This is below the main menu.
It opens up palettes of math operators as described below. The Standard Toolbar This provides shortcuts for many common tasks from opening and saving files, cutting and deleting to spell checking and bringing up lists of built-in functions and units. Hover over each button to see tooltips with a brief description. The Formatting Toolbar This formats your text and math at the click of a button.
The Resources Window and E- books If you seek examples, want information that can be utilized in your Mathcad worksheets or wish to access web information from within Mathcad, go to the Help menu, and then open Tutorials, QuickSheets , Reference Tables or E-books. Tutorials includes Getting Started Primers, Migration Guide and Features In-Depth, while Quicksheets are live examples showing the use of Mathcad functions, graphs and programming features.
Information on physical constants, chemical and physical data and mathematical formulas in Mathcad format can be found in Reference tables. Mathcad E-books can be accessed by opening E-books. These E-books have the advantage that all equations are live in them and you can change the values of variables, constants etc.
Chapter 1: Basics of Mathcad 15 Controlling Calculation and The Status Line The calculation mode, whether manual or automatic, is a property saved in your worksheet and template files. Mathcad starts in the automatic mode and all calculations and results are updated automatically. The word " Auto " can be seen in the message line at the bottom of the Mathcad window. This line provides status alerts, tips, keyboard shortcuts, and other helpful information along with the calculation status of the worksheet.
Here, "auto" refers to the automatic mode , in which Mathcad automatically recalculates any math expressions when changes in the worksheet are made. When "WAIT" appears on the status line, the cursor changes to a flashing lightbulb, indicating that Mathcad is still completing computations.
Besides giving the page number of the current worksheet, the message line will also indicate whether the Caps Lock or the Num Lock key is depressed on your keyboard. In manual mode, Mathcad does not compute or show results until recalculation is specifically requested.
However, while in manual mode, Mathcad does keep track of pending computations. Once a change is made that requires recalculation, the word " Calc " appears on the status line to indicate to the user that the results being displayed are not correct and that recalculation is necessary to ensure accuracy. The screen can then be updated by going to the Tools menu and choosing Calculate and then Calculate Now.
To force Mathcad to recalculate all equations in the worksheet, go to the Tools menu and choose Calculate and then Calculate Worksheet. A region can be selected by clicking in math or text in your worksheet, after which it is indicated by a thin rectangle around it.
Moving the cursor to one of the edges of the region, will change it to a small hand with which the region can be moved to anywhere in the worksheet. While clicking in the math region will bring blue selecting lines under the material selected, clicking in a text region will bring black boxes to each corner and the middle of each line. With these boxes text regions can be resized as needed. To add a border around a region or regions, select the region s , then right-click and choose Properties from the menu.
Then click on the Display tab and check the box next to " Show Border ". Now, use the mouse to move the region as necessary by holding down the left mouse button and dragging it. Once the regions are positioned in the desired manner, the mouse button may be released. Then, an empty part of the screen may be clicked on to deselect the regions.
Alternatively, choose Regions from the View menu, which will highlight the boundaries of the region against a contrasting background. Cut and Paste can also be used to move regions. Once regions are inserted in the worksheet, they can be aligned horizontally or vertically by going to the Format menu and choosing Align Regions. Copying and Pasting Selected Regions Selected regions can also be copied and put into any place within a document or into another document by choosing the Copy and Paste commands from the Edit menu.
The little black box delimited by blue editing lines that you see is called a placeholder. Continue typing. Then choose Text Region from the Insert menu or type the double quote ". The crosshair transforms to an insertion point with a black text box around it. Several predefined templates are available each with a variety of styles, and if necessary, new templates can also be created.
Any Mathcad worksheet can be saved as a new template. In the placeholders, substitute your own text or bitmaps in any of the placeholders, or use the built-in styles. You can also revise them if needed. When you create a worksheet based on a template, all of the formatting information, and any math, text and image regions are copied into the new worksheet. By creating a new template or revising another template , a customized format can be generated.
Text styles and number formats can be created, number formats, fonts and sizes can be set, bitmaps can be added , and also, page numbers, filenames and dates can be inserted. Thus, by using templates, you maintain consistency across multiple worksheets through definition of math styles, text styles, printing margins, numerical result formats, units etc. To save a template, choose Save As from the File menu and use the file extension.
The settings, styles and bitmaps saved will be available for the next file you may want to create, leading to greater consistency in your files. Using Styles The use of Text Styles allows you to create a consistent appearance in your worksheets. Styles in each template are available by choosing Style from the Format menu. Any specific style with a defined font, size, etc. To create or modify a style, again choose Style from the Format menu. To save your styles for use in new files, you must make a template file.
Math Styles can be used to assign specific fonts, font sizes etc. There are predefined ones but additional styles can be defined and applied. This can be accomplished by going to the Format menu and choosing Equation. Such a number is termed a variable. Let Apples be, then, a variable. To do this, select Function from the Insert menu, or click on the function button on the toolbar The Insert Function dialog box, shown below, will allow insertion of a function name directly into the placeholder Built-in functions can also be inserted directly from the keyboard.
The following examples will illustrate the process. This stickiness applies to exponents, square roots, subscripts, and division. Most problems dealing with editing equations stem from working with operators. Although Mathcad automatically inserts parentheses wherever necessary, the Mathcad user must put in parentheses himself in accordance with his own judgement to give clarity to expressions. When expressions become complicated, it is definitely preferable to work with smaller and more manageable subexpressions within them.
This can be accessed by choosing Tutorials from the Help menu. The following will provide a range of x values going from 2 to 4 with increments of 0. Chapter 1: Basics of Mathcad 25 Figure 1. Then, fill in the appropriate number of rows and columns, click on Insert and finally fill in the placeholders with given values. In Mathcad , by default the first element has the index 0. Define a function f x as. These are listed below. There is also a wide range of built-in functions in Mathcad that return information about the size of an array and its elements.
For a given matrix [M], various pieces of information can be generated as shown below. Press [Enter] and fill in the placeholders on the x and y axes. If this range is not prescibed by you, Mathcad will choose a default range for the dependent variable. Type to create the x-y plot, type x in the middle placeholder on the horizontal axis and type f x in the middle placeholder on the vertical axis.
Press [Enter]. The following graph should then appear on the screen. The smaller step enables Mathcad to calculate more points.
This will make the plot a lot smoother see graph below because now there are more points or dots being connected together.
Formatting of an x-y plot can be accomplished as follows. Double-click on it or choose Graph from the Format menu to open up a dialog box.
This dialog box will allow several options in terms of grid lines, legends, trace types, markers, colors, axis limits etc. This vector which will have 7 rows and 1 column can be created using the Matrix command on the Insert menu. The resulting plot should be 95 90 Tempi 85 80 75 0 2 4 6 i Notice here that box symbols have been used on a dashed line.
Alternatively, two vectors of equal size can be plotted against each other. Plotting a Function of Vector Elements Sometimes, a function may need to be plotted over points that are not evenly spaced.
In order to do this, x has to be defined as a vector of the given numbers in the prescribed range. This can be done using the Matrices dialog box with the placeholders properly filled in as shown. For example, the following should illustrate how the two functions sin x and cos 2x can be plotted on the same graph.
Formatting Text Using the drop-down lists in the Format Bar, different fonts as well as point sizes can be selected. Appropriate buttons must be clicked to generate special effects like boldface, italics, etc.
Several options become available upon choosing Text from the Format menu. See Figure 1. Text Styles and Templates Text styles provide consistency in the appearance of worksheets and enable the application of text formatting to the text regions. Available text styles depend on the template used to create a worksheet.
To examine the different templates and text styles provided in Mathcad, choose New from the File menu and modify them or create new ones. Formatting Math In Mathcad different font tags can be applied to variables and to constants. To make changes in the font, click on a variable or constant in a math region and use the Format Bar. Alternatively, you can choose Equation from the Format menu.
Highlighting of equations can also be done in Mathcad. Below is shown an example of a highlighted equation. Also, fonts and their sizes can be controlled and highlighting of equations can be done as desired. In the Number Format dialog box that shows up, change the Exponential Threshold , and Number of decimal places as necessary and click on OK. This will set the format only for this particular result.
However, if this needs to be done for the entire worksheet, click on a blank part of the worksheet, and do the above.
Chapter 1: Basics of Mathcad 37 Figure 1. Under the " Legend label " column, type the desired name of the trace. Symbols, line types, colors, trace types, etc. Finally, preview the changes and click OK to finalize them.
An example is shown at the end of this section. The program will also flag incorrect and inconsistent dimensional calculations, and mixing and matching of units can be done as desired. The default system in Mathcad is the SI unit system To define a variable in terms of the built-in unit kilometers , for example, just multiply the given number by km. To change this result to feet , for example, click in the name of the unit that you want to replace, then drag-select it and type in the new desired unit in its place.
Finally click outside the equation to see the new result. The following equivalents can be easily generated using the procedures described above. Then, click the Unit System tab, and select U. This option gives you results in "English System" measures. In the following calculation, a mass is multiplied by an acceleration to give force in proper units.
The result should be in Newtons or an equivalent force unit. Then, go to Unit Display and check Format Units and Simplify units when possible, and results will display as shown below. Because real world problems are generally quite complex with the generation of closed-form analytical solutions becoming impossible in many situations, there exists, most definitely, a need for the proper utilization of computer-based techniques in the solution of practical problems.
The advancement of computer technology has made the effective use of numerical methods and computer-based techniques very feasible, and thus, solutions can now be obtained much faster than ever before and with much better than acceptable accuracy. However, there are advantages as well as disadvantages associated with any numerical procedure that is resorted to , and these must be kept in mind when using it. A disadvantage associated with analytical solution techniques is that they are generally applicable only to very special cases of problems.
Numerical solutions, on the contrary, will solve complex situations as well. While numerical techniques have several advantages including easy programming on a computer and the convenience with which they handle complex problems, the initial estimate of the solution along with the many number of iterations that are sometimes required to generate a solution can be looked upon as disadvantages. These include inaccurate mathematical modeling, wrong programming, wrong input, rounding off of numbers and truncation of an infinite series.
Round-off error is the general name given to inaccuracies that affect the calculation scene when a finite number of digits are assigned to represent an actual number. In a long sequence of calculations, this round-off error can accumulate, then propagate through the process of calculation and finally grow very rapidly to a significant number. A truncation error results when an infinite series is approximated by a finite number of terms, and, typically, upper bounds are placed on the size of this error.
The true error is defined as the difference between the computed value and the true value of a number. The order of approximation is defined by the highest derivative included in the series. For example, If only terms up to the second derivative are retained in the series, the result is a second order approximation.
Thus , the fewer the terms that are included in the series, the larger will be the error associated with the computation of the function value. If the function is linear , however, only terms up to the first derivative term need to be included. Example 2. These are given in Tables 2. Table 2. Using Mathcad, generate plots of the various Taylor series approximations and associated errors as functions of the independent variable x.
Compare the various Taylor series approximations obtained with true values in a table. Generate plots of the approximations and associated errors as functions of x. Compare the true value of f 2. Compare these with the exact solution. Calculate errors abnd generate calculations to three decimal places. Generate answers correct to four decimal places. Compare these with the exact solution by computing percentage errors.
Compare your answer with the true value. Nonlinear equations have no closed-form solutions except in some very special cases, and thus, computer methods are indispensable in their solution. In this chapter, however, only the Bisection, False Position, Newton-Raphson, Secant and Successive Iteration methods will be addressed along with the functions used in Mathcad to find roots. The method involves investigating a given range to seek a root and then bisecting the region successively until a root is found.
Procedure for Finding Roots 1. Choose starting and end points xstart and xend 2. Compute: f xstart and f xend 3. If the above product is negative, then the root lies between xstart and xend. If this product is positive, reselect xstart and xend.
Call it "xmid1" and repeat above steps, i. Repeat the above procedure until convergence at a root value occurs. Figure 3. Bisection Method Computation of Error and Convergence Criterion A convergence criterion has to be followed in order to determine if a root has indeed been found. Advantages and Disadvantages of Bisection While Bisection is a simple, robust technique for finding one root in a given interval, when the root is known to exist and it works even for non-analytic functions, its convergence process is generally slow, making it a somewhat inefficient procedure.
Sometimes, a singularity may be identified as if it were a root, since the method does not distinguish between roots and singularities, at which the function would go to infinity. Therefore, as the method proceeds, a check must be made to see if the absolute value of [f xend -f xstart ], in fact, converges to zero.
If this quantity diverges, the method is chasing a singularity rather than a root. When there are multiple roots, Bisection is not a desirable technique to use, since the function may not change signs at points on either side of the roots. Therefore, a graph of the function must first be drawn before proceeding to do the calculations. Example 3. In an attempt to minimize the number of iterations needed, we will obtain a root value that is correct only to two decimal places, in this case.
Thus the new xstart is 17 and the new xend is Thus the new xstart is The main difference is that while the interval size in the Bisection method is reduced by bisecting it in each step of the iteration , this reduction of interval size is achieved by a linear interpolation fitting the two end points. While the Bisection method is reliable, it is slower than the False Position method in achieving convergence.
Regula Falsi method The procedure for finding roots then is as follows. See Figure 3. Choose the starting and ending points xstart and xend as in the Bisection method. Compute f xstart and f xend. Make sure that f xstart times f xend is still a negative product. If it is not, then there is no root between xstart and xend. Repeat the above procedure until convergence takes place.
This is called stagnation of an end point. This is not desirable since it slows down the convergence process especially when the initial interval is very large or when the function is highly nonlinear. Examples 3. The starting and ending points were 16 and 20 respectively. Thus the new xstart is 16 and the new xend is Thus the new xstart is 1. Thus the new xstart is 3. Thus the new xstart is 4.
Thus the new xstart is 5. In this method, an initial approximation of the root must be assumed, and calculations are started with a "good initial guess". If this initial guess is not a good one, then divergence may occur. From Figure 3. Newton-Raphson method Procedure for Finding Roots 1. Make a good initial guess. Call it X Old. Keep improving the guess using Equation 3. Solution is done when a new improved value X New is almost equal to the previous value X Old Advantages and Disadvantages of the Method While the Newton-Raphson method is faster than the Bisection method, is applicable to the complex domain as well and can be extended to simultaneous nonlinear equations, it may not converge in some situations.
The solution may oscillate about a local maximum or minimum, and if an initial estimate is chosen such that the derivative becomes zero at some point in the iteration process, then a division by zero takes place and convergence will never occur. Although convergence will occur quite rapidly if the initial estimate is sufficiently close to the root, it is possible for it to be be slow when it is far from the root.
Also, if the roots are complex, they will never be generated with real initial guesses. A worthwhile feature of the Newton-Raphson method is that the numerical process will correct itself automatically for minor errors.
Thus, any errors that are made in computing the next guess will simply generate a different point for drawing the tangent line and will not have any effect on the final answer. Convergence Criterion for the Newton-Raphson Method It can be mathematically shown that in order for the Newton-Raphson method to converge to a real root, the absolute value of the derivative of the g xi of Equation 3.
However, in some cases, it may not hold for the initial guess. Start with an initial estimate of 2. Let us start with an initial estimate of However, there is no need to do this every time, since a complex root will always have a complex conjugate associated with it. Here, both f z and z are to be scalar quantities. The procedure to be used will be clear from the following example.
Let us find the root of the function in Example 3. It does not require a guess value. By choosing "matrix" from the "insert" menu, type in a vector "v " as shown , beginning with the constant term, making sure that you insert all coefficients even if they are zero.
Then, polyroots v returns all roots at once. The following steps will find the root of the polynomial of Example 3. Include all coefficients, even zeros. The one difference is that while the derivative fprime x is evaluated analytically in the Newton-Raphson method, it is determined numerically in the Secant method. Secant method By the Newton-Raphson method, a new improved guess of the root is generated using Equation 3.
However, two initial estimates x i-1 and x i of the solution will be required to start the iteration process as can be seen from Equation 3. Make initial estimates x 0 and x 1. Continue obtaining improved estimates x 3 , x Among the disadvantages are convergence to an unintended root at times, and divergence from the root if the initial guesses are bad.
Also, if f x is far from linear near the root, the iterations may start to yield points far away from the actual root. We first draw a graph of the given function to see approximately where a real root lies in the range given. To type a subscript, use the left bracket " [ "and put an integer in the placeholder.
Vector elements in Mathcad are ordinarily numbered starting with the first element numbered as the zeroth element. A look at the Secant Method suggests that this feature relates well with its recursive formula. Put in "N" as the expected number of iterations.
Then i goes from 1 to N. To find the required root, begin with the initial estimates x 0 and x 1 and use the recursive formula of the Secant Method to obtain improved estimates. Continue until convergence to a solution takes place. Clearly, the other complex root will be the complex conjugate -3 - 2i.
Resorting to the polyroots function will confirm the roots generated above. Applications of this technique can be found in the use of the Newton-Raphson method and the Secant method.
Another name for this method is Fixed Point Iteration. To insure convergence of the iteration, the function selected must be such that the absolute value of its slope is always less than unity. Otherwise, divergence will occur. Determine the negative root by the method of successive substitution. Using the above recursive relationship, we find revised values of x until convergence occurs as shown below. These roots are difficult to compute by the methods discussed in this chapter for the following reasons.
In the case of the Bisection method, the function does not change sign at the root. In the case of Newton-Raphson and Secant methods, the derivative at the multiple root is zero.
Case of multiple roots Because the Newton-Raphson and Secant methods in their orginal forms are methods that resort to linear convergence, they cannot be employed to generate multiple roots. The following modification to the original Newton-Raphson equation has been suggested [ 4 ]. However, this may not be a very practical route since it assumes prior knowledge about the multiplicity of a root.
Substitution of Equation 3. To determine the single root, the above approach can still be employed, but with a different starting estimate, as shown below. The following steps will now demonstrate the application of the modified Secant Method formula, which is Equation 3. In certain situations, it may be necessary to solve nonlinear equations in two or more variables. In these cases, iteration can be resorted to as presented in the following example. Thus, the computations must be repeated with equations set up in a different format as shown below.
Iteration This example illustrates a very serious disadvantage associated with the successive substitution method which is the dependence of convergence on the format in which the equations are put and utilized in the iteration process. Also , even in situations where a converged solution can be attained, initial estimates that are fairly close to the true solution must be resorted to, because, otherwise, divergence may occur and a solution may never be obtained.
The results of the iterative process are summarized in the following table. The procedure is as follows: 1. Provide initial guesses for all unknowns. These initial guesses give Mathcad a place to start searching for the solution. Type the word Given. This tells Mathcad that what follows is a system of equations. Given can be typed in any combination of upper and lower case letters, and in any font. However, it should not be typed in a text region.
Then type the equations and inequalities in any order below the word Given. You can of course separate the left and right sides of an inequality with the appropriate symbol.
Chapter 3: Roots of Equations 87 Example 3. Using the Given and Find functions, solve 2 2 1. The maximum load that the column can carry with a factor of safety of 2.
Thus, it must be solved iteratively using trial and error. How this can be accomplished with Mathcad is demonstrated below. Natural Frequencies of Vibration of a Uniform Beam For a uniform beam that is clamped at one end and free at the other, a shown in Figure 3. For a beam with a length of 20 feet, an EI value of 16 x 10 6 lb-in 2 , and a weight per unit length of 0. Some of these are listed below. Third natural frequency: Solving the Characteristic Equation in Control Systems Engineering A characteristic equation is an algebraic equation that is formulated from the differential equation or equations of a control system [14].
Its solution, which often requires evaluation of the roots of a polynomial of degree higher than two, is crucial in determining system stability and assessing system transient response in terms of its time constant, natural frequencies , damping qualities etc.
An application involving the use of Mathcad' s polyroots function in determining the roots of a characteristic polynomial of a control system is presented below. For varying values of this parameter, the roots of the characteristic polynomial can be evaluated as shown below, and the system transient response and stability studied , following which, an appropriate range for K may be recommended.
Horizontal Tension in a Uniform Cable Flexible cables are often used in suspension bridges, transmission lines, telephone lines , mooring lines and many other applications. Plot of g H The use of the Secant method in obtaining the required root is shown below. This is done below. Label it and give it a title. Verify your answer by using the root function.
Also obtain all the roots of the polynomial with the polyroots function. Generate an answer that is good to three decimal places. Obtain all roots of the following polynomial lying in the range Verify your answers by using the root function.
Obtain an answer that is correct to at least three decimal places. Obtain an answer that is correct to three decimal places. Obtain an answer that is correct to four decimal places. Obtain all roots of the following polynomial lying in the range 0 to 1. Obtain all roots of the following polynomial lying in the range 0. Start with initial estimates of 1. Start with initial estimates of 4. Generate an answer that is correct to four decimal places. Generate an answer that is correct to three decimal places.
Generate an answer that is correct to threer decimal places. Notice what this plot suggests in terms of the interval where the roots may lie. Then, draw a second graph for a narrower range Start with an initial estimate of 0.
Start with a reasonable initial estimate. Obtain the solution of the following system of nonlinear equations by iteration x 1. Verify your answers with the Given and Find functions. Using the Given and Find functions of Mathcad, obtain the solution to the following system of equations. Using a range of damping ratios from 0. Determine the first three natural frequencies of a 36 in. E for steel is 30 x 10 6 psi. Determination of the inverse of a matrix is linked with the concepts of transpose, minor, cofactor and adjoint.
Addition and Subtraction: Two matrices with the same number of rows and columns can be added by adding the corresponding terms. Example 4. How to perform matrix operations will be clear from the following examples. Figure 4. Note that, in this case, subscripts will go from 0 to 2.
For Example 4. Formulate a set of linear equations that represent the relationship between voltage, current and resistances for the circuit shown in Figure 4. Some examples of eigenvalue problems are given below. Determination of natural frequencies and mode shapes of oscillating systems. Computation of principal stresses and principal directions 3. Computation of principal moments of inertia and principal axes. Buckling of structures. A principal goal of this book is to furnish the background needed to create Mathcad documents for the generation of solutions to a variety of problems.
This book, which is designed to be used in a first course in numerical methods in a computer science, mathematics, Mathcad offers the effective built - in functions for integration of stiff equations , but the Mathcad HELP function Using Mathcad , the main topic is the numerical solution of two - point boundary - value problems for the ordinary This comprehensive book illustrates how MathCAD can be used to solve many mathematical tasks, and provides the mathematical background to the MathCAD package.
But , with Mathcad , even this analytical solution is easy to perform. AL Physical Chemistry is the first course in the Chemistry curriculum that uses numerical methods to When using Mathcad , the user must make this conversion from superior to first order equation.
0コメント