Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Integration in maple J. Gerlach Last Revision: February 1, 2011 Antiderivatives The command to find antiderivatives is int . You need to communicate the function (the integrand) and the variable of integration. Here is an example: In order to find the antiderivative of just enter (1.1) The syntax of the command is int( function, variable). The same result can be achieved with the inert version of the integration command (two steps, Int followed by value(%)) (1.3) or with right-clicking on the function (1.4) integrate w.r.t. x (1.5) or by using the icon on the left (1.6) Maple doesn't know every integral; when it gets too hard, maple will just repeat the question: (1.7) Constant of Integration Maple omits the constant of integration C. This can sometimes lead to seemingly contradictory results. Let's say that we want to integrate the function Direct calculation yields (1.1.1) (1.1.2) (1.1.3) On the other hand, we could also expand the function before we integrate. This leads to the following: (1.1.4) (1.1.5) (1.1.6) Thus we have found the two anti-derivatives Y and Z. They are not identical since (1.1.7) (1.1.8) But this is not a contradiction, since we know that all antiderivatives of the same function differ by a constant. Variable of Integration Suppose we want to integrate y = . First we define the expression xt If we consider x to be the variable of integration, we find (1.2.1) (1.2.2) while with t as variable we obtain (1.2.3) The answers are completely different, which means that we need to pay attention to the second argument of the integration command (do we mean dx or dt?). If the variable of integration is neither x nor t, say it is z, then we get (1.2.4) Definite Integrals Definite integrals are evaluated just as easily; just add the range of the variable (lower and upper limit) to the int command. For example, let's say we want to integrate on the interval [0, 4]. We enter (2.1) Maple returns the result, but it doesn't display the integral very well. It may be more advantageous to use a two step method (Int followed by value) instead (2.2) Clickable math can be used as well (2.3) integrate w.r.t. x (2.4) = (2.5) Here I used the "Definite Integral" option under "Constructions", and then the "Evaluate (from inert)" command. Using the icon on the left we get (2.6) If you are interested in numerical results, you may use either the evalf command, or the "Approximate" option when you right-click. Example: 0.9084218056 (2.7) or (2.8) at 10 digits 0.9084218056 When maple can't find an explicit result for a definite integral (because the antiderivative may be hard to find), numerical evaluation is a good option. Example: (2.9) Maple doesn't know how to proceed. Alternative: (2.10) 0.8277841559 (2.11) Variable Limits of Integration The upper and lower limits in an integral may be variable themselves. Maple can handle this. Example: We define a new function F(x) as (2.1.1) In the literature this function is known as the Fresnel Sine function. Maple recognizes this: (2.1.2) The derivative of F is (2.1.3) as expected from the Fundamental Theorem of Calculus. Here is another illustration. We can construct an antiderivative of any function f(x) by defining it as Then F'(x) =f(x), as long as f is continuous. Example with better choice) and a=1 (a = 0 may be a (2.1.4) Check the derivative of F: (2.1.5) The explicit formula for F is (2.1.6) with derivative (2.1.7) Numerical Integration Numerical integration is the approximate calculation of the value of a definite integral. This is useful when the integrand is a complicated function without a simple anti-derivative. Evaluations of the function at the left or right endpoint, or in the middle of a subinterval are special cases of Riemann sums (Section 4.2 and 4.3) and means of numeric approximations of a definite integral. The Trapezoidal Rule and Simpson's Rule (Section 4.6) are other options. All of these are built-in functions of the student package. We illustrate all of these methods for the integral of the function on the interval from 0 to 2 and we compare the numerical approximations to the exact value of the integral. First restart and bring up the student package. Now define the function once and for all (3.1) Next find the exact result for the definite integral and name it TrueResult. 86 15 (3.2) 5.733333333 (3.3) at 10 digits A display of the approximating rectangles can be done with the leftbox, rightbox or middlebox command. For any of these instructions you need to communicate the function, the interval and the number of subintervals. Let's look at right endpoints for 5, 10 and 20 subintervals: 5 4 3 2 1 0 5 4 3 2 1 0 0 1 x 2 0 1 x 2 5 4 3 2 1 0 0 1 x 2 It becomes evident that more subintervals will lead to better approximations of the area under the curve. The "box" commands display only, you need the "sum" commands to actually calculate the areas. We illustrate this process for rightsums. (3.4) at 10 digits 6.584960000 (3.5) The rightsum command just shows the sum which needs to be computed, and we have to follow it with an evaluation command.All of this can be done in a single step (and we will use this in the future) : 6.584960000 (3.6) For more subintervals we get 6.146560000 5.936660000 The commands work just the same for leftsums or middlesums. (3.8) Now let us discuss the accuracy of approximation schemes, where we compare the approximations to the exact value of the integral. We shall always use 10 subintervals in the comparisons, and the exact value was computed before 86 15 5.733333333 As expected, right or left sums do not fare well: (3.9) 6.146560000 (3.10) 0.413226667 (3.11) 5.346560000 (3.12) (3.13) The average of the two estimates should be better, especially since one estimate is too high and the other is too low. 5.746560000 (3.14) 0.013226667 (3.15) This is quite an improvement! The Trapezoidal Rule (details in class) will yield the same result: 5.746560000 (3.16) For the Midpoint Rule the rectangles are always taken in the middle of an interval, as the graph below illustrates 5 2 0 0 1 x 2 The accuracy of this method is on the same order as the Trapezoidal Rule (roughly speaking, it is usually twice as good). 5.726760000 (3.17) (3.18) Finally, Simpson's Rule can be thought of as a weighted average of the Midpoint Rule and the Trapezoidal Rule. 5.733360000 (3.19) 0.000026667 (3.20) Again, notice a major improvement in accuracy! Simpson's Rule can be calculated directly with the simpson command (we have to use n=20 to get the same result as above). 5.733359999 (this is just a slight rounding discrepancy). For technical reason the number of subintervals in Simpson's rule must be even. (3.21)