Dene an ode note that the diff command and not the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e integrations. For example, recompute the previous integral on the interval x = 1 to x = 2. > Int(df,x=1..2); 2 sin(a x) + x cos(a x) a + 2 b x dx 1 > value(%); −sin(a) + 3 b + 2 sin(2 a) Consider a more complicated integral. > Int(exp(-x^2), x); e(−x ) dx 2 > value(%); 1√ π erf(x) 2 If Maple cannot clearly determine whether a variable is real or complex, it may return an unexpected result. > g := t -> exp(-a*t)*ln(t); 70 • Chapter 3: Finding Solutions g := t → e(−a t) ln(t) > Int (g(t), t=0..infinity); ∞ 0 e(−a t) ln(t) dt > value(%); t→∞ lim − e(−a t) ln(t) + Ei(1, a t) + γ + ln(a) a Maple assumes that the parameter a is a complex number. Hence, it returns a more general answer. For situations where you know that a is a positive, real number, indicate this by using the assume command. > assume(a > 0): > ans := Int(g(t), t=0..infinity); ∞ ans := 0 e(−a ~ t) ln(t) dt > value(%); − ln(a ~) γ − a~ a~ The result is much simpler. The only non-elementary term is the constant gamma. The tilde (~) indicates that a carries an assumption. Remove the assumption to proceed to more examples. You must do this in two steps. The answer, ans, contains a with assumptions. To reset and continue using ans, replace all occurrences of a~ with a. > ans := subs(a =’a’, ans ); ∞ ans := 0 e(−a t) ln(t) dt The first argument, a = ’a’, deserves special attention. If you type a after making an assumption about a, Maple automatically assumes you 3.6 Solving Differential Equations Using the dsolve Command • 71 mean a~. In Maple, single quotes delay evaluation. In this case, they ensure that Maple interprets the second a as a and not as a~. Now that you have removed the assumption on a inside ans, you can remove the assumption on a itself by assigning it to its own name. > a := ’a’: Use single quotes here to remove the assumption on a. For more information on assumptions, see 6.2 Assumptions. 3.6 Solving Differential Equations Using the dsolve Command Maple can symbolically solve many ordinary differential equations (ODEs), including initial value and boundary value problems. Define an ODE. Note that the diff command and not the inert form Diff is used in this example. > ode1 := {diff(y(t),t,t) + 5*diff(y(t),t) + 6*y(t) = 0}; ode1 := {( d2 d y(t)) + 5 ( y(t)) + 6 y(t) = 0} dt2 dt Define initial conditions. > ic := {y(0)=0, D(y)(0)=1}; ic := {D(y )(0) = 1, y(0) = 0} Solve with dsolve by using the union operator to form the union of the two sets. > soln := dsolve(ode1 union ic, {y(t)}); soln := y(t) = −e(−3 t) + e(−2 t) To evaluate the solution at points or plot it, first use the unapply command to define a proper Maple function. For more information, see 3.1 The Maple solve Command. To extract a value from a solution set, use the eval command. 72 • Chapter 3: Finding Solutions > eval( y(t), soln ); −e(−3 t) + e(−2 t) Define y as a function of t by using the unapply command. > y1:= unapply(%, t ); y...
View Full Document

Ask a homework question - tutors are online