### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# ComputationLaboratoryII CS122

Drexel

GPA 3.88

### View Full Document

## 25

## 0

## Popular in Course

## Popular in ComputerScienence

This 17 page Class Notes was uploaded by Vito Kilback on Wednesday September 23, 2015. The Class Notes belongs to CS122 at Drexel University taught by Staff in Fall. Since its upload, it has received 25 views. For similar materials see /class/212476/cs122-drexel-university in ComputerScienence at Drexel University.

## Reviews for ComputationLaboratoryII

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/23/15

V Chapter 9 More Mathematical computation l 7 Section 91 Solving multiple equations andor inequalities Maple can solve systems of equations by giving solve a set of equations and a set of variables One can also enter inequalities instead of equations fsolve can handle systems of equations but it does not handle inequalities Maple39s quotfirmestquot solution power comes from the exact solution of systems of linear equations The solution if one exists will be described in full If NULL is returned as the answer from solve it means that no solution exists Exact solution of inequalities may not be successful even if there is a solution That is if Maple returns NULL in this situation it does not necessarily mean that there is no solution it may only mean that Maple couldn39t find any solutions If Maple finds an approximate solution to a system of equations it does not necessarily mean that a solution exists just that the approximation technique which are not infallible thinks that it39s found one Even if a solution exists to a system an approximate solution may or may not be close to the exact solution due to accumulated rounding errors resulting from the use of oating point limited precision numbers This limitation exists in most systems eg Matlab Fortran or C packages that use oating point arithmetic to solve systems of equations Example 811 solve and fsolve with systems of equalities or inequalities Example Commentary solve 3xy5 4 y 7x xy w l e 4 4 fsolve339x y5 4 y7x x y x 02500000000 y 5750000000112 solve x y3 xy4 36 301M x yfy 96 x yl xR00t0fffZ Zy fR00t0f ffZ Z 5y 113 To solve a system of equations give solve a set of equations and a set of variables The result can be a set of equations solve returns NULL if it can39t any solution Maple may return expressions involving more advanced mathematics in some cases If you get back an answer that you don39t comprehend it39s a sign that either you39ve asked the wrong problem by mistake or that you39re going to have to get more help in understanding the situation solve Tcr2 10 r gt 0 r We are interested in finding the radius of a eval27r 114 25W at 5 digits gt 11210 114 115 116 circle whose area is 10 In order to discard negative roots of the quadratic equation we put in the additional inequality that r is positive We get a set back as the answer We can use the result from solve as is to figure out the circumference of the specified circle both exactly and as a five digit approximation solvexygt 5x y lt3 xy x34 x5 lty 4 ltxx 3 lty fsolvexy gt 5x y lt 3 xy Error Got internal error in TypesettingParse MilnertiDELAYLESSTlIAN is not a valid inert form 117 Efsovexygt5 X ylt3 X r 1 solve can handle systems of inequalities Here the solution is described as a sequence of two different sets fsolve can39t handle inequalities Inequalities aren39t that easily handled through approximate calculations because it39s not uncommon for rounding error to seriously affect the accuracy of the results solve3xy5 4 y2x xy X1Y2 118 fsolve339xy5 4 y2x xy Error in fsolve invalid arguments Lists of equations and variables sometimes work too But then the result comes back in a different form a list of solutions Each solution is expressed as a list of equations for the variables involved in the system fsolve doesn39t accept lists of unknowns at least in Maple 12 There39s no strong reason why the design m to be this way but that39s Maple 1239s fsolve rejects parameters of type list solve x2 2x 5 0x gt 0 x x 1 JF fsolve x2 2x 5 0 x gt 0 0 Error in fsolve expecting an equation or set or list of equations but received inequality x 22xi5 0 0 lt x 119 Sometimes you can give extra constraints on the solution through the use of inequalities fsolve doesn39t work with inequalities If the result of a multi variate solve is a piecewise expression then the additional phrase assum i ng inequality can eliminate some of the pieces Example 912 Use of assuming solve x2 5 x x gt 0 x We get a piecewise expression as the result of solve if you don39t put any restrictions on XZFNH 0 lt55 alpha WWW 5J7 lt0 1110 otherwise Adding information that alpha is positive removes some of the pieces and greatly x Z J I x 1111 simplifies the information being presented solve x2 5oc x gt 0 x assuming 01 gt 0 T7 Section 92 Calculus differentiation simplification As it is taught in traditional first year calculus differentiation is an operation on functions Maple knows how to differentiate all of the common functions found in calculus It is particularly useful for performing differentiation when it would take a lot of algebraic manipulation to do the operations by hand di as a function takes two or more arguments The first argument must be or evaluate to an expression The second argument must be or be an expression that evaluates to the variable of differentiation The there are third fourth etc arguments provided they are used as variables of higher derivatives The result of diff is an expression or a number if the derivative is a numerical constant Evaluation of a derivative expression can occur through eval as with other expressions Example 821 Symbolic differentiation and evaluation of derivatives Example Commentary expr1 x2 2x 5 x2 2 x 5 121 di 636197 X Find the first derivative of the expression with 2 x 2 122 respect to x posExpr sin cot 52 sin 03 t 52 123 di PosExpn t Find the first derivative of the expression with 124 2sincot5 coscot5o 124 di posExpr t t 2coscot52o2 2sinot 125 2 2 5 co di expr t 126 simplify 125 20322coscot52 1 127 eval 122 x 3 4 128 eval 127 I 470 2 032 2 cos470 m 52 1 129 respect to t Find the second derivative of the expression with respect to t The result is the same as if we had taken the derivative of 124 di s second argument must be the variable of differentiation Note that if the variable doesn39t occur in the expression the derivative according to the mathematical definition is zero If you are surprised by getting a zero derivative check that you are using the correct variable to differentiate with respect to simplify can reduce the size of the expression although factor or expand sometimes work better Sometimes additional trigonometric identities need to be applied through simplify trig This is a way to compute ic2 2x5 dx x23 This is a way to compute d2 2 P s1n to t 5 The result of l evaluation does not have to be a number even if a numeric value is being supplied for one of the variables in the expression being evaluated Example 822 Plotting a function and its derivative together Example Commentary f a b gt Sina cosb a 17 gtsina cosb gz a g g Medea plortgm ro30 1210 1211 We39re already used to functions that take one or two arguments Note that unlike mathematical convention in programming variable names often do have names that are more than one letter long This is to increase intelligibility to readers looking at the programming Although it seems minor ease of comprehension can play an significant role 1 G u u 10 2 0 t 1 2 fderiv1 di goc 0c 1 1 1 1 2 cos 2 on 3 sin 3 on 1212 plot g on fderiv on 0 30 2 in the cost of developing and using software so is an important engineering concern In this example we plot a quotstrangequot function built out of trigonometric parts and plot it and its derivative Since g is a function gt will evaluate to the expression Thus the plotting variable should be t rather than on or some other variable The value of fderiv is an expression involving alpha We plot two expressions involving the variable alpha on the same plot The use of a set as a first argument to plot to do multiple plots was first explained in section 63 We need to use on as the plotting variable here since the value of fderivis an expression involving 0c Section 93 Calculus limits You can use the clickable interface to compute limits by selecting the appropriate item from the Expression palette and then filling in the template as needed Maple uses calculus techniques eg l39Hopital39s Rule to compute limits symbolically Example 931 Clickable interface version of limits Example Commentary lim H3 x 32 00 131 hm smx xgtioo X 0 132 lim l ta 0 t unde ned 133 lim ta 0 I 00 134 hm sinx X A 1 x sina 7 135 The result of limit can be an expression possibly involving positive or negative infinity as well as the symbol unde ned Even though the limit exists as t approaches from the right or left they do not agree so there is no quottwo sidedquot limit n n OI n H To take a one sided limit add a superscript to the limit point Note that the value returned as the limit for x a while true for most values of a is not really valid for a0 The textual version of taking limits involves the limit function limit takes at least two arguments The first argument is the expression that you wish to take the limit of The second argument is an equation indicating the limit variable and the limiting value If you supply a third argument it indicates whether a quotright sidedquot quotleft sidedquot limit is desired instead of a two sided limit Example 931 Textual version of limits Example Commentary limit1x3quot2x3 co 136 limitsinx x x 00 0 137 limit1t t0 left 00 138 The first argument is the expression that you wish to take the limit of The second argument is an equation indicating the limit variable and the limiting value You can use quotinfinityquot or quot infinityquot as the way of specifying 00 or 00 textually without use of the palette The third optional third argument to limit can specify a one sided limit This is the textual way of specifying lim There is no simple t a 0 way of specifying this i This is the textual way of specifying lir51Jr t t H limit1t t 0 right 00 139 One could make a case that the second argument for the textual form of limit should be something looking like var gt limit value since that is the more conventional terminology But because of the limitations of Maple39s processing capabilities for its programming language it would be more expensive to support arrows for both this meaning in limits and the use of gt in function definitions So users must get used to using equations rather than the standard math symbol for 7 quotapproachesquot 7 Section 94 For the advanced multivariate differentiation This section can be skipped until you take multivariate calculus Calculations involving expressions or functions of several variables are a situation where having a computer to do the symbolic calculation is even more useful One can apply differentiation several times via the clickable interface but this can become tedious when computing higher derivatives The textual interface can be faster Other multivariate operations have no clickable Examples 941 Multivariate calculus operations This problem 67 from Anton Calculus 8th Let cos Com ute and Z 5 y p Z 2 Z edition section 143 Zyx We enter the expression and give it a name zexpr cosy 5 COS 041 We use the textual version of differentiation to di zexpn x x l 6080 4 x32 di zexpn y y This computes i i 2 i J7cosy 143 6y 6 may 39 eXpreSSlon dl zexpn x y 1 mm a a 32 144 7 7 Z 7 2 J ThlS computes ax 6y 6y ax of the compute i2 of the expression 6 x 142 of the di Zexpn y x 1 mm 2 J7 145 39cosbl differentiate wrt x C3827 X differentiate wrt y l siny 2 5 expression Since the expression describes a continuous function of x and y we get the same results as when we took the partial derivatives in the reverse order This is one situation where the textual interface gives the answer faster than the clickable interface However the clickable interface does display the intermediate results Given that x3 y2x 3 0 find if implicitdi x3 y239x 3 05 y X 2 2 l m 146 2 y x 6 Given yexsin3 z 3z compute a zand 6 6 z through implicit differentiation y im licit differentiation yexsrn3 z 3zp lne e X implicit differentiation 6 yexsin3z 3z lt X This is Example 3 from section 145 of Anton Calculus 8th edition Not surprisingly Maple has a built in command to do implicit differentiation You can read more about it by typing quotimplicit differentiationquot or quotimplicitdif quot into Maple39s on line help This is problem 43 in section 145 of Anton The clickable interface lets us select what the dependent variable is and which is the variable of differentiation Here we pick quotzquot and 39x Although the output does not show it we picked quotzquot and quotyquot here Using the textual version implicitdi would clearly show that different things are being computed Find the directional derivative of fx y 2 xy eyatP1 1 in the direction of the negative y axis with S tudentM ultivariateCalculus Approximatelnt 147 ApproximatelntTutor CenterOfMass ChangeO ariables CrossSection CrossSectionTutor Del DirectionalDerivative DirectionalDerivativeTutor This is problem 25 from section 146 of Alton Calculus 8th edition This loads all the functions from the Student MultivariableCalculus package You can read more about this by entering quotdirectional derivativequot into Maple39s on line help FunctionAvemge Gradient GmdientTutor Jocobian LagrangeMultipliers MultiInt Noble Revert S econdDerivdtiveTest S urfaoeArea TaylorApproximation TaylorApproxinmtionTutor 110 1 Mir DirectionalDerivdtiveh xy 3983 96 y 15 148 With the package loaded in we can use the DirectionalDerivative function The second argument is the point where we are evaluating the derivative and the third argument describes the direction We need to express this direction as a quotunit vectorquot This 3 d graph describing the situation with the directional derivative of 148 was produced by selecting Tools gtTutors gtMultivariable Calculus gt Directional Derivative in the Maple interface and supplying the information in textual form described in that problem 7 Section 95 For the advanced integration This section can be skipped until you need to do integrals Maple can perform symbolic integrals about as well as most people can Because it is indefatigably rigorous about doing algebra it can often get an answer more reliably at least for longer problems We will discuss symbolic integration further in a few chapters but will preview it here You can read more about this by entering quotintegrationquot into Maple39s on line help Next term we will work more with symbolic integration but since we are introducing calculus in this chapter we wanted to give a more complete picture of Maple39s calculus capabilities Example 951 Symbolic Integration Jsinx2dx 151 Maple can handle do indefinite and definite integration symbolically using the integration item from the Expression palette x 2 integratewrtx sin x 2 2 cos x x2 16 cos x 8sinxx The clickable interface has an quotintegratequot item You have to select the variable of integration The clickable interface does not have a quotdefinite integrationquot menu item since it is too much work to enter the information in that fashion You can int sin i x2x 2 a L 2 L 2cos 2 xx 16cos 2 x 8sinixx 2 intlnx x x0 152 1 2 16 7 1112 153 L 2 64 7 The function that does integration is called int although it could have been called integrate that doesn39t work in Maple The first argument is the expression to be integrated the second is either the variable of integration for indefinite integration or an equation stating the variable and a range for definite integration Maple has a number of tools for studying the part of calculus having to do with integration For example selecting Tools gtTutors gtCalculus Single Variable gtlntegration Methods will display a pop up window where one can enter the textual form of an integrand and produce a step by step derivation of the symbolic integral as illustrated by Figure 951 below gure 951 Symbolic Integration Tutor from Tools gtTutors gtCalculus Single Variable gtlntegration Methods rm E ll RultleInIunn Arrrrly Ruln Unnlrxlnnn Rulls Hllll Emu zfunmnn FuIIElinn smtxzww Vzllzbln x flnm In Fm unsummmume Me has bEEn apphm Eslrnw HInlS cu M ll JD Slll Example 951 Numerical rntegratron I When Maple returns the samethrng as what 4 2 you entered rt means that rt couldn t determrne I tanx dx a srrnple mpressron for the rntegral o i A n I tanx739 dx 154 o z t 10 ch 393 I tanx2 lmmzzggm However rt can determrne that the area 0 underneath the Curve oftanx2 between 0 and evalfinttanx2 x 0 J 20 017122897213322970855 155 g is approximately 01712 To do this we used the quotapproximate to 10 digitsquot item of the clickable interface This uses the textual version of the integration and numerical approximation commands to approximate the area to 20 digits 7 Section 9X Chapter summary Example 911 Solving equations Example Commentary solve 3xy5 4 y 7x xy x g 4 y 4 fsolve3xy54 y7x xy x 02500000000 y 5750000000 162 solve x y3 xy4 xy 301M x yfy 96 x yll xR00t0fffZ Zy fR00t0f ffZ Z 163 To solve a system of equations give solve a set of equations and a set of variables The result can be a set of equations solve returns NULL if it can39t any solution Maple may return expressions involving more advanced mathematics in some cases If you get back an answer that you don39t comprehend it39s a sign that either you39ve asked the wrong problem by mistake or that you39re going to have to get more help in understanding the situation Example 912 Use of assuming solve x25ocx gt 0 x Hw n MEN lamm F lt0391396394 otherwise solve x2 5oc x gt 0 x assuming on gt 0 We get a piecewise expression as the result of solve if you don39t put any restrictions on alpha Adding information that alpha is positive removes some of the pieces and greatly k 165 simplifies the information being presented Example 821 Symbolic differentiation and evaluation of derivatives Example Commentary expr1 x2 2x5 x2 2 x 5 166 di expr x 2 x 2 167 posExpr sin cot 52 sin to t 52 168 di PosExpn t 2sincot5 coscot5o 169 di PosExpn t t 2cos03t52602 2sincot 1610 2 2 5 co di expr t 1611 simplify 1610 20322COSDI52 1 1612 eval 167 6 3 4 1613 eval 1612 t 470 2 of 2 cos470 m 52 1 1614 Find the first derivative of the expression with respect to x Find the first derivative of the expression with respect to t Find the second derivative of the expression with respect to t The result is the same as if we had taken the derivative of 124 di s second argument must be the variable of differentiation Note that if the variable doesn39t occur in the expression the derivative according to the mathematical definition is zero If you are surprised by getting a zero derivative check that you are using the correct variable to differentiate with respect to simplify can reduce the size of the expression although factor or expand sometimes work better Sometimes additional trigonometric identities need to be applied through simplify trig This is a way to compute i x2 2x 5 dx x23 This is a way to compute 1614 d2 2 72 s1n to t 5 The result of d t t 47 evaluation does not have to be a number even if a numeric value is being supplied for one of the variables in the expression being evaluated Example 931 Clickable interface version of limits Example Commentary 1 The result of limit can be an expression x1313 x 3 2 possibly involving positive or negative 00 1615 infinity as well as the symbol unde ned hm s1nx x gt 00 X 0 1616 1 rhino Even though the limit exists as t approaches from the right or left they do not agree so unde rwd 13963917 there is no quottwo sidedquot limit lim ta 0 I 00 1618 To take a one sided limit add a quotquot or quot quot superscript to the limit point hm s1nx X H l x 5mm 1619 Note that the value returned as the limit for x a a while true for most values of a is not really valid for a0 Example 931 Textual version of limits Example Commentary limitlx 3quot2x3 00 limitsinx x x 00 1620 1 n1 The first argument is the expression that you wish to take the limit of The second argument is an equation indicating the limit variable and the limiting value You can use quotinfinityquot or quot infinityquot as the way of specifying 00 or 00 textually without use of limitl lt t0 left 00 limitl It I 0 right 00 1621 1622 1623 the palette The third optional third argument to limit can specify a one sided limit This is the textual way of specifying lirn There is no simple I a 0 way of specifying this This is the textual way of specifying lir51Jr t H

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

#### "I signed up to be an Elite Notetaker with 2 of my sorority sisters this semester. We just posted our notes weekly and were each making over $600 per month. I LOVE StudySoup!"

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.