Mathca Lecture #5 In-class Worksheet Plotting an Calculus At the en of this lecture, you shoul be able to: graph expressions, functions, an matrices of ata format graphs with titles, legens, log scales, lines, an axis labels fin the roots of an expression by tracing perform ifferential an integral calculus numerically perform ifferential an integral calculus symbolically solve engineering problems involving calculus 1. Plotting Basics A. Syntax D plots can be inserte using by: typing the @ symbol using the graph icon on the Math/Graph tool palette The black boxes represent placeholers. Must fill in the center boxes on each axis; these are the inepenent variable (x-axis) an the function (y-axis) Can fill in boxes at extrema of each axis; these are the bouns B. Demonstration of plotting expression. Changing the Bouns 1. clicking on the graph causes the boun to appear at the extrema of each axis. the boun are surroune by small half brackets 3. the first time you begin typing on a clicke boun, the previous contents will isappear 4. if you want to change the boun again, you will have to first elete the previous boun an then type the new boun. You can change a variety of plot properties by ouble clicking on the graph. Note: emonstrate how to a a caption an change the color an weight of the line.
C. Practice Plot n 3 vs n Plot ln(α) vs α. 1. Notice that the inepenent variable has not been efine previously. By efault, if the inepenent variable is not efine, Mathca uses -10 to 10. If the function is not efine on this interval, Mathca plots only the regions where the function is efine.. You can efine your own value of the inepenent variable by using a range variable (iscusse last lecture). See the example below z 019 0 600 z 400 00 0 0 0 0 z
D. Demonstration of plotting vector of ata. Explanation: We often want to graph iscrete points of measure ata. This is one by placing the a in a vector. The vectors must be the same size. 1 i 0 3 x y x 3 i i 4 y 1 4 9 16 1. In general, when you are plotting iscrete points such as those obtaine from irect experimental ata, you o not use a line.. A line is usually use if the graph is mae from a function, a correlation, or a fit to the ata. 3. A line may be use to connect points, but it shoul be note that is is only there to guie the eye. In such cases, you shoul use straight lines to connect the points. D. Demonstration of multiple plots on the same graph. Explanation: Sometimes, we want to inclue more than one set of ata on the same graph. This is one by separating the arguments with a comma. (Typing the comma key give you a new place holer to the right of or below the previous argument.) 1. Notice that each x argument is matche to a y argument.. You can plot multiple expressions using the same inepenent variable if esire; however, type of each argument must match. 3. You cannot match an expression (on the y axix) with a matrix of ata (on the x axis) when plotting. (see below.)
E. Demonstration of plotting user-efine functions. You can also plot user efine functions. f( b) b F. Practice The vapor pressure of acetone is escribe well by the following expression, P sat B ( T ) expa C ln( T ) DT T where A = 69.006, B = -5599.6, C = -7.0985, an D = 6.37E-6. The temperature must be evaluate in Kelvin an the pressure returne is in Pascal. Experimental ata for the vapor pressure of acetone is available in variable foun to the right. On a graph, plot both the experimental vapor pressure an that obtaine from the correlation above. A 69.006 B 5599.6 C 7.0985 D 6.3710 6 B Psat( t) exp A Cln t D t t K K K Pa T expr VP 0 K P expr VP 1 K VP 0 1 3 4 5 6 7 8 0 1 59.18 4.67 103 65.04 6.005 103 71.76 8.691 103 75.1 1.038 104 78.64 1.4 104 8.3 1.484 104 85.6 1.748 104 93.87.554 104 30.43 3.691 104 9 311.75... Notice that when I first try to create the plot, I on't get anything. This is because I nee to change the bouns. Looking at the ata, the temperature range shoul be from about 50 to 50 K. Changing the bouns to this fixes the problem.
1. Notice that you can place the y-axis on a log scale by ouble clicking on the graph an checking the appropriate box.. Notice How you can the units on the graph by iviing the y arguments by the esire units. Troubleshooting Tips/Don't Forget This Beginners in Mathca often have trouble graphing. Keep in min the following. 1.. 3. 4. Many of the problems with graphing can be solve by typing the correct bouns, even if you think they are correct to begin with. Sometimes the problem is that you are using an inepenent variable that has been efine previously. Try changing the variable name to something ifferent. Make sure that the argument type matches. Make sure the units are correct. The units of each y-axis argument must be the same.. Plotting to help you solve for roots of an equation. Engineers solve equations everyay. One of the first things you shoul always o when trying to fin the roots of an expression is to create a plot. This will tell you how many real roots the solution has as well as give you a goo iea of where they are. Demonstration For y = q 6 3q 5 5q 4 q 3q 1 plot y vs q. How many real roots are present? yq ( ) q 6 3q 5 5q 4 q 3q 1
1.510 6 110 6 yq ( ) 510 5 0 510 10 5 0 5 10 q Try changing the bouns to make sure you get all the roots. 3. Differential Calculus 1. Since the roots of the equation are when the function equals zero, make the y-axis close to zero.. Zooming in reveals roots you can't initially see. 3. You can place a "marker" (or straight line) by ouble clicking on the graph, checking "Show markers", clicking OK, an then filling in the place holer that has appeare. 4. The Trace utility, on the Graph tool palette, is useful to etermine precise values for roots. (you must click on a graph to enable the Trace button.) Differential Calculus is fairly simple using Mathca. The functions are foun on the Calculus tool palette. A. Demonstration of operator syntax First Orer x x3 x f( x) Higher Orer xx x3 or x 3 x Note, you can remove the ()'s the Mathca as between the erivative operators. Mixe Derivatives x y x y x y x3 y or x x y x3 y
B. Numerical Evaluation of Derivatives Explanation To etermine the numerical value of the erivative at some point, efine the value of the inepenent variable, type the erivative, an then type =. Demo Fin the value of the erivative of x x 3 when x = 1. f ( x) x x 3 1 f( ) 4 p 1 p p p 3 4 Practice: Fin the value of the fourth erivative of [ sin(3x) + 4 cos(5x)] when x = 15 f ( x) sin( 3x) 4cos( 5x) x 15eg Practice: Fin the cross erivative /xy of x 3 3x y 3x y y 3 at x = 1 an y = 1. f ( xy ) x 3 3x y 3x y y 3 x 1 y 1 C. Symbolic Evaluation of Derivatives Explanation: There are three ways to get a symbolic erivative 1. Use the arrow on the symbolic tool palette. Evaluate/Symbollically (on the Symbolics pullown menu) 3. Variable/Differentiate (on the Symbolics pullown menu) Demo Metho 1: the Symbolic toolbar x x x 3 4 f ( x) x x 3 x f( x) 4 Not what you want. Remember that the tool palette honors all previous calculations.
Demo Metho, the Symbolics/Evaluate/Symbolically x 1 x x x 3 4 x x x 3 4 Not what you want. Remember that the tool palette honors all previous calculations. x x x 3 yiels x Demo Metho 3, the Symbolics/Variable/Differentiate x 1 x x 3 by ifferentiation, yiels x Note: to use this metho remember to only select the variable by which you want to ifferentiate. 1. Remember, there is a slight ifference between using the Tool Palette an using the pull own menu. The Tool Palette honors all previous calculations an will re-evaluate every time you change something in the worksheet. 3. The Pull own menu ignores any previously-efine variables/functions an oes the calculation once. 4. Remember to select the entire expression when using metho. 5. Remember to select only the variable of integration when using metho 3. Practice: Fin the cross erivative, /xy of x 3 3x y 3x y y 3 x y x3 3x y 3x y y 3 3. Integral Calculus Integral calculus is straightforwar in Mathca. The symbols for both efinite an inefinite integrals are foun on the calculus tool palette. A. Demonstration: Numerical Evaluation of Definite Integrals Integrate -4x + 3x + 1 from -1 to. 1 4x 3x 1 x 8.5
f () s 4s 3s 1 f() t t 8.5 1 1. The variable of integration is a ummy variable. It oesn't matter what you call it an it oesn't have to be the same name as when the function is efine.. Mathca can o units in integrals. Integrating with units: In engineering, we often have to integrate the heat capacity from one temperature to another to etermine the heat require for a particular process. Mathca can o the integration with the units inclue. Cp( T) 10 5 T K J molk T 1 300K T 400K T q Cp() t t 1.76 10 5 J T mol 1 B. Multiple Integrals The most ifficult thing about multiple integrals is etermining which bouns correspon to which variable of integration. For example, if I neee to o a triple integral, an I place three integral symbols in Mathca, it woul look like this. It is often ifficult to remember if you fill in the integral signs from the insie out or from left to right. To make sure that you on't make a mistake, the best way to o this is place one integral sign, fill it in, an then procee to the next. For example, if I have a function x +y +z that I must integrate with 0 < x < 1, -4 < y < 10, an - < z < 5, I woul procee using the following steps.
Practice the example given above. C. Symbolic Integrals Explanation: As with ifferentiation, there are three ways to calculate a symbolic integral 1. Use the arrow on the symbolic tool palette. Evaluate/ Symbolically (on the Symbolics pullown menu) 3. Variable/Integrate (on the Symbolics pullown menu) Inefinite Integrals Symbolically integrate xlnx ( ) Demo Metho 1: the Symbolic toolbar x 1 sin( x) Notice that x is alreay efine so I have to change the variable of integration. blnb ( ) sin( b) b Demo Metho, the Symbolics/Evaluate/Symbolically xlnx ( ) sin( x) x Demo Metho 3, the Symbolics/Variable/Differentiate xlnx ( ) sin( x) by integration, yiels 1. Remember that metho 1 honors all previous calculations.. Remember to select the entire expression when using metho. 3. Notice that no integral sign is neee for metho 3. Definite Integrals You can symbolically evaluate efinite integrals b a 4x 3x 1 x 4a 3 3 3a 1a 4b 3 3 3b 1b