Thursday, May 30, 2013

Growth and decay

One word problem you will very commonly face in MA2051 is that of growth and decay! These problems all take on a very similar form and therefore can be solved with ease once you get used to them.

These problems are often about chemical half-lives, so let's do an example like that.

The rate of decay of a particular material varies proportionately to the amount present. After 2 years, 30% of the material remains. What is the equation that models the decay of this material, and what is the half-life of this material?

The first important bit of material that this problem gives is that this is a decay equation, not a growth equation. This means that the amount of material is decreasing, not increasing, as it might if this were a population of bacteria, for example. This means that there's a negative sign out front!

Then it tells that the rate is proportionate to the amount. This means that the change, or dy/dt, is equal to the amount, or y, times some constant, which we can call k.

dy/dt = -ky

That's the equation that needs to be solved! And that will always be the equation when we're dealing with decay. If we're dealing with growth, it's exactly the same except without the negative sign.

This is a separable equation. We covered separable equations a couple of posts ago, but we'll go through it now too. We must separate the y's from the t's. This means dividing both sides by y and multiplying both sides by dt, which results in:

dy/y = -kdt

Note that all y's now appear on the left side of the equals sign, and all t's are on the right. Now integrate both sides!

ln(y) = -kt + c

Solve for y:

eln(y) = e-kt + c
y = ece-kt
y = Ce-kt Where C = the positive constant ec

Okay! The differential equation has been solved. Now the only tricky part that is left is interpreting the other bits of information that the word problem gave us: an initial value, and the fact that they're searching for a half life.

Notice this: We have two unknown constants that must be found (C and k) but we only have one bit of information - the amount left after 2 years. That shouldn't usually be enough to find two constants. But! There is something else we can conclude just based on the type of problem this is. Watch and see!

We can start by defining the amount of material present at time 0 as being 100% of the material.

100 = Ce-k*0 - one equation

And we are given that 30% of the original material is left after 2 years. Really, we can choose any number so long as it is 30% of the original amount. We chose 100 up above, so now we have to use 30.

30 = Ce-k*2 - a second equation! Since we have 2 variables, 2 equations is exactly what we need in order to solve for both C and k.

Start with the first equation; it's easier because of the 0.

100 = Ce-k*0
100 = C

Now sub into the second equation:

30 = Ce-k*2
30 = 100e-2k
.3 = e-2k
ln(.3) = ln(e-2k)
ln(.3) = -2k*ln(e)
ln(.3) = -2k
-ln(.3)/2 = k

Since all natural logs of numbers between 0 and 1 are negative, k will always be a positive constant.

So now we have the answer to the first question of our challenge: the equation that models the material's decay. Subbing in for C and k, that equation is:

y = 100eln(.3)t/2

Now we need to find the half life.

The half life, by definition, is the time it takes for the material to divide in half. This isn't hard to find: we must simply sub in for y with an amount that is 50% of the original amount. Recall that above, we chose 100 as being the original amount. Now, we must use 50.

50 = 100eln(.3)t/2

And solve for t!

1/2 = eln(.e)t/2
ln(1/2) = ln(eln(.3)t/2)
ln(1) - ln(2) = ln(.3)t/2*ln(e)
0 - ln(2) = ln(.3)t/2
-2ln(2)/ln(.3) = t

And that's the half life!

In fact, we just solved for the half life very formally, but the half life will always follow the formula ln(2)/k!

And that's decay! I don't think I'll do an explicit growth problem here because nothing changes very significantly. You just leave out the negative sign in all of your calculations.

Happy calculating,
Rachel

Sunday, May 26, 2013

Calculus topics from before MA2051 that you'll need - integration by parts and partial fraction decomposition

Aside from remembering how to do various derivatives and integrals, in MA2051 there are some calculus topics you need to remember from earlier classes. The two that seem to give people the most grief are integration by parts and partial fraction decomposition.

Integration by parts: This is a method you need to use when you have two terms multiplied together and one is not the derivative of the other (if it were, you could use U substitution). An example is ∫xsin(x)dx.

The formula for this situation is: ∫udv = uv - ∫vdu. So you have to assign one term in the original integral to be u, and another to be dv. You'll have to then derive to find du and integrate to find v, then plug into the formula.

The piece of advice I always give is this: Pick u to be something that gets simpler when you take the derivative. For example, x becomes 1. A counterexample, sin(x) just becomes cos(x) - no easier to work with.

Let's do out an example problem - the one mentioned before, ∫xsin(x)dx. We can see, using the tip given above, that x should be chosen for u, leaving sin(x) for dv.

u = x, dv = sin(x)dx
du = 1dx, v = -cos(x)

Subbing into the formula:

∫xsin(x)dx = -xcos(x) + ∫cos(x)dx

Now there's a new integral to solve, but it's an easy one: cosine.

∫xsin(x)dx = -xcos(x) + sin(x) + C

And you're done!

Now partial fraction decomposition. You'll be doing a LOT of these when you get to Laplace transforms!

The basic idea is: sometimes you'll get a big fraction you want to integrate, such as 6/(x2 + 2x - 8). How do you integrate that? You don't know how to, but what you can do is split it up into two different fractions, each of which you can integrate. And that's partial fraction decomposition.

Start by factoring the denominator: x2 + 2x - 8 factors into (x+4)(x-2).

Now you set up an equality. Set the fraction equal to the sum of two fractions, each of which has just one of the terms in the denominator and a variable in the numerator. It will be these variables that you will have to find:

6/((x+4)(x-2)) = A/(x+4) + B/(x-2)

Multiply both sides by the lefthand denominator. Some cancellation will occur, and you'll have:

6 = A(x-2) + B(x+4)

Distribute:

6 = Ax - 2A + Bx + 4B

You can actually find both A and B from this equation. What, you say? Two unknowns and only one equation? It's true! Just requires a bit of ingenuity. Notice something: on the lefthand side of the equation, there is only a constant term. There are no terms containing x. Doesn't this mean that all the terms containing x on the righthand side of the equation must have to cancel out? Yes, it does! So, you can conclude:

A + B = 0, because Ax and Bx have to cancel each other out on the righthand side. If they didn't, there would be some x term on the lefthand side too!

Furthermore, you can now see that the two constant terms on the righthand side will have to add up to four, since that's what exists on the lefthand side. So:

-2A + 4B = 6

And voila, out of thin air you now have two equations for your two variables, a more familiar system of equations situation. Substitute:

A + B = 0
A = -B

-2A + 4B = 6
2B + 4B = 6
6B = 6
B = 1
A = -B
A = -1

And, going back to the original definition you wrote, you can now sub in for A and B:

6/((x+4)(x-2)) = A/(x+4) + B/(x-2)
6/((x+4)(x-2)) = -1/(x+4) + 1/(x-2)

Now instead of integrating the ugly fraction on the left side, you can integrate the two nice fractions on the right side.

∫6/((x+4)(x-2)) = ∫-1/(x+4)dx + ∫1/(x-2)dx
∫6/((x+4)(x-2)) = -ln(x+4) + ln(x-2) + C

And that's partial fraction decomposition! The rules change somewhat when the terms in the denominator are more complex than the binomials I used here, but that doesn't happen often, and when it does, you can consult the table on page 263 of the Farlow textbook for the (minor) changes that need to be made.

Happy calculating,
Rachel

First order equations - method of integrating factor

As promised, here is the second method of solving first order equations. This method works only on linear equations - see my earlier post on classifying ODE's if you're not sure.

I am a big advocate of teaching with examples. Here's one:

2dy/dx + 2y/x = 4x

The first step is to always make sure the coefficient on your dy/dx term is 1. So in our case, we need to divide both sides by 2 in order to make this true.

dy/dx + y/x = 2x

Now we use the coefficient of the y term to find our integrating factor. The integrating factor is always equal to e to the power of the integral of that coefficient. So, in our case, IF = e∫1/x = eln(x) = x (for this integral, ignore the addition of + c that you usually use).

Now multiply both sides by the integrating factor.

(dy/dx + y/x)*x  = 2x2

Here is the step where a lot of people get confused. The why behind this is not immediately obvious (I will include a quick proof at the bottom of this post), but every time, the left hand side of the equation will reduce to the derivative of y times the integrating factor. This is a property special to the integrating factor and is the reason why it is defined the way it is.

(y * x)' = 2x2

So now, to nullify that derivative, we just have to integrate both sides. You'll notice that our integrating factor in this example was very "nice" in the sense that it reduced down to x instead of involving an exponential term like it most often will. In these other cases, it may be necessary to use integration by parts.

y * x = 2/3x3

Then divide the integrating factor out to isolate y.

y = 2/3x2

And that's the answer! Now for that proof...you won't need to know this for class, but I don't like to make unsubstantiated claims.

Remember that the integrating factor was e to the power of the integral of the coefficient in front of your y term. Let's call this coefficient p. So my claim was that the left hand side of your equation should always equal the derivative of y times the integrating factor. If you want to actually do out this derivative, you'll have to use product rule:

(y * e∫p)' = y' * e∫p + y * (∫p)'e∫p

Let's clean this up a bit. The derivative of the integral of p is just p. We can represent y' as dy/dx. And we can pull out a common factor of e∫p:

(dy/dx + py)*e∫p

But wait! That's just the original lefthand side of the equation times the integrating factor. Which is exactly what we were trying to prove this was equal to.

Happy calculating,
Rachel

First order equations - method of separation of variables

First order differential equations are those that have a first derivative - y' or dy/dx - as its highest order derivative.

There are two methods to solve first order equations that are taught in MA2051. Deciding which one to use depends on the type of equation. If the equation is linear, you should use the method of integrating factor, which I will cover in another post. Otherwise, you'll need to use separation of variables. Check my post about classifying differential equations if you're not sure what kind of equation you're working with.

Separation of variables is just what it sounds like - your goal is to get all y's and dy's onto one side of the equal sign, and all x's and dx's on the other. Here's a simple example:

dy/dx = y

Don't forget - you can just treat dy/dx like you treat any other fraction. You'll need to multiply both sides by dx and divide both sides by y. The result is:

dy/y = dx

The variables are separated! Now you just integrate both sides.

ln(y) = x + c
eln(y) = e(x+c)
y = ecex
y = Ceis your final answer, where big C is equal to the constant e to the power of little c. This is actually an equation that you will use extensively in MA2051, especially in word problems.

Separating your variables can be harder than that example shows. Sometimes it takes some acrobatics. There really isn't any way to outline all these situations in a post. Just make sure you know your algebraic rules thoroughly (see my first post on precalculus topics for some help) and you should always be able to manipulate things into the form you need. Good luck!

Happy calculating,
Rachel

Thursday, January 10, 2013

Amplitude-Phase Form Proof

Again, I pulled formulas out of thin air when I showed amplitude-phase form. Your professor may want to see justification, so I will show an example here.

Say you have solved a differential equation, and you got an answer in the form y = c1eβxcos(γx) + c2eβxsin(γx). Now you're supposed to convert to amplitude phase form. As I stated in my previous post, this answer will be in the following form:  y(x) = Aeβxcos(γx - θ). But why?

First, we will start by defining the constant A, which is equal to √(c12 + c22). Now on the right-hand side of your equation, multiply and divide by A. This is the same as multiplying by 1, and does not change the actual problem. You'll get:

y = c1√(c12 + c22)/√(c12 + c22)eβxcos(γx) + c2√(c12 + c22)/√(c12 + c22)eβxsin(γx)

Now visualize a right triangle in which the legs have length c1 and c2. By the Pythagorean theorem, the hypotenuse will be √(c12 + c22).



So you can replace several pieces of the above equation in terms of θ.

y = √(c12 + c22)cos(θ)eβxcos(γx) + √(c12 + c22)sin(θ)eβxsin(γx).

And what's left is equal to A:

y = Acos(θ)eβxcos(γx) + Asin(θ)eβxsin(γx).

Pull out common factors:

y = Aeβx(cos(θ)cos(γx) + sin(θ)sin(γx)).

Now use a trigonometic identity to clean it up: cos(A)cos(B) + sin(A)sin(B) = cos(B-A)

y = Aeβx(cos(γx - θ)

And that's the proof!

Second Order Linear Answer Proofs

A few posts ago, I explained how to get answers for second order linear diff EQs. However, I just provided formulas. This isn't enough for some professors! They might ask that you justify where that formula came from. To justify, you'll have to show a proof.

In lecture, your professor will probably show you a proof using variables for every term. This can get messy and confusing, plus there is no point in me repeating exactly what you've already been shown. So, I am going to show proofs on specific example problems.

As outlined in the previous post on this topic, there are three scenarios you will encounter. Which scenario you are in will depend on the results of your characteristic equation.

Scenario 1: b2-4ac > 0: 2 real roots
Example problem: 6y'' + y' - y = 0

As I already explained, the answer in this situation will take the following form: y(x) = c1eα1+ c2eα2x. But why?

Well, start with a guess. Guess that your answer will take the form y = eαx where α is a constant. Now take the first derivative: y' = αeαx. And the second: y'' =  α2eαx. Now substitute these values in for y, y', and y'' in the original equation:

2eαx + αeαx - eαx = 0

Now you can factor out a common term of eαx:

eαx(6α+ α - 1) = 0

Now, eαx can never equal zero. It is a positive number raised to some power, and in this situation you will never receive zero for an answer. This means that the only way to make the equation hold true is to make the part in parenthesis equal 0.

(6α+ α - 1) = 0
α = -1/2, 1/3

And that's where your characteristic equation comes from. Now you can see why it is that when you solve the characteristic equation for its roots, you are finding solutions to the differential equation. Since this characteristic equation is a second order equation (the highest exponent is 2), it will have two solutions. This is why a second order differential equation also has two solutions.

We assumed at the beginning that the answer was in the form y = eαx, and we were able to show that this assumption can lead us to answers that satisfy the equation. So it is valid to take the values of α you find from the characteristic equation, and substitute them into  y = eαx.

The Superposition Principle says that any answer to a differential equation multiplied by a constant is still an answer to the equation, and any two answers added together are also an answer. This is why we take the two solutions to the characteristic polynomial and put constants (c1 and c2) in front, and why we add them together to get the final solution.

Scenario 2: b2-4ac < 0: imaginary roots
Example problem: y'' + 2y' + 2y = 0

I stated in my previous post that the answer will end up being in the following form: y(x) = c1eαxcos(βx)+ c2eαxsin(βx). Now let's prove it.

Start out similarly to what we did last time: assume the answer will take the form y = eαx. Take the first and second derivatives and plug into the original problem as before. Pull out the common term and you will get the characteristic equation:

+ 2α + 2) = 0

The problem now is that this equation does not have real roots. Use the quadratic formula to find its imaginary roots:

α = (-2 ± √(4 - 4*1*2))/2
α = 1 ± i

So you could plug in for α at this point and say that your solution is y = c1e(1+i)x + c2e(1-i)x. But those have imaginary numbers in them, and we don't like that.

To solve that problem, we use Euler's formula, which states that y = eix = cos(x) + isin(x). You don't need to prove this statement on your test.

So look at your solution as written right now: y = c1e(1+i)x + c2e(1-i)x.
Distribute: y = c1e1x+1ix + c2e1x-1ix.     (I am leaving the 1's in there to be clear about what is happening with your coefficients. They are preserved.)
Now remember a property of exponents: ex+y = exey. So rewrite your equation using this rule:
y = c1e1xe1ix  + c2e1xe-1ix

Now you can apply Euler's formula on the terms containing i. You will get the following:

y = c1e1x(cos(1x) + isin(1x)) + c2e1x(cos(-1x) + isin(-1x))

Better, but there's still those pesky i's. We now use a property of cosine and sine to help us with the next step. Cosine is an even function. That means that cos(-x) = cos(x). Sine is an odd function, meaning that sin(-x) = -sin(x). We will use these rules to rewrite what is above:

y = c1e1x(cos(1x) + isin(1x)) + c2e1x(cos(1x) - isin(1x))

Great! Now we have like terms. Regroup the equation so that cosine and sine are together:

y = (c1+ c2)e1xcos(1x) + i(c1- c2)e1xsin(1x)

Now we just redefine our coefficients. c1+ c2 = cand i(c1- c2) = c4.

We can now write the equation as y = y = c3e1xcos(1x) + c4e1xsin(1x). All done!

There is a third scenario,  b2-4ac = 0: repeated roots. This proof is very similar to the first one, and I will leave it up to you! If you really want to see it, just shoot me a message.

Sunday, September 2, 2012

Checking Your Answers

One of the great things about Diff EQs is you can always check your answer. The checks aren't necessarily super easy, though, so I'd recommend waiting until the end of an exam and checking if you still have time left over. Your professor will probably take off points for algebraic or differentiation errors, so checking is definitely a good idea!

Say you're solving the equation:

y'' - 10y' + 25y = 0; y(0) = 1, y'(0) = 0

And you've come up with the following solution:

y(x) = e5x - 5xe5x

First make sure your first initial condition holds: y(0) = 1

y(0) = e5*0 - 5*0*e5*0y(0) = 1 - 0 = 1

Now take the derivative of your equation:

y'(x) = 5e5x - 5e5x - 25xe5x     (notice that you must use product rule on the second term)
y'(x) = -25xe5x

Check your second initial condition: y'(0) = 0

y'(0) = -25*0*e5*0y'(0) = 0

Now take the second derivative:

y''(x) = -25e5x - 125xe5x      (product rule again)

Now you have y'', y', and y - you can substitute these into the original equation and make sure it all equals zero.

y'' - 10y' + 25y = 0
-25e5x - 125xe5x - 10(-25xe5x) + 25(e5x - 5xe5x) = 0
-25e5x - 125xe5x + 250xe5x + 25e5x - 125xe5x = 0

Notice the 1st and 4th terms cancel, and the 2nd, 3rd, and 5th terms cancel, so the whole thing equals 0, and your solution checks out. Go ahead and try this anytime you're doubting yourself!

Happy calculating,
Rachel