Math 244, Spring 2009 Sections 07 and 08 

 

 

Integration, Differentiation, Plotting, and Solving Differential Equations 

 

 

Example 1. Enter and evaluate the indefinite integral Typesetting:-mrow(Typesetting:-mo( Differentiate the output to verify that the anti-derivative is correct. Plot the integrand and the integral on the same set of axes.  Then evaluate the definite integral from x=0 to x=Pi. 

 

Solution. The integral is entered and evaluated below.  There are two different ways to enter the integral.  The first is to type int(x*cos(3*x),x);  The ,x tells Maple that you want to integrate with respect to the variable x. An important observation:  a times sign * between x and cos(3*x)  is required to signify multiplication.  Also observe that Maple omits the constant of integration. 

 

The integral can also be entered by choosing the Typesetting:-mrow(Typesetting:-mo(from the menu on the left-hand side of the screen (under the "Expression" tab).  First enter x*cos(3*x) in place of f.  Then use the tab key to move the cursor to the dx, and enter x (again to tell Maple that you want to integrate with respect to the variable x).  Then hit enter.  

 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`*`(`/`(1, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(`/`(1, 3), `*`(x, `*`(sin(`+`(`*`(3, `*`(x)))))))) (1)
 

> Typesetting:-mrow(Typesetting:-mo(
 

`+`(`*`(`/`(1, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(`/`(1, 3), `*`(x, `*`(sin(`+`(`*`(3, `*`(x)))))))) (2)
 

 

To differentiate the output, you can either type %' (using the prime notation for the derivative) or the diff(f,x) command.  This tells Maple to differentiate f with respect to x.  

 

 

> Typesetting:-mrow(Typesetting:-mi(
 

`*`(x, `*`(cos(`+`(`*`(3, `*`(x)))))) (3)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`*`(`/`(1, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(`/`(1, 3), `*`(x, `*`(sin(`+`(`*`(3, `*`(x)))))))) (4)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`*`(x, `*`(cos(`+`(`*`(3, `*`(x)))))) (5)
 

> diff(`*`(`^`(x, 2)), x); 1
 

`+`(`*`(2, `*`(x))) (6)
 

 

As with the int command, you can also choose the Typesetting:-mrow(Typesetting:-mfrac(Typesetting:-mo(symbol from the menu on the left-hand side of the screen and use the tab key to move between the dx and the f.  Don't forget to use the * sign for multiplication.  Use the arrow keys to move between numerators, denominators, and exponents. 

 

> Typesetting:-mrow(Typesetting:-mi(
 

`*`(x, `*`(cos(`+`(`*`(3, `*`(x)))))) (7)
 

> Typesetting:-mrow(Typesetting:-mfrac(Typesetting:-mo(
 

`*`(x, `*`(cos(`+`(`*`(3, `*`(x)))))) (8)
 

 

The plot procedure will draw the two curves. Put the integrand and output (1) inside of square brackets. The entry x=0..2 plots the curves over the interval from x=0 to x=2. The caption equation adds a caption.  You can use the color= option to adjust the colors of the curves. 

 

 

> Typesetting:-mrow(Typesetting:-mi(
Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

 

In general, use plot([f(x),g(x)]); to plot curves f(x) and g(x) on the same set of axes.  You can plot more than two functions by including more functions inside the square brackets. 

 

> Typesetting:-mrow(Typesetting:-mi(
 

-`/`(2, 9) (9)
 

> Typesetting:-mrow(Typesetting:-mi(
 

-.2222222222 (10)
 

 

Using the Percent Sign % to Refer to the Previous Output  

The percent sign, % , in an input expression refers to the last output (last in time, not position). Use it sparingly to avoid confusion.  

 

Example 2. Differentiate the expression sin(x)/x and then integrate the output. 

 

 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`/`(`*`(cos(x)), `*`(x)), `-`(`/`(`*`(sin(x)), `*`(`^`(x, 2))))) (11)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`/`(`*`(sin(x)), `*`(x)) (12)
 

 

 

Solving Differential Equations and Initial-Value Problems 

 

The dsolve command solves a given differential equation.  The symbol _C1 represents an arbitrary constant. 

 

> Typesetting:-mrow(Typesetting:-mi(
 

y(x) = `/`(`*`(`+`(`*`(`/`(1, 3), `*`(`^`(x, 3))), _C1)), `*`(x)) (13)
 

To obtain the solution to an initial value problem put the differential equation and the initial condition inside a set of curly brackets {}, as shown below.  

 

> Typesetting:-mrow(Typesetting:-mi(
 

y(x) = `/`(`*`(`+`(`*`(`/`(1, 3), `*`(`^`(x, 3))), `-`(`/`(7, 3)))), `*`(x)) (14)
 

The output to dsolve is the solution equation. To plot the solution curve apply the plot procedure to the expression on the right hand side of equation (6). See below.  

 

> Typesetting:-mrow(Typesetting:-mi(
 

`/`(`*`(`+`(`*`(`/`(1, 3), `*`(`^`(x, 3))), `-`(`/`(7, 3)))), `*`(x)) (15)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`/`(`*`(`+`(`*`(`/`(1, 3), `*`(`^`(x, 3))), `-`(`/`(7, 3)))), `*`(x)) (16)
 

> Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

 

The plot is rather disappointing. This is because the solution has a vertical asymptote at the origin and we did not limit the vertical range. See the next plot input. The second range entry y=-8..8 tells plot to use the vertical range from y=-8 to y=8.  

 

 

> Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

 

Formula (17) shows that, as x approaches infinity, the solution curve approaches the curve y=(1/3)*x^2. See the next plot. The color option makes the first curve red and makes the second curve blue.  

 

> Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

 

Example 4. A house cools at a rate so that Newton's Law of Cooling applies: T' = k*(A-T), where T(x)  is the  

temperature inside the house at time x,  A is the ambient temperature, and k is a positive constant. Assume that the ambient temperature is A=50 degrees F. If the house temperature is 70 degrees at 12 midnight and 65 degrees at 1 AM, then what is its temperature at 6 AM?  

 

Solution. Begin by obtaining the solution to the initial value problem T' =k*(50-T) , T(0) =70 , where we let x=0 correspond to 12 midnight. When entering this equation we must be careful to put a * symbol between k and the  

term 40-T  to indicate multiplication.  

 

> Typesetting:-mrow(Typesetting:-mi(
 

> dsolve({diff(T(x), x) = `*`(k, `*`(`+`(50, `-`(T(x))))), T(0) = 70}); 1
 

T(x) = `+`(50, `*`(20, `*`(exp(`+`(`-`(`*`(k, `*`(x)))))))) (17)
 

 

To obtain the value of k, we substitute x=1 and set the result equal to 65, and solve for k. 

 

> `:=`(T, rhs(%)); 1
 

`+`(50, `*`(20, `*`(exp(`+`(`-`(`*`(k, `*`(x)))))))) (18)
 

> subs(x = 1, T); 1
 

`+`(50, `*`(20, `*`(exp(`+`(`-`(k)))))) (19)
 

> `:=`(A, %); 1
 

`+`(50, `*`(20, `*`(exp(`+`(`-`(k)))))) (20)
 

> solve(A = 65, k); 1
 

`+`(`-`(ln(`/`(3, 4)))) (21)
 

> `:=`(k, %); 1
 

`+`(`-`(ln(`/`(3, 4)))) (22)
 

 

 

> T; 1
 

`+`(50, `*`(20, `*`(exp(`*`(ln(`/`(3, 4)), `*`(x)))))) (23)
 

This is the solution formula that is needed to answer the question. Simply evaluate T when x=6.  

 

> subs(x = 6, T); 1
 

`+`(50, `*`(20, `*`(exp(`+`(`*`(6, `*`(ln(`/`(3, 4))))))))) (24)
 

> evalf(%); 1
 

53.55957031 (25)
 

 

 

>