53
Copyright c 2008 Kevin Long Higher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University September 5, 2008

Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

  • Upload
    others

  • View
    11

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ngHigher Mathematics for Scientists and Engineers

Math 3350 Lecture Notes

Kevin LongTexas Tech University

September 5, 2008

Page 2: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

2

Page 3: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Contents

1 Introduction: motion of a falling sphere 51.1 Motion subject to a constant force . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Effects of air resistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.2.1 How NOT to solve this problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.2.2 A way out of the loop: separation of variables . . . . . . . . . . . . . . . . . . . . . . . 81.2.3 Using the initial conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.2.4 Analysis of the solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.3 Checking solutions to differential equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.1 A systematic procedure for validating solutions . . . . . . . . . . . . . . . . . . . . . . 11

1.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.5 Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2 Separation of variables 152.1 Separable equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.1.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.2 A procedure for solving separable equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.2.1 Some shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.2.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.3 Using Mathematica to assist separation of variables . . . . . . . . . . . . . . . . . . . . . . . . 19

3 Separation of variables, continued 253.1 Using the initial conditions systematically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.1.1 A shortcut to C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.1.2 Using definite integrals to incorporate initial conditions . . . . . . . . . . . . . . . . . 263.1.3 Shortcut, version 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.1.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.2 Existence and uniqueness of solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283.2.1 What if the algebraic subproblem has multiple solutions? . . . . . . . . . . . . . . . . 283.2.2 An initial value problem with multiple solutions . . . . . . . . . . . . . . . . . . . . . 293.2.3 Existence and uniqueness of solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4 Linear first-order equations 334.1 A standard notation for first-order linear equations . . . . . . . . . . . . . . . . . . . . . . . . 344.2 Solving first-order linear equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.2.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.2.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.4 Using Mathematica for first-order linear equations . . . . . . . . . . . . . . . . . . . . . . . . 39

A An introduction to Mathematica 43

3

Page 4: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

4

Page 5: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Lecture 1

Introduction: motion of a fallingsphere

We’ll start with an example. Recall Newton’s Second Law of Motion from classical mechanics,

md2x

dt2= F (x,

dx

dt, t). (1.1)

The usual problem you’d solve in mechanics is this: given a force F and knowledge of a particle’s initialposition and velocity x0 and v0, find the resulting motion x(t). In more mathematical language, you’re givena function F (x, dx

dt , t) and you’re looking for a function x(t) such that when you plug it into the left-hand side(LHS) of equation 1.1, you get back the force function F (x, dx

dt , t) appearing on the right-hand side (RHS).Such a problem, where we are to determine a function x(t) given an equation involving x and one or

more of its derivatives, is called a differential equation (DE). When the equation involves derivatives withrespect to only a single variable, it is called an ordinary differential equation (ODE). When the functionmust also be consistent with some initial conditions, the problem is called an initial value problem (IVP).These lectures will be concerned primarily with IVPs.

This differential equation involves d2xdt2 , but doesn’t contain any higher-order derivatives such as d3x

dt3 . Thehighest order of derivative appearing in a DE is called the order of the DE. Equation 1.1 is therefore secondorder.

However, suppose the force F depends on time t and velocity v, but not on position x. Recalling thatthe acceleration d2x

dt2 is the derivative of velocity, dvdt , then in such a special case equation 1.1 can be written

in terms of velocity and time, eliminating position:

mdv

dt= F (v, t). (1.2)

This is a first-order equation. Roughly speaking, all other things being equal, the lower the order of adifferential equation the easier it is to solve1, so we’ll start with this first order form, restricing ourselves toposition-independent forces.

1.1 Motion subject to a constant force

The simplest force function is just a constant, say, F = −mg as appears in the motion of a falling body nearthe Earth’s surface. You’ve probably solved this problem in calculus or physics courses. With F = −mg,

1The “all other things being equal” hedging is necessary. There are many considerations entering into whether a differentialequation is “easy” or “hard” to solve in practice. There are simple tenth-order equations, and wickedly difficult first and secondorder equations.

5

Page 6: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

the equation of motion (again, in first-order form) is

mdv

dt= −mg, (1.3)

which after cancelling out the masses givesdv

dt= −g.

For simplicity we’ll work in English units so that g is the nice round number 32 feet per second per second.Do the indefinite integral of both sides, ∫

dv

dtdt = −

∫32 dt (1.4)

v(t) + C1 = −32t+ C2 (1.5)

Notice that both sides have a constant of integration; however, we can always pick one of them and subtractit from both sides. I toss a coin, it comes up tails, so I choose to subtract C1 from both sides; that gives me

v(t) = −32t+ C2 − C1.

But C2 − C1 is just a constant, so I can rename it, calling it C, in which case

v(t) = −32t+ C.

When doing the indefinite integral of both sides of an equation, we can always do this business of subtractingone constant of integration and renaming the resulting constant. You can always take a shortcut and useonly the one constant of integration.

Because of the presence of C, we’ve not found just one function v(t) that satisfies 1.3, we’ve found afamily of solutions with infinitely many members, each corresponding to a particular choice of C. We’ll callthis a family of solutions parametrized by C

To narrow the solution down from an infinite family to a single function, we need to provide moreinformation. Suppose that in addition to requiring the function v(t) satisfy 1.3, we also require that whent = 2 seconds, the velocity is 7 feet per second. In other words, v(2) = 7. Satisfying equation 1.3 means that

v(t) = −32t+ C,

and in particular,v(2) = −2 · 32 + C,

so that the additional requirement v(2) = 5 implies that

7 = −64 + C

orC = 71,

and thereforev(t) = −32t+ 71

In this example, then, all that we needed to find a single function rather than a family of functions was toadd one additional requirement, namely the stipulation that the velocity at some time t0 (in this example,t0 = 2) be given a known value v0 (in this example, v0 = 7). Whether that specifying an initial value willbe sufficient (or necessary, for that matter) for other problems is a question we’ll take up later.

In this problem, we were able to find a family of solutions by straightforward integration. In general, wewon’t be able to do that, at least not with some trickery first to tweak the problem into a form that we cansolve by integration.

6

Page 7: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

1.2 Effects of air resistance

A real body falling through air will experience a force in addition to gravity: hydrodynamic drag, or airresistance. An asymmetric body might experience lift or torque as well as drag; a non-rotating sphere haszero lift and zero hydrodynamic moment. To keep things simple and ensure we stay in one dimension we’llassume the body is a sphere. Experiments show that the hydrodynamic drag on a sphere depends on itsvelocity relative to the fluid medium, so the equation of motion should be

mdv

dt= −mg + Fd(v)

where Fd(v) is some (perhaps very complicated) function of velocity to be determined by experiment.Let’s think a minute about the general form of the drag force Fd(v). First of all, we know that when

the velocity is zero2, the drag force must be zero, i.e. Fd(0) = 0. Second, we know from experiment thatthe drag force always acts to oppose the motion: when v < 0, Fd > 0 and vise-versa. Note that the firstcondition Fd(0) = 0 follows from this second condition.

The simplest function with F always directed opposite to v is Fd(v) = −kv, where k is a constant.This simple expression for the drag force is in fact correct for motion at very low speeds – for instance,for a ping-pong ball falling through air, or for a colloidal particle in water or oil. It’s called Stokes’ Law,after the 19th-century mathematical physicist G. G. Stokes who investigated low-speed flow and found3

that, for a sphere of radius a in a fluid with dynamic viscosity η, the coefficient k is 6πηa. Because it’slimited to low speeds, the Stokes’ Law force won’t be accurate for high-speed things like cars, airplanes, ormathematics professors mysteriously falling from rooftops after brutal exams, but it will be a good modelfor many engineering problems, such as:

• The transport of rock particles in the “mud” used to remove debris from an oil drill.

• The transport of blood cells in plasma in the body or in an engineered biomedical device.

• The transport of soil particles during erosion by water or air.

So although high-speed aerodynamics requires drag force functions much more complicated than Stokes’Law, problems involving this simple little formula – about as simple as things get in fluid mechanics – arestill worth studying.

1.2.1 How NOT to solve this problem

So let’s take Stokes’ Law as given and see if we can solve the resulting equations of motion. Newton andStokes together give us

mdv

dt= −mg − kv. (1.6)

To put in some numbers, let’s take g = 32 and k/m = 8. Integrating both sides did the trick before, so let’stry it again: ∫

dv

dtdt = −

∫32 dt−

∫8v(t) dt.

The LHS and the first term on the RHS are easy, so

v(t) = −32t−∫

8v(t) dt.

But what about the last term, −∫

8v(t) dt. See the problem? We can’t compute the integral withoutknowing v(t). What’s v(t)? Well, by the equation it’s equal to the RHS, but the RHS contains the integral

2Think about what would happen were that not the case: a ball sitting at rest relative to a fluid would start moving as ifof its own volition. That doesn’t happen!

3Both experimentally and theoretically

7

Page 8: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

we don’t know how to do until we know v(t). So this approach leaves us stuck in an endless loop: we can’tsolve the problem without doing the integral, which requires us to have already solved the problem! Youcan go round and round here, integrating, differentiating, trying algebraic substitutions, and get nowhere.

Box 1.1 Getting stuck in a loop like that above is one of the most com-mon reasons for failing the first quiz in a differential equations class! Mostof the practical methods of solving differential equations boil down to transformingthe problem so that we can integrate without going round and round in that loop.

1.2.2 A way out of the loop: separation of variables

For this problem, a pretty simple transformation gives us a form we can work with. The trick – we’ll explainvery soon why someone might think to do this – is to divide both sides of equation 1.6 by 32 + 8v,

132 + 8v

dv

dt= −1,

and then integrate both sides with respect to t,∫1

32 + 8vdv

dtdt = −

∫dt. (1.7)

It’s easy to compute the integral on the RHS; it’s just −t + C. To do the integral on the LHS, make thesubstitution u = v(t). By the usual procedure of a “u-substitution,” we compute

du =dv

dtdt.

Now notice that this appears directly in the LHS integral, as shown in the box,∫1

32 + 8v(t)dv

dtdt = −t+ C (1.8)∫

132 + 8u

du = −t+ C. (1.9)

Now this integral is something we can compute. Notice that through our u-substitution we’ve eliminatedtime from the integral. This is important. Considered as a function of time t, the integrand 1

32+8v(t) isan undetermined function; therefore, we don’t know how to compute its integral over t. But considered asa function of v, the integrand 1

32+8v is a perfectly well-determined function that we can integrate over v.This transformation is called separation of variables; it reduced the problem to an integral involving

only v on the LHS and an integral involving only t on the RHS. The reason it’s useful is that all integralsinvolving v(t) integrated over t have been eliminated; these were precisely the troublesome terms causing theendless loop in Box 1.1.

The integral is just ∫1

32 + 8udu =

18

log (32 + 8u) .

(Check it!) If you don’t know how to do that last integral off the top of your head, learn it, because we’regoing to see this sort of integral over and over again. As before, the constant of integration can be droppedbecause we’ve already introduced one on the other side. Setting the result of the LHS integral equal to thatof the RHS integral gives

log (32 + 8u) = −8t+ 8C. (1.10)

8

Page 9: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

This is an algebraic equation we can solve for u. Because we used the substitution u = v, we can gobackwards and replace u with v(t). Do so, then exponentiate both sides, getting

32 + 8v(t) = e−8t+8C (1.11)

so that

v(t) = −4 +18e8Ce−8t. (1.12)

As before, this is a family of functions parametrized by C.

1.2.3 Using the initial conditions

To pin the solution down to a single function, we need to impose initial conditions.

For example, if the ball is dropped from rest, then v(0) = 0. Plug in t = 0 and v(0) = 0 into the solutionto get

v(0) = −4 +18e8Ce−8·0, (1.13)

0 = −4 +18e8C (1.14)

so

e8C = 32.

It’s not necessary to write out the solution for C (it is easily computed: C = 18 log 32), because we can just

substitute e8C = 32 directly into equation 1.12, giving

v(t) = −4 + 4e−8t.

Looks like we’re done. There is in fact one more very important step, but first, a word of warning.

9

Page 10: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Danger! Danger!

Box 1.2 A VERY COMMON MISTAKE. There’s an easy mistake to makein going between step 1.10 and step 1.11 in the calculation above. In exponentiat-ing the RHS −8t + 8C, it’s critical to remember that exponentiation does notdistribute over addition. That means that e−8t+8C is NOT equal to e−8t +e8C .When you exponentiate a sum, you must exponentiate the whole sum as a unit,NOT one term at a time. The “exponential of a sum” is NOT the “sum of theexponentials.”

Maybe it’s not obvious to you that exponentiation doesn’t distribute over addition.To prove that it doesn’t, it’s only necessary to provide a single counterexample.This brings us to ...drum roll... the first theorem of this course!

Theorem 1.1 Exponentiation does not distribute over addition.Suppose that exponentiation distributes over addition, that is,

ea+b = ea + eb (1.15)

for every value of a and b. If we find any values of a and b for which equation 1.15is false, then our initial supposition must be false. It’s easy to find such a coun-terexample: take a = 0 and b = 0, in which case 1.15 evaluates to

e0+0 = e0 + e0 (1.16)1 = 1 + 1 (1.17)1 = 2 (1.18)

which is clearly false. Thus, our initial supposition is incorrect. �

We’ve therefore proven that ea+b 6= ea + eb. If you exponentiate a sum and write itas the sum of the exponentials, you’re making a mistake. This is a special case of ageneral class of errors; we’ll study the question in more generality after introducingthe concept of linearity.

1.2.4 Analysis of the solution

At this point, let’s make just a few observations about the solution. The first is that as t → ∞, u → −4.That is, the velocity asymptotically approaches the constant value of 4 feet per second downwards; this iscalled the terminal velocity. The second observation is that we can examine the behavior at small timeby making a Maclaurin series expansion of the exponential functions,

e−8t ≈ 1− 8t+642t2 − · · · .

Using this approximation in the solution gives us

u(t) ≈ −32t+ 128t2 − · · · .

When t is small, say less than 0.01 seconds, then v(t) ≈ −32t is a very good approximation to the velocity.That’s just the velocity resulting from the constant gravitational acceleration of 32 ft/s/s, which makes sensebecause the air resistance force is small near the initial speed of zero.

So the solution makes basic physical sense. But is it right?

10

Page 11: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Figure 1.1: Don’t let this happen to you: check your solutions!

1.3 Checking solutions to differential equations

Trust, but verify

Ronald Reagan

The professions that use differential equations – engineering, medicine, finance, the military – are seriousbusiness, with serious consequences riding on getting things right (see figure 1.3.) As a working engineer,you’ll always need to validate your work. Most companies do validation voluntarily as a good businesspractice; it helps avoids recalls and lawsuits, or simply the release of a faulty product that gets bad reviewsand doesn’t sell. In safety-critical applications – automobiles, aircraft, medical devices, weapons, nuclearreactors – a rigorous validation procedure will be required by the government, private insurance companies,more likely both.

Validation of a complex engineering system is difficult, and the field of quality assurance engineering isa big subject in itself; you may well take a whole course on it at some point. Here, we’ll concentrate on asmall part of the problem: validating the solution of a differential equation.

1.3.1 A systematic procedure for validating solutions

To begin with, recall how to check the solution to an algebraic equation. To check whether x = 2 is thesolution to 3x+ 2 = 5, you substitute 2 in for x in the equation. You get 3 · 2 + 2 on the LHS, and 5 on theRHS. Comparing the LHS and RHS, you find 8 6= 5, so that x = 2 is clearly not the solution.

11

Page 12: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Validating the solution to a differential equation is only slightly more complicated. The basic idea is thesame as for validating the solution to an algebraic equation: plug the purported solution into the equation,and see whether the computed LHS and RHS are equal.

I find it’s good practice to use a systematic procedure. You can, if you like, develop your own; here ismine. I write out the calculations for the RHS and LHS separately, clearly labeling them:

LHS =dv

dt(1.19)

=d

dt

[−4 + 4e−8t

](1.20)

= 0− 8 · 4e−8t (1.21)= −32e−8t (1.22)

and then

RHS = −32− 8v (1.23)= −32− 8

(−4 + 4e−8t

)(1.24)

= −32 + 32− 8 · 4e−8t (1.25)= −32e−8t (1.26)= LHS (1.27)

so the solution to the ODE checks.What’s left? We still need to check that the solution satisfies the initial conditions. Evaluate the solution

at the initial time t = 0:

v(0) = −4 + 4e−8·0 (1.28)= −4 + 4 · 1 (1.29)= 0. (1.30)

But the initial velocity was specified to be v(0) = 0, so the solution satisfies the initial conditions. It thereforechecks out with both the ODE and the IC.

Box 1.3 In this course, I will require that you check the solution to most problems.Unless told otherwise, if the solution hasn’t been checked, you’ve notfinished the problem and you won’t get full credit.

1.4 Summary

• A problem in which we are to determine a function v(t) given an equation involving v and its derivativesis a differential equation. When supplemented by a specification of initial conditions, it is an initialvalue problem (IVP).

• It is generally not possible to solve a differential equation by integrating to get rid of derivatives, thendoing algebra to solve for the unknown function. The reason is that the integrals may involve theunknown function; because the solution has not yet been determined the integrals involving it can’tbe computed. Not understanding this point is a common beginner’s mistake.

• Some problems – such as the problem of a ball falling subject to gravity and air resistance – canbe transformed such that they can be solved by integration. This is the method of separation ofvariables.

12

Page 13: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

• Distributing exponentiation over addition is a serious mistake; it is a special case of a general class oferrors very commonly made by students.

• You can check the solution to an ODE by the following procedure: plug the solution into the LHSand into the RHS. If the two calculations don’t come out the same, then you’ve made an error. Whensolving an IVP, you also need to check that the solution obeys the initial conditions.

1.5 Preview

Here’s where we’re going in the next several lectures.

• How do we know that an ODE or IVP even has a solution? There are problems in mathematics thathave no solution (for example, find the real number x such that x2 = −1). Can we determine whetheran IVP has a solution? If it does, can we determine how many solutions it has? This is a theoreticalquestion and may sound like useless pedantry, but it has important engineering consequences.

• If an IVP has one (or more) solutions, is there a systematic way to find it (or them)? Alas, there is not.There are several methods – separation of variables is one of them – that can be applied systematicallyto certain restricted classes of problems. We’ll develop several such methods, and specify preciselywhich classes of problems yield to which methods.

• If we’re faced – as we often are – with one of those problems that has a solution but for which none of thevarious methods of finding an exact solution applies, is there a way to compute a good approximationto the solution?

13

Page 14: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

14

Page 15: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Lecture 2

Separation of variables

In the previous lecture we found that integrating both sides of the equation

dv

dt= −32− 8v (2.1)

led to an integral

−8∫v(t) dt

whose value we couldn’t compute because v(t) was an unknown function of time. To avoid this problem, wepulled a rabbit out of the hat: dividing both sides by 32 + 8v and then doing a u-substitution u = v(t) ledto ∫

du

32 + 8u= −

∫dt.

The key point is that after the u-substitution the integral on the LHS now involves a fully-determined functionof u integrated over u, rather than an undetermined function of t integrated over t, so it can be computed(up to an as-yet undetermined constant of integration). After doing both integrals, we got an algebraicequation that we solved for v(t). The constant of integration was determined by imposing initial conditions.The final step, as always, was to check the solution.

2.1 Separable equations

Why did this trick work? More precisely, what was the specific feature of the problem

dv

dt= −32− 8v

that let us reduce the problem to integration after a simple transformation? And more importantly, can weidentify this same feature in other problems? If so, this transformation goes from being an isolated one-off“trick” to a special case of a general method. A trick to solve a single problem is cute but not particularlyuseful; a general method able to solve many problems is something worth talking about.

To see what’s going on let’s try the same trick on the equation

dv

dt= t− v.

We’ll quickly see this won’t work; the reason why will help us see what feature of 2.1 let us transform thatproblem successfully. Divide both sides by t− v, giving∫

1t− v

dv

dtdt =

∫dt.

15

Page 16: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Make the u-substitution u = v again on the LHS, giving∫du

t− u=∫

dt.

The LHS integral can’t be computed. Why not? Because it involves t as well as u. Because u = v(t) there’sa relationship between t and u through the function v, but because we don’t know v(t) we can’t determinehow t depends on u. We’re back to square one; we can’t do the integral until we’ve solved the problem, andwe can’t solve the problem without doing the integral.

But the failure of the trick on this problem1 highlights why it did work for the first problem. It workedfor 2.1 because the form of the equation was such that when we did the transformation, t disappeared entirelyfrom the LHS, leaving an integral entirely in terms of u. If there’s any “mixture” of t and u on either sideof the equation, we’re stuck with an integral we can’t compute. Expressions such as the sum t− u can’t bedisentangled in that way. However, with any product such as ut, or teu, or t2(u + 1), the stuff involving uand the stuff involving t can be disentangled by division.

For this division trick to work,then, the equation has to have a particular structure: given an equation

dv

dt= f(v, t),

I have to be able to factor the RHS f(v, t) into a product g(t)/h(v), one factor of which involves only t, theother of which involves only v. Let’s introduce a term for such problems: separable equations, and set upa formal definition.

Definition 2.1 A first-order ODE for y(x) of the form

dy

dx=g(x)h(y)

is called a separable equation.

2.1.1 Examples

• The equation y′ = y sinx is separable, because we can identify g(x) = sinx and h(y) = x−1.

• The equation y′ = y sinx+ 2 is not separable. There is no way to factor y sinx+ 2 into a product ofg(x) and 1/h(y).

• The equation y′ = y2 + 2xy is not separable. There is no way to factor y2 + 2xy into a product of g(x)and 1/h(y).

2.2 A procedure for solving separable equations

In principle, separable equations can always be solved by integration. In practice, there might be troubleactually computing a given integral, but the important thing is that a separable equation can always berewritten in terms of integrations. Here’s how.

To solve the ODEdy

dx=g(x)h(y)

,

multiply both sides by h(y) and integrate with respect to x:∫h(y(x))

dy

dxdx =

∫g(x) dx.

1We will be able to solve this problem by another method

16

Page 17: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Make the substitution u = y(x), in which case du = dydx dx so that∫

h(u) du =∫g(x) dx.

Define H(u) ≡∫h(u) du and G(x) ≡

∫g(x) dx. Note that we’ve defined u = y(x), then we can write

H(u) = H(y(x)). Doing the integrals and including a constant of integration gives us

H(y(x)) = G(x) + C.

This is an algebraic equation for y(x) in terms of x. In principle (there’s that phrase again – I’ll say morelater about the difference between “in principle” and “in practice” for such problems), you can usually solvethat algebraic equation for y(x) by inverting the function H.

2.2.1 Some shortcuts

There are a few simplifications we can make. Notice that we’re always doing the substitution u = y, andthat substitution always has the effect of replacing dy

dx dx with du. Notice also that at the end we’ll put yback in for u in H(u). Effectively, u is a dummy variable that we put in and take out again; we might aswell skip it and just work with y, writing the integral

∫h(u) du as

∫h(y) dy.

Notice also that the procedure looks like we’re “multiplying both sides by dx.” Of course dydx is not a

fraction and in general we can’t treat it as one, but as a mnemnonic device we can think of

dy

dx=

g(x)h(y)

(2.2)

dy =g(x)h(y)

dx (2.3)

h(y) dy = g(x) dx (2.4)∫h(y) dy =

∫g(x) dx. (2.5)

You get the same result as we got doing the transformation rigorously with a u-substitution. Feel freeto use this mnemnonic device – everyone uses it, and it’s perfectly OK for you to use it on a test – butalways remember that it’s a notational replacement for the actual u-substitution, and that“multiplying by differentials” is, in general, not mathematically valid. Keep in mind that aperfectly legitimate test question would be to ask you to justify the trick in terms of substitutions andtransformations.

2.2.2 Example

Solvedy

dx= −

(1 + y2

)x

with initial conditions y(2) = 1. This is separable, with h(y) = 11+y2 and g(x) = −x. Using the shortcuts

above,

dy

1 + y2= −x dx (2.6)∫

dy

1 + y2= −

∫x dx (2.7)

arctan y = −x2

2+ C. (2.8)

17

Page 18: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Solve for y by taking tangents of both sides,

y = tan(−x

2

2+ C

). (2.9)

That’s the solution to the ODE. To solve the IVP we use the initial conditions, plugging x = 2 and y(2) = 1into the equation to find

1 = tan (−2 + C) (2.10)C − 2 = arctan(1) (2.11)

C = arctan(1) + 2 (2.12)

4+ 2. (2.13)

Therefore

y(x) = tan(−x

2

2+π

4+ 2). (2.14)

Check

In the checking step, we’ll use the trig identity sec2 u = 1 + tan2 u and the differentiation rule

d

du(tanu) = sec2 u.

Here goes.

LHS =dy

dx= −2x

2sec2

(−x

2

2+π

4+ 2)

(2.15)

= −x(

1 + tan2

(−x

2

2+π

4+ 2))

(2.16)

= −x(1 + y2

)(2.17)

= RHS X (2.18)

Box 2.1 I should mention that I made a simple sign error in working this problem,and caught it in the checking stage.

18

Page 19: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Box 2.2 A COMMON MISTAKE: Many students will set this problem up cor-rectly, do the integrals correctly, then mess up the algebra. Here’s an exam solutionby an anonymous Texas Aggie:

dy

1 + y2= −x dx (2.19)∫

dy

1 + y2= −

∫x dx (2.20)

arctan y = −x2

2+ C (2.21)

y = − tanx2

2+ tanC. (2.22)

But tanC is just a constant, so we can just write it as C, giving us

y = − tanx2

2+ C. (2.23)

Now, apply the initial conditions:

1 = − tan 2 + C (2.24)C = 1 + tan 2 (2.25)

so

y(x) = − tanx2

2+ 1 + tan 2.

Check the “solution” to show that it is incorrect (the check gets messy, so it mighthelp to use Mathematica). Where did the Aggie go wrong? (Hint: It is a seriousconceptual error, not a simple arithmetic or algebra error)

2.3 Using Mathematica to assist separation of variables

19

Page 20: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Separation of variables with MathematicaSolve the equation

������dy

dx= -xI1 + y2M

with initial conditions y(2)=1. This is separable with gHxL = -x and hHyL = ������������1

1+y2.

Start by defining Mathematica functions for g and h. Note the underscores; they matter (in a way that will be explained later).

In[1]:= g@x_D = -x

Out[1]= -x

In[5]:= h@y_D = 1� H1 + y^2L

Out[5]= ���������������������1

y2 + 1

Define variables for use when we set the initial conditions.

In[34]:= x0 = 2

Out[34]= 2

In[35]:= y0 = 1

Out[35]= 1

Doing the integrals

In[3]:= G@x_D = Integrate@g@xD, xD

Out[3]= - ��������x2

2

In[6]:= H@y_D = Integrate@h@yD, yD

Out[6]= tan-1 HyL

Solving the algebraic equation

Solve for y as a function of x. Note the addition of the constantof integration.

In[17]:= algSoln@x_, C_D = Solve@H@yD � G@xD + C, yD

Out[17]= ::y ® tani

k

jjjjj �����1

2I2 C - x2 M

y

{

zzzzz>>

Use the result of the algebraic solution to define a function (a one-parameter family depending on C, actually) representing thesolution of the ODE.

In[18]:= odeSoln@x_, C_D = y �. algSoln@xD@@1DD

Out[18]= tani

k

jjjjj �����1

2I2 C - x2 M

y

{

zzzzz

Solving for C

Copyright

c©20

08Kev

inLo

ng

Page 21: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Solving for C

Plug the initial conditions into the ODE solution and solve for C.

In[36]:= cSoln = Solve@odeSoln@x0, CD � y0, CD

Solve::ifun :

Inverse functions are being used by Solve, so some solutions may not be found;use Reduce for complete solution information. �

Out[36]= ::C ® 2 + �����Π

4>>

Let’s return to the issue of the scary warning message later. For now, forge boldly ahead, substituting C=2+ ���Π

4 into the ODE

solution.

In[37]:= ivpSoln@x_D = odeSoln@xD �. cSoln@@1DD

Out[37]= tani

k

jjjjj �����1

2

i

kjjj2

i

kjjj2 + �����

Π

4

y

{zzz - x2 y

{zzz

y

{

zzzzz

Here’s what the solution looks like

In[38]:= Plot@ivpSoln@xD, 8x, 2, 6<D

Out[38]=3 4 5 6

-6

-4

-2

2

4

6

The solution blows up just below x=3. (You should calculate exactly where!) I’ve continued the graph after that point to highlightthe singularity, but the behavior of the solution to the IVP is undefined once it "blows up."

Checking the solution

You can use Mathematica to simplify checking the solution. Plug in, and let Mathematica do the calculus and algebra:

In[39]:= LHS = D@ivpSoln@xD, xD

Out[39]= -x sec2i

k

jjjjj �����1

2

i

kjjj2

i

kjjj2 + �����

Π

4

y

{zzz - x2 y

{zzz

y

{

zzzzz

In[40]:= RHS = -x H1 + ivpSoln@xD^2L

Out[40]= -xi

k

jjjjjtan2 i

k

jjjjj �����1

2

i

kjjj2

i

kjjj2 + �����

Π

4

y

{zzz - x2 y

{zzz

y

{

zzzzz + 1y

{

zzzzz

2 sepVar.nb

Copyright

c©20

08Kev

inLo

ng

Page 22: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

In[41]:= RHS � LHS

Out[41]= -xi

k

jjjjjtan2 i

k

jjjjj �����1

2

i

kjjj2

i

kjjj2 + �����

Π

4

y

{zzz - x2 y

{zzz

y

{

zzzzz + 1y

{

zzzzz � -x sec2i

k

jjjjj �����1

2

i

kjjj2

i

kjjj2 + �����

Π

4

y

{zzz - x2 y

{zzz

y

{

zzzzz

If you remember your trig identities, you’ll see that these are equal. When looking at complicated expressions, the FullSimplify[ ]function is amazingly useful...

In[42]:= FullSimplify@RHS � LHSD

Out[42]= True

...so the IVP solution is indeed a solution of the ODE. Now check that the IVP solution satisfies the IC:

In[43]:= ivpSoln@x0D � y0

Out[43]= True

...so our solution passes both the ODE check and the IC check. All done! Well, not quite.

About that warning message

OK, why the scary warning message??? It’s because the algebraic equation being solved is

In[44]:= odeSoln@x0, CD � y0

Out[44]= tani

k

jjjjj �����1

2H2 C - 4L

y

{

zzzzz � 1

which we can clean up a little with our friend FullSimplify[ ]

In[45]:= FullSimplify@odeSoln@x0, CD � y0D

Out[45]= tanH2 - CL + 1 � 0

which has multiple solutions because the tangent function is periodic (with period Π ). The solution C = ���Π

4+ 2 is the principal

value, but there are infinitely many other solutions obtained by adding to ���Π

4+ 2 any integer multiple of Π .

Taking into account the multiple solutions to the algebraic equation, the IVP solution is actually

In[46]:= -Tan@x^2�2 - 2 - Pi�4 + n PiD

Out[46]= tani

k

jjjjjj- ��������x2

2- n Р+ �����

Π

4+ 2

y

{

zzzzzz

where n is an integer. However, the tangent function is periodic with period Π, so the addition of an nΠ phase shift does not

matter.

Thus the scary warning about inverse function was a false alarm. This will usually be the case for problems of this sort, becausewe’ll be inverting a function to get C, and then putting the value of C right back into the function. You do things like this all thetime in hand calculations, but don’t always think about what’s happening.

Here’s the plot of the solution where we’ve used C = 143 Π + 2 + ���Π

4 instead of C = 2 + ���

Π

4. As expected, it is identical to the

solution with the principal value of C.

sepVar.nb 3

Copyright

c©20

08Kev

inLo

ng

Page 23: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

In[47]:= Plot@-Tan@x^2�2 - Pi�4 - 2 + 143 PiD, 8x, 2, 6<D

Out[47]=3 4 5 6

-6

-4

-2

2

4

6

OK, now we’re all done.

4 sepVar.nb

Copyright

c©20

08Kev

inLo

ng

Page 24: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

24

Page 25: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Lecture 3

Separation of variables, continued

A separable first-order differential equation (see 2.2 of Nagle, Saff, and Snider, and lecture #2 in my classnotes) has the form

dy

dx=g(x)h(y)

.

As you’ve seen, such an equation can be solved by collecting everything depending explicitly on x on oneside of an equation, everything depending on y to the other, then integrating both sides:∫

h(y) dy =∫g(x) dx.

If H(y) and G(x) are the antiderivatives of h(y) and g(x), respectively, then upon doing the integrals youget

H(y) = G(x) + C (3.1)

where C is a constant of integration. You can solve this algebraic equation for y(x), and then choose C sothat y(x) satisfies the initial conditions.

3.1 Using the initial conditions systematically

3.1.1 A shortcut to C

One observation is that when we have initial conditions y(x0) = y0, then we can substitute x0 and y0 in thealgebraic equation 3.1 to find

C = H(y0)−G(x0). (3.2)

So we don’t need to think about “solving for C,” because once you know the antiderivatives G and H youcan just compute it from equation 3.2.

Once you realize that C will always be given by C = H(y0)−G(x0), you can transform the solution asfollows:

H(y) = G(x) + C (3.3)H(y) = G(x) +H(y0)−G(x0) (3.4)

H(y)−H(y0) = G(x)−G(x0). (3.5)

25

Page 26: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

3.1.2 Using definite integrals to incorporate initial conditions

Suppose that instead of computing the indefinite integrals of both sides of the separated equation, youcomputed the definite integrals with limits chosen as follows. Use y and x for the upper limits and y0 andx0 for the lower limits on the integrals over y and x, respectively. Then∫ y

y0

h(y) dy =∫ x

x0

g(x) dx (3.6)

and by the fundamental theorem of calculus,

H(y)−H(y0) = G(x)−G(x0) (3.7)

where H and G are again the antiderivatives of h and g. This is exactly the same algebraic equation asobtained in the previous section after eliminating C. Therefore, by setting up a definite integral using theinitial conditions in the limits of integration you can bypass C altogether and immediately get an algebraicequation with the initial conditions built in.

How did I know to make the magic choice of limits for the definite integral? Here’s why this works. Let’sgo back to the differential equation, and multiply both sides by h(y) but do not take the usual shortcut with“multiplying differentials.” This gives

h(y)dy

dx= g(x). (3.8)

Now integrate both sides over x, from x0 to x,∫ x

x0

h(y(x))dy

dxdx =

∫ x

x0

g(x) dx. (3.9)

There are no suspect tricks or shortcuts here: we’ve taken an equation and integrated both sides over thesame variable with the same limits of integration. Provided the functions h and g are actually Riemannintegrable so that the integrals exist – more about that later – it’s all mathematically kosher.

Now, make the u-substitution u = y(x). As in lecture 2, we can replace dydx dx by du, and write the LHS

integral entirely in terms of u. However, one more thing happens: when you make a subsitution inside anintegral, you also transform the limits of integration. The original limits of integration were from x0 to x.Transforming the LHS integral from an integral over x to one over u means we must transform the limits ofintegration to u0 = y(x0) = y0 and u = y(x). Therefore, after substitution we get∫ y

y0

h(u) du =∫ x

x0

g(x) dx, (3.10)

or, invoking the fundamental theorem of calculus,

H(y)−H(y0) = G(x)−G(x0). (3.11)

3.1.3 Shortcut, version 2

In class, I introduced separation of variables using indefinite integration plus constants of integration becausethat’s the notation used in the book. 1 However, in practice, I nearly always use definite integration whensolving real problems, because it lets me include initial conditions automatically from the beginning withouthaving to introduce a temporary variable C which I must solve for given initial conditions.

1For some reason, every introductory DiffEq book I’ve seen does separation of variables using indefinite integrals andconstants of integration, rather than definite integrals with the initial conditions built into the limits. I don’t know why this isthe case. I was only taught the “C” method when I took differential equations, but somewhere (perhaps in a physics class?)picked up the “limits” method, and have preferred it ever since.

26

Page 27: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Box 3.1 A revised “shortcut” procedure for a separable problem is this:

1. Write the equation in separated form, “multiplying differentials,”

h(y) dy = g(x) dx. (3.12)

2. Take definite integrals of both sides, using the initial conditions for the lowerlimits and the variables y and x for the upper limits,∫ y

y0

h(y) dy =∫ x

x0

g(x) dx. (3.13)

3. Compute the integrals on both sides, obtaining

H(y)−H(y0) = G(x)−G(x0). (3.14)

4. Solve this equation for y. The initial conditions have been accounted for instep 2.

This is the procedure I use in practice – I often need to solve such equations in thecontext of “real-world” scientific problems – and I recommend it to you as well.

3.1.4 Example

Solvedy

dx= −x(1 + y2), y(2) = 1. (3.15)

We solved this equation before using indefinite integrals plus constants of integration. Let’s do it again usingdefinite integration.

1. Separate variables:dy

1 + y2= −x dx. (3.16)

2. Integrate both sides, using the initial conditions to set lower limits and the variables in the upperlimits: ∫ y

1

dy

1 + y2= −

∫ x

2

x dx. (3.17)

3. Compute the integrals:

arctan y |y1 = − x2

2

∣∣∣∣x2

(3.18)

arctan y − π

4= −x

2

2+ 2 (3.19)

4. Solve the algebraic equation for y(x):

y = tan(−x

2

2+ 2 +

π

4

). (3.20)

This is the same as the solution computed in lecture 2. As it’s already been checked, I won’t repeat thecheck of the solution here.

27

Page 28: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

3.2 Existence and uniqueness of solutions

Separation of variables reduces a separable first-order initial value problem to a problem of integrationfollowed by the solution of an algebraic equation,

H(y)−H(y0) = G(x)−G(x0). (3.21)

I’ll call this the algebraic subproblem. In practice, it’s not always possible to solve this equation for y.Furthermore, you need to be careful, because algebraic equations can have multiple solutions.

3.2.1 What if the algebraic subproblem has multiple solutions?

As usual, let’s start with a concrete example: solve the IVP

dy

dx=x

y, y(0) = y0. (3.22)

To avoid a zero denominator on the RHS, let’s specify that y0 6= 0. Separating variables gives∫ y

y0

y dy =∫ x

0

x dx, (3.23)

or, after integrating and cancelling factors of 12 all around,

y2 = y20 + x2. (3.24)

But when solving for y(x), we get two solutions,

y(x) = ±√y20 + x2. (3.25)

Both are solutions of the ODE, as we can quickly check:

LHS :dy

dx= ± 1

22x√y20 + x2

(3.26)

=x(

±√y20 + x2

) (3.27)

=x

y(3.28)

= RHS. X (3.29)

Are both of these legitimate solutions? To the ODE, yes. But when we go to the IVP, notice that only oneof the two solutions is consistent with the initial conditions.

• Solution #1: y =√y20 + x2. When x = 0, we have y(0) =

√y20 =| y0 |. This is consistent with the

initial conditions only when y0 is positive.

• Solution #2: y = −√y20 + x2. When x = 0, we have y(0) = −

√y20 = − | y0 |. This is consistent with

the initial conditions only when y0 is negative.

We can write this more compactly as

y(x) =

{√y20 + x2 y0 > 0

−√y20 + x2 y0 < 0.

(3.30)

28

Page 29: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

At the end of the day, we still end up with exactly one solution to the IVP, but we had to pass throughmultiple solutions to the algebraic equation – and therefore multiple solutions to the ODE – to get there.This occurred even though we’d included the initial conditions in the procedure for obtaining the algebraicequation 2. We had to choose after the fact one of those two solutions that was consistent with the initialconditions.

In case you’re thinking that this is just mathematical pedantry about a special case that will never arisein practice, recall that it is very common for algebraic equations to have multiple solutions – every quadraticequation has two solutions, for instance. Therefore, this situation where you need to choose one solutionfrom several will be the rule rather than the exception. The good news is that it’s usually easy to do, andas often as not you’ll automatically pick the right solution without consciously thinking about it.

In this example, the presence of multiple solutions to the algebraic subproblem did not mean that theinitial value problem had multiple solutions. We found that only one of the solutions to the algebraicsubproblem was consistent with the initial conditions. That will usually be the case. Next, we look at a casewhere the initial value problem has multiple solutions.

3.2.2 An initial value problem with multiple solutions

In the preceding example, we’d specified that y0 6= 0 to avoid a zero denominator on the RHS. Suppose we’dnot noticed the zero denominator and forged boldy forward taking y0 = 0. We’d expect something to gowrong... but what form will the disaster take?

Recall that the solutions to y′ = x/y are

y(x) = ±√y20 + x2 (3.31)

When y0 6= 0, only one of these two solution branches will be consistent with an initial condition y(0) = y0.But when y0 = 0, the solutions are

y(x) = ±√x2 (3.32)

= ±x (3.33)

and both of those solutions are consistent with the initial condition y(0) = 0.Just to make sure we’ve not gone off track, let’s check the two solutions. Both obviously satisfy the IC

y(0) = 0. As for the ODE, plugging the solution into the LHS gives

dy

dx= ±1, (3.34)

whereas the RHS givesx

y= ±x

x= ±1 (3.35)

so both solutions check.We have therefore found a case where an IVP has more than one solution! How is this possible? At the

initial point x = 0, y(0) = 0, the RHS of the equation is 0/0, therefore undefined. At that point, becausey obeys the ODE y′ = x

y , the slope y′ is also undefined. In this problem it is therefore possible to havemultiple curves, with different slopes, leaving the point (0, 0). In other words, we have multiple solutions tothis IVP. When we have only one solution, the jargon is to say the solution is unique. Multiple solutionsare sometimes referred to as non-unique.

This raises a horrifying possibility: will multiple solutions be the rule, rather than the exception, for IVPs.After all, multiple solutions are very common in algebraic equations; is that also the case for differentialequations? This is an important question: if you’ve done an IVP-based mathematical analysis to determine

2Here I used the “limits” procedure. The same issue would arise with the “C” procedure: after solving for C, the algebraicequation would still have two solutions.

29

Page 30: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

that your bridge doesn’t fall down or your motor doesn’t overheat, could you have overlooked someother “hidden” solution lurking out there, according to which your device does fail? For anengineer, overlooking a solution that is a failure mode would be an example of what’s known as a “career-limiting maneuver.”

There’s another, more positive, reason that the question of unique versus multiple solutions is of morethan academic interest. In physical systems, it’s often the case that interesting things happen at thetransition from unique to multiple solutions, where by “interesting,” I mean “critical to understandingthe behavior of the system, and having practical consequences.” Some examples of “interesting” behaviorrelated to multiple solutions include:

• Buckling of a beam: Below a critical load, there is only one solution, the unbent beam. Above thecritical load, there are multiple solutions: a buckled beam, and an unstable unbent beam.

• A phase transition in chemistry: a critical point on a phase diagram is a point at which a substance(e.g., water) can exist in multiple states. On one side of a critical point, multiple solutions might exist.For instance, above the boiling point of water there are two states: the stable vapor state, and theunstable superheated liquid state.

3.2.3 Existence and uniqueness of solutions

If the question of unique versus multiple solutions is so important, we’d better have a way of predictingwhen the issue of multiple solution arises. In general, determining the uniqueness, or even the existence, ofa solution to a mathematical problem can be extremely difficult. In this course, though, we’re restrictingourselves to initial value problems, and luckily, there is a theorem giving precise conditions under which anIVP can have non-unique solutions.

The example above should give us a hint that as long as the RHS is “well-behaved,” the solution willbe unique; we ran into trouble only when the RHS, and therefore the slope, became undefined due to azero denominator. The theorem makes precise what is meant by “well-behaved” in this context. Here’s thetheorem (quoting from Nagle, Saff, and Snider):

Theorem 3.1 Existence and Uniqueness of Solution to IVP

Given the initial value problemdy

dx= f(x, y), y(x0) = y0,

assume that f and ∂f/∂y are continuous in an open rectangle

R = {(x, y) such that a < x < b and c < y < d}

that contains the point (x0, y0). The the IVP has a unique solution in some interval x0 − δ < x < x0 + δwhere δ is a positive number.

Do not memorize the statement of this theorem. You can always look up the precise statement with openrectangles and δs and all that. If you end up becoming a theorist, you’ll need to know the precise statement.Here’s what the typical scientist or engineer should take away from the theorem:

Box 3.2 From the definition of the IVP, the slope of the solution at x = x0, y = y0will be f(x0, y0). You can run into non-uniqueness trouble at (x0, y0) when either

• the slope f(x, y) varies discontinuously with either x or y, or

• the partial derivative of the slope f(x, y) with respect to y varies discontinu-ously with x or y.

30

Page 31: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

In the one example of multiple solutions you’ve seen so far, the source of the non-uniqueness was that theslope was undefined due to a zero denominator when y → 0. The function f(x, y) = x/y is not continuousat y = 0, so the theorem’s requirements for a unique solution aren’t met. Thus a non-unique solution ispossible when the initial value of y is zero.

You’ve not yet seen an example of the second case where the uniqueness theorem’s conditions are violated:when the partial derivative of the slope with respect to y, ∂f

∂y , with respect to varies discontinuously. We’llcome back to that in a subsequent lecture. For now, I’ll leave you with a puzzle (to be answered later)

• Why does a discontinuity in ∂f∂y lead to non-uniqueness, but not a discontinuity in ∂f

∂x ?

31

Page 32: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

32

Page 33: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Lecture 4

Linear first-order equations

Newton’s Law of Cooling determining the temperature T as a function of time t is

dT

dt= −k (T − Ta) , (4.1)

where k is a cooling rate constant and Ta is the ambient temperature. Additionally we’re given initialconditions T (t0) = T0.

The equation is separable, and so∫ T

T0

dT

T − Ta= −k

∫ t

t0

dt (4.2)

logT − Ta

T0 − Ta= −k (t− t0) (4.3)

T − Ta

T0 − Ta= e−k(t−t0) (4.4)

T (t) = Ta + (T0 − Ta) e−k(t−t0) (4.5)

I’ll leave it to you to check the solution.Equations similar to this arise in many contexts, for example, they are used to determine:

• The velocity v of a ball falling under gravity subject to linear air resistance

mdv

dt= −k

(v +

mg

k

)(4.6)

• The charge Q on a capacitor charging in an RC circuit given an imposed voltage Vp

dQ

dt= − Q

RC+ Vp (4.7)

• The intensity I(x) of a beam of radiation in a medium with absorbtivity κ and emissivity j

dI

dx= −κI + j (4.8)

and numerous other problems throughout science and engineering. Structurally, they’re all exactly thesame equation; only the names and meanings of the symbols change. Change “ambient temperature” to“capacitance times imposed voltage“ and “cooling rate constant” to “1/RC” and the work you’ve donein solving – and more importantly, understanding – Newton’s law of cooling immediately transfers to theproblem of charging of a capacitor.

33

Page 34: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

4.1 A standard notation for first-order linear equations

Because all these problems have the same structure we can define a common notation to work with, andthen refer all “real-world” problems back to this standard form. The standard form is

dy

dt+ py = q (4.9)

where p and q are constants. All of the above problems can be written in this form, for example, to getNewton’s law of cooling we’d take y = T , x = t, p = k, and q = kTa. This type of equation is calledfirst-order linear with constant coefficients. The word “linear” means the following: the independentvariable y and its derivatives appear only to the zeroth or first power. To remember why this form is called“linear,” notice that if you think of the (y, y′) plane, then the equation

dy

dx+ py = q

is the equation of a line in that plane. Note that this doesn’t mean the curve defined by the solution y(x)will be a line!

All of the above problems can be written in this form, for example, to get Newton’s law of cooling we’dtake y = T , x = t, p = k, and q = kTa.

When p and q are constants, we can always solve 4.9 by separation of variables. However there areproblems where we might want p and/or q to be functions of x; for example, the ambient temperature Ta

in a building could vary with time of day, or the imposed voltage Vp could be AC rather than DC. So let’sdefine the more general form in which the coefficients p and q can be functions of x (not functions of y).

Box 4.1 The standard form of a first-order linear ordinary differential equa-tion is

dy

dx+ p(x)y = q(x)

Notice that this equation is not separable, except in three special cases:

• p and q are constant,

• p(x) is not constant, but q = 0,

• q(x) is not constant, but p = 0.

However, we’ll soon see that it’s always possible to find a transformation that will let us convert a first-orderlinear ODE to a separable equation.

Examples of linear and nonlinear equations

Linear differential equations have many special properties, and it’s important to be able to identify when anequation is or isn’t linear. Here are some examples.

1. x dydx + exy = sinx is linear because y and y′ appear to the first power in the terms on the LHS and to

the zeroth power on the RHS, and do not appear in any other ways.

2.(

dydx

)2

+ y = 1 is nonlinear because y′ appears to the second power.

3. dydx + ey = x is nonlinear because y appears inside an exponential function.

4. dydx = xy−1 is nonlinear because y appears to the −1 power.

5.√

1 + x2 dydx +

√xy = tanx is linear because y and y′ appear to the zeroth and first powers only.

Notice that a linear equation can contain any crazy function of the independent variable x; it’s the way inwhich the equation depends on y and y′ that determines whether the equation is linear.

34

Page 35: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

4.2 Solving first-order linear equations

Here’s what we’ll do: we’re going to introduce an undetermined function µ(x) that will be used to transformthe equation into a “nice” equation that can be integrated directly. The requirement that the resultingequation can be integrated will lead to a differential equation for µ(x). This second equation is separableand therefore easily solved.

Here goes. We will assume there is a function µ(x) such that µ(x) times the original equation y′+p(x)y =q(x), i.e.,

µ(x)y′ + µ(x)p(x)y = µ(x)q(x) (4.10)

can be rewritten asd

dx[µ(x)y] = µ(x)q(x). (4.11)

The LHS contains y only inside a derivative, and the RHS depends only on x. Therefore can solve for y byintegrating both sides over x:∫ x

x0

d

dx[µ(x)y] dx =

∫ x

x0

µ(x)q(x) dx, (4.12)

µ(x)y(x)− µ(x0)y(x0) =∫ x

x0

µ(x)q(x) dx, (4.13)

µ(x)y(x) = µ(x0)y(x0) +∫ x

x0

µ(x)q(x) dx, (4.14)

y(x) =1

µ(x)

[µ(x0)y(x0) +

∫ x

x0

µ(x)q(x) dx]. (4.15)

This is a great result: a formula you can use to crank out the solution y(x)! But it will only work if µ(x)exists. Does such a “magical” µ(x) exist, as we’ve assumed? And if so, how do we find it?

The initial assumption is that

µ(x)y′ + µ(x)p(x)y =d

dx[µ(x)y] . (4.16)

Expanding the derivative on the RHS gives

µy′ + µpy = µ′y + µy′, (4.17)

and so

µpy = µ′y (4.18)µp = µ′ (4.19)

(4.20)

which is a separable equation. Solving this last equation for µ is relatively easy:∫dµ

µ=

∫p(x) dx (4.21)

logµ =∫p(x) dx (4.22)

µ = eR

p(x) dx. (4.23)(4.24)

The function µ(x) is called an integrating factor, because multiplying both sides of the equation by it givesan equation we can solve by integration.

35

Page 36: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Question

Can you explain why I didn’t need to worry about initial conditions or constants of integration when solvingthe equation for µ?

4.2.1 Example

Solve the equationdy

dx+ 3y = sinx (4.25)

with y(0) = 1. You’re likely to encounter such an equation at some point: A model of an RC circuit withan AC driving voltage will give an equation of this form.

The equation is in standard form with p(x) = 3 and q(x) = sinx. Therefore the integrating factor µ is

µ(x) = eR

p(x) dx (4.26)

µ(x) = eR

3 dx (4.27)µ(x) = e3x. (4.28)

With µ = e3x and q = sinx, equation 4.11 for y becomes

d

dx

[e3xy

]= e3x sinx (4.29)

so ∫ x

0

d

dx

[e3xy

]dx =

∫ x

0

e3x sinx dx (4.30)

e3xy(x)− 1 =∫ x

0

e3x sinx dx (4.31)

y(x) = e−3x

[1 +

∫ x

0

e3x sinx dx]

(4.32)

The integral inside the brackets is∫ x

0

e3x sinx dx =110− e3x

10(cosx− 3 sinx) (4.33)

soy(x) =

1110e−3x − 1

10(cosx− 3 sinx) (4.34)

Check

Compute the two terms on the RHS:

dy

dx= −33

10e−3x +

110

(sinx+ 3 cosx) (4.35)

and3y =

3310e3x − 1

10(3 cosx− 9 sinx) . (4.36)

When added to form y′ + 3y, the exponential and cosine terms cancel, leaving

dy

dx+ 3x =

110

(1 + 9) sinx (4.37)

dy

dx+ 3x = sinx = LHS.X (4.38)

36

Page 37: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

4.2.2 Example

Solve the IVPdy

dx+ 2xy = 2xe−x2

, y(2) = π. (4.39)

In standard form, p(x) = 2x and q(x) = x. The integrating factor is

µ(x) = eR

2x dx (4.40)

= ex2. (4.41)

To solve the IVP, integrate both sides of

d

dx[µ(x)y(x)] = µ(x)q(x) (4.42)

from x = 2 to x, ∫ x

2

d

dx[µ(x)y(x)] dx =

∫ x

2

µ(x)q(x) dx (4.43)

µ(x)y(x)− µ(2)y(2) =∫ x

2

µ(x)q(x) dx (4.44)

ex2y(x) = e2

2π +

∫ x

2

2xex2e−x2

dx (4.45)

ex2y(x) = e4π + 2

∫ x

2

x dx (4.46)

ex2y(x) = e4π + x2 − 4 (4.47)

and finallyy(x) = e−x2 [

e4π + x2 − 4]. (4.48)

Check

Plug y(x) into LHS:

LHS first term: y′ = −2xe−x2 [e4π + x2 − 4

]+ e−x2

[0 + 2x+ 0] (4.49)

LHS second term: 2xy = 2xe−x2 [e4π + x2 − 4

](4.50)

When we add these two expressions to form the LHS y′ + 2xy, the boxed terms cancel leaving us with

dy

dx+ 2xy = 2xe−x2

(4.51)

LHS = RHSX (4.52)

Finally, check the initial conditions:

y(2) = e−22 [e4π + 22 − 4

](4.53)

= e−4[e4π + 4− 4

](4.54)

= e−4e4π (4.55)= πX (4.56)

37

Page 38: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Box 4.2 A COMMON MISTAKE: The preceding example used the function ex2.

Be careful about notation when working with this function. The notation ex2means

e(x2), not (ex)2. The difference is important: they are very different functions.

If you don’t see why ex2and (ex)2 are different, try the following calculations:

• Plot the two functions.

• Show that (ex)2 = e2x.

• Find a value of x for which ex2and (ex)2 take on different values.

• Find a value of x for which ex2and (ex)2 take on the same values.

• For how many values of x are ex2and (ex)2 equal? What are those values?

(Hint: use the identity (ex)2 = e2x.)

4.3 Summary

First-order linear equations are a very important subclass of differential equations. They show up everywhere,in branches of science from electric circuits to radiation physics. It’s convenient that such a widely useful typeof equation also turns out to be relatively easy to solve: there is a straightforward procedure for finding thesolution to any first-order equation. The procedure involves doing two integrals: one to get the integratingfactor µ(x) = exp(

∫p(x) dx), and the second an integral over µ(x)q(x) to get the solution.

Box 4.3 When you’ve identified a problem as a first-order linear equation, followthis procedure:

1. Put the equation in standard form

dy

dx+ p(y)y = q(y), y(x0) = y0 (4.57)

2. Compute the integrating factor

µ(x) = eR

p(x) dx. (4.58)

3. Solve the equationd

dx[µ(x)y(x)] = µ(x)q(x) (4.59)

for y(x) by integrating both sides. To incorporate initial conditions, either(a) use the initial value x0 in the lower limit of integration, or (b), introducea constant of integration to be determined through the initial conditions.

4. The solution will be

y(x) =1

µ(x)

[µ(x0)y(x0) +

∫ x

x0

µ(x)q(x) dx.]

(4.60)

However, rather than memorizing this equation I usually find it easier toremember the equation from step 3 and work from there.

38

Page 39: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

4.4 Using Mathematica for first-order linear equations

Because there’s a well-defined procedure for solving first-order linear equations, these problems are well-suited to automated solution by computer. In this section I’ll show how to use Mathematica to carry outthe procedure described above.

39

Page 40: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Solve y ’ + 3 y = sin x with y H0L = 1 with Mathematica

� Define p and q, and compute the integrating factor

To put the equation in standard form y’ + pHxL y = qHxL we set pHxL = 3and qHxL = sin x.

In[9]:= p@x_D = 3

Out[9]= 3

In[10]:= q@x_D = Sin@xD

Out[10]= sinHxL

The integrating factor is Μ = eÙ pHxL dx .

In[11]:= mu@x_D = Exp@Integrate@p@xD, xDD

Out[11]= ã3 x

� Define values for the initial conditions x0 and y0

In[12]:= x0 = 0

Out[12]= 0

In[13]:= y0 = 1

Out[13]= 1

� Use the standard solution formula to compute yHxL

The solution is

yHxL = ����������1

ΜHxLBΜHx0L yHx0L + Ùx0

xΜHxL qHxL â xF

which is entered into Mathematica as

In[14]:= y@x_D = 1� mu@xD Hmu@x0D y0 + Integrate@mu@xD q@xD, 8x, x0, x<DL

Out[14]= ã-3 xi

k

jjjjj ���������1

10I1 - ã3 x HcosHxL - 3 sinHxLLM + 1

y

{

zzzzz

Running Expand[ ] multiplies everything out

In[15]:= Expand@y@xDD

Out[15]= - ���������������������cosHxL

10+ ��������������������������

11 ã-3 x

10+ �������������������������

3 sinHxL

10

This is the same answer obtained by hand previously.

� Check the solution

Plug yHxL into the LHS, and compare to the RHS.

Copyright

c©20

08Kev

inLo

ng

Page 41: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

In[17]:= LHS = FullSimplify@D@y@xD, xD + p@xD y@xDD

Out[17]= sinHxL

In[21]:= RHS = q@xD

Out[21]= sinHxL

These are the same,so LHS=RHS and the equation checks

In[22]:= LHS � RHS

Out[22]= True

Verify the solution satisfies the initial conditions

In[20]:= y@x0D � y0

Out[20]= True

All done!

2 FirstOrderLinear.nb

Copyright

c©20

08Kev

inLo

ng

Page 42: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

42

Page 43: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Copyright

c©20

08Kev

inLo

ng

Appendix A

An introduction to Mathematica

Mathematica is a software package with powerful capabilities for symbolic computation. This appendix givesan overview of its basic features.

43

Page 44: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Numbers

� Numbers are recorded as exact expressions, not decimal approximations

524�12

�������������131

3

Sqrt@2D

"#####2

� The N[] operator computes a numerical value to a requested precision

N@131�3D

43.6667

N@Sqrt@2DD

1.41421

N@Sqrt@2D, 10D

1.414213562

N@Sqrt@2D, 50D

1.4142135623730950488016887242096980785696718753769

� The number e is written with a capital E

E^H2 xL

ã2 x

N@ED

2.71828

N@E, 50D

2.7182818284590452353602874713526624977572470937000

� The number Π is written Pi

N@Pi, 500D

3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808�

65132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659�

33446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174�

88152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611�

73819326117931051185480744623799627495673518857527248912279381830119491

� Operations will be done exactly when possible

Copyright

c©20

08Kev

inLo

ng

Page 45: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Operations will be done exactly when possible

Cos@Pi�3D

�����1

2

Log@E^3D

3

� If there’s no simpler representation, a number will be left as-is

Cos@Sqrt@5DD

cosK"#####5 O

but you can always get a numerical value later

N@Cos@Sqrt@5DDD

-0.617273

Basic syntax for algebraic operations

� Use "*" or blank space or parentheses for multiplication

The following three ways of writing 7 x �!!!!!

y are all equivalent.

7*x*Sqrt@yD

7 x "#####y

7 x Sqrt@yD

7 x "#####y

7 Hx HSqrt@yDLL

7 x "#####y

� A common error is to leave out the space

With the space properly inserted between x and y, HxyL � y = x as it should.

Hx yL �y

x

With the space left out by mistake, Mathematica thinks you’ve defined a new variable xy, and so you don’t get the answer youexpect:

2 intro.nb

Copyright

c©20

08Kev

inLo

ng

Page 46: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

HxyL �y

���������xy

y

� Use the caret ("^") for powers

E^y

ãy

y^H1 + 4 tL

y4 t+1

� Use the slash "/" for division

24 y^2�8

3 y2

� Be careful with trig notation

Write cos2 y as Hcos yL2 .

N@Cos^2@Pi�3DD H* doesn’t work like you think it will *L

[email protected]

N@Cos@Pi�3D^2D

0.25

Write inverse trig functions as ArcTan[y] instead of Tan^(-1)[y]

Tan^H-1L@1D

TanH-1L@1D

ArcTan@1D

�����Π

4

Defining your own functionsf@x_D = x Sin@xD �10 + Sin@2 xD � H1 + x^4L

���������1

10x sinHxL + �������������������������

sinH2 xL

x4 + 1

Notice the use of square brackets (f[x] instead of f(x)) for function notation. Notice that the built-in function Sin[x] starts with acapital letter.

The underscore after the argument name is important; it lets "x" be replaced by any other expression.

Troubleshooting basic problems with functions

intro.nb 3

Copyright

c©20

08Kev

inLo

ng

Page 47: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Troubleshooting basic problems with functions

� Leaving out the underscore

g@xD = 2 x Sin@xD

2 x sinHxL

looks OK so far, but then

g@2D

gH2L

Mathematica doesn’t know how to evaluate g[2], because g has been defined for the symbol x only.

� Using parentheses instead of square brackets

g HxL = 2 x Sin@xD

Set::write : Tag Times in g x is Protected. �

2 x sinHxL

This happens because g(x) is interpreted as "g times x" instead of "g of x," and Mathematica then thinks you’re trying to redefinewhat multiplication means! The error message means that the definition of the multiplication operator is write-protected. The fixis to use square brackets like you’re supposed to

Plotting functionsI’ll type f[x] here to remind myself what its definition is:

f@xD

���������1

10x sinHxL + �������������������������

sinH2 xL

x4 + 1

Now I’ll plot it:

Plot@f@xD, 8x, -10, 10<D

-10 -5 5 10

-0.5

0.5

I can plot two or more functions on the same figure

4 intro.nb

Copyright

c©20

08Kev

inLo

ng

Page 48: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

g@x_D = 4 x^2 Exp@-x^2D

4 ã-x2x2

Plot@8f@xD, g@xD<, 8x, -10, 10<D

-10 -5 5 10

-0.5

0.5

1.0

1.5

Here’s a plot of 3 functions.

h@t_D = 1�4 Cos@5 tD + Sin@tD

�����1

4cosH5 tL + sinHtL

Plot@8f@xD, g@xD, h@xD<, 8x, -10, 10<D

-10 -5 5 10

-1.0

-0.5

0.5

1.0

1.5

See the documentation for more information on setting plot options such as axis labels.

DifferentiationD@Sin@tD, tD

cosHtL

D@t Exp@-tD Cos@tD^2 , tD

ã-t cos2 HtL - ã-t t cos2 HtL - 2 ã-t t sinHtL cosHtL

Derivatives of unknown functions will be left in symbolic form.

intro.nb 5

Copyright

c©20

08Kev

inLo

ng

Page 49: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

D@t^2 p@tD, tD

p¢ HtL t2 + 2 pHtL t

We can differentiate the functions we’ve defined

D@f@tD, tD

- ��������������������������������������4 sinH2 tL t3

Ht4 + 1L2

+ ���������1

10cosHtL t + �������������������������������

2 cosH2 tL

t4 + 1+ ������������������

sinHtL

10

or alternatively,

f’@tD

- ��������������������������������������4 sinH2 tL t3

Ht4 + 1L2

+ ���������1

10cosHtL t + �������������������������������

2 cosH2 tL

t4 + 1+ ������������������

sinHtL

10

Integration

� Indefinite integrals can be done symbolically when possible

Integrate@s^2 Sin@sD, sD

2 s sinHsL - Is2 - 2M cosHsL

Integrate@q’@tD, tD

qHtL

Mathematica can do some integrals you really don’t want to do by hand

Integrate@1� Hx^7 + 2L, xD

��������������������1

7 26�7

i

k

jjjjjjjjjj-2 sin

i

kjjj �����

Π

7

y

{zzz tan-1

i

k

jjjjjjjjcot

i

kjjj �����

Π

7

y

{zzz - ����������������������������

x cscI ����Π

7M

�!!!!!2

7

y

{

zzzzzzzz+ logI26�7 x + 2M - cos

i

kjjj �����

Π

7

y

{zzz log

i

kjjj-25�7 x2 + 2 26�7 cos

i

kjjj �����

Π

7

y

{zzz x - 2

y

{zzz +

logi

k

jjjjj-25�7 x2 - 2 26�7 sini

k

jjjjj �����������3 Π

14

y

{

zzzzz x - 2y

{

zzzzz sini

k

jjjjj �����������3 Π

14

y

{

zzzzz - logi

kjjj-25�7 x2 + 2 26�7 sin

i

kjjj ���������

Π

14

y

{zzz x - 2

y

{zzz sin

i

kjjj ���������

Π

14

y

{zzz +

2 tan-1

i

k

jjjjjjjjjj��������������������������������

secJ ��������3 Π

14N x

�!!!!!2

7+ tan

i

k

jjjjj �����������3 Π

14

y

{

zzzzz

y

{

zzzzzzzzzzcos

i

k

jjjjj �����������3 Π

14

y

{

zzzzz + 2 tan-1i

k

jjjjjjjj������������������������������

x secI ������Π

14M

�!!!!!2

7- tan

i

kjjj ���������

Π

14

y

{zzz

y

{

zzzzzzzzcos

i

kjjj ���������

Π

14

y

{zzz

y

{

zzzzzzzzzz

Integrate@Hx^5 + 3 xL Exp@xD HCos@2 xD + 5 Sin@4 xDL, xD

���������������������������������������������������1

75 429 903 125 ãx I24 137 569 I625 x5 + 1875 x4 - 5500 x3 + 2100 x2 + 6795 x - 1683M cosH2 xL -

62 500 I1 419 857 x5 - 835 210 x4 - 1 277 380 x3 + 1 040 400 x2 + 4 465 611 x - 647 766M cosH4 xL +

48 275 138 I625 x5 - 1250 x4 - 500 x3 + 3600 x2 - 405 x - 1278M sinH2 xL +

15 625 I1 419 857 x5 + 6 264 075 x4 - 4 618 220 x3 - 2 791 740 x2 + 6 546 411 x + 3 817 845M sinH4 xLM

Not even the most sadistic Calculus II professor would assign such evil integrals, but Mathematica makes short work of them.

� Some integrals can’t be done in closed form

6 intro.nb

Copyright

c©20

08Kev

inLo

ng

Page 50: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Some integrals can’t be done in closed form

The great 19th century mathematician Joseph Liouville proved that there are certain integrals that can’t be computed exactlythrough a finite number of elementary operations (aka "in closed form" or "in finite terms". If Mathematica encounters one ofthese, it will simply return the integral left undone. You won’t see any such integrals in 3350 (if you see one in the real world or inanother course, please feel free to ask me about methods of computing approximations to the integral)

Integrate@Sin@Exp@Sqrt@xD � H1 + xLD + xD, xD

à sini

k

jjjjjx + �����������

"######x

x+1

y

{

zzzzz â x

� Some integrals will return unfamiliar-looking functions

In later courses, you’ll learn about "special functions," which are functions somewhat more complicated to analyze and computethan the familiar functions such as trig functions, the exponential, and the logarithm. Many real-world integrals and differentialequations have solutions that are special functions. I won’t ask you to do much with them in 3350 other than to ask you to recog-nize one when you see one.

One of the simplest special functions is the "error function," or "erf." It rears its head when integrating the function e-x2.

Integrate@Exp@-x^2D, xD

�����1

2

�!!!!!!Π erfHxL

Here’s the plot of erf HxL on the interval [0,10].

Plot@Erf@xD, 8x, 0, 3<D

0.5 1.0 1.5 2.0 2.5 3.0

0.2

0.4

0.6

0.8

1.0

You can look up special functions in the Mathematica documentation. Again, in 3350 we won’t do much at all with them, butexpect to see a problem or two (on a project or a take-home test) where Mathematica spits one out at you as the answer. In suchcases, you’ll be expected to know how to identify and plot the special functions you encounter.

Solving algebraic equations

� You can solve algebraic equations

Notice the double-equals sign ("==") instead of "=." This is important.

intro.nb 7

Copyright

c©20

08Kev

inLo

ng

Page 51: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Solve@2 x + 7 � 3, xD

88x ® -2<<

Here’s what happens if you use "=" instead of "==".

Solve@2 x + 7 = 3, xD H* DOH! *L

Set::write : Tag Plus in 2 x + 7 is Protected. �

Solve::eqf : 3 is not a well-formed equation. �

Solve@3, xD

� You can solve equations involving functions

Solve@Log@3 x + 4D � y, xD

::x ® �����1

3H-4 + ãyL>>

� Equations can have multiple solutions

Solutions are returned as lists (in curly braces)

Solve@x^2 + 3 x + 2 � 0, xD

88x ® -2<, 8x ® -1<<

Solve@a Log@t^2 + 5 t + 4D � c, tD

::t ® �����1

2

i

k

jjjj-"#####################

9 + 4 ��c

a - 5y

{

zzzz>, :t ® �����1

2

i

k

jjjj"#####################

9 + 4 ��c

a - 5y

{

zzzz>>

Given an equations requiring theuse of a multi-valued inverse function, such as sin x = ���1

2, Mathematica will return the principal

value and make a note that other solutions exist.

� Solutions involving inverse functions can have multiple values

Solve@Sin@xD � 1�2, xD

Solve::ifun :Inverse functions are being used by Solve, so some solutions may not be found;use Reduce for complete solution information. �

::x ® �����Π

6>>

You don’t ordinarily think of the logarithm as being a multi-valued function. As a function of a real variable, it is single-valued.As a function of a complex variable, however, it is multi-valued. Mathematica warns about that.

Solve@Exp@xD � y, xD

Solve::ifun :Inverse functions are being used by Solve, so some solutions may not be found;use Reduce for complete solution information. �

88x ® logHyL<<

� Some algebraic equations can’t be solved in finite numbers of simple operations

8 intro.nb

Copyright

c©20

08Kev

inLo

ng

Page 52: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

Some algebraic equations can’t be solved in finite numbers of simple operations

Some algebraic equations can’t be solved in "closed form." This means there’s no formula for the solution that can be written interms of a finite number of elementary operations. An example is "Kepler’s Equation," y + a sin y = x, where 0 < a < 1, whichcan’t be solved for y as a closed-form formula for y as a function of x and a. (There is in fact an exact formula for the solution to

this problem, but it’s an infinite series).

As is the case when you request an integral that has no closed-form solution, Mathematica will simply tell you that it can’t solvethe problem.

Solve@x + 1�2 Sin@xD == y, xD

Solve::tdep : The equations appear to involve thevariables to be solved for in an essentially non-algebraic way. �

SolveBx + ��������������������sinHxL

2� y, xF

Some differential equations lead to such "impossible" algebraic equations, so you’ll occasionally encounter such an equation in3350. In such a case, the solution to the DE is called an "implicit solution." In all such cases, I’ll give you a heads up that youshouldn’t try to solve the algebraic equation; it’s OK to just write it down.

The question of which algebraic equations, integrals, or differential equations can be solved in closed form is dealt with in abranch of mathematics called abstract algebra, which is beyond the level of this course. The fact that many (most!) problems arenot solveable in a finite number of operations is why we’ll have to develop methods for solving problems approximately.

� Simultaneous equations

You can solve two equations in two unknowns...

Solve@8x + y � 1, 2 x + 3 y � -2<, 8x, y<D

88x ® 5, y ® -4<<

..or three equations in three unknowns, and so on.

Solve@84 A + 2 B + 11 C � 0, A + 7 B + 3 C � 1, A + B � -1<, 8A, B, C<D

::A ® - ���������41

36, B ® ���������

5

36, C ® ���������

7

18>>

We will be solving systems of equations very often when we get to linear second-order equations.

Summary

� You can use Mathematica to automate essentially all of the tasks arising in the method of separation of variables:

- You can do integrals symbolically

- You can solve algebraic equations symbolically

intro.nb 9

Copyright

c©20

08Kev

inLo

ng

Page 53: Higher Mathematics for Scientists and Engineers …klong/3350-Fall08/lecNotes.pdfHigher Mathematics for Scientists and Engineers Math 3350 Lecture Notes Kevin Long Texas Tech University

� Watch out for common errors

If you get an error message, please check this document first to see if you’ve made one of the common errors.

� Many problems in mathematics (algebraic equations, integrals, and differential equations) have no "closed-form" solution

-- "no closed form" means "can’t be expressed in a finite number of elementary operations", i.e., sines, exponentials, etc.

-- Many real-world engineering problems can’t be solved in closed form. -- In such cases, we’ll need to resort to approximate methods. In this course, you’ll learn some simple methods for computingapproximate numerical solutions to IVPs.

10 intro.nb

Copyright

c©20

08Kev

inLo

ng