Skip to main content

Calculus III - 3-Dimensional Space: Equations of Lines

In this section we need to take a look at the equation of a line in  R 3 R 3 . As we saw in the previous section the equation  y = m x + b y = m x + b  does not describe a line in  R 3 R 3 , instead it describes a plane. This doesn’t mean however that we can’t write down an equation for a line in 3-D space. We’re just going to need a new way of writing down the equation of a curve. So, before we get into the equations of lines we first need to briefly look at vector functions. We’re going to take a more in depth look at vector functions later. At this point all that we need to worry about is notational issues and how they can be used to give the equation of a curve. The best way to get an idea of what a vector function is and what its graph looks like is to look at an example. So, consider the following vector function. → r ( t ) = ⟨ t , 1 ⟩ r → ( t ) = ⟨ t , 1 ⟩ A vector function is a function that takes one or more variables, one in this case, and returns a vector. Note as we

Differential Equations - First Order: Euler's Method



Up to this point practically every differential equation that we’ve been presented with could be solved. The problem with this is that these are the exceptions rather than the rule. The vast majority of first order differential equations can’t be solved.
In order to teach you something about solving first order differential equations we’ve had to restrict ourselves down to the fairly restrictive cases of linear, separable, or exact differential equations or differential equations that could be solved with a set of very specific substitutions. Most first order differential equations however fall into none of these categories. In fact, even those that are separable or exact cannot always be solved for an explicit solution. Without explicit solutions to these it would be hard to get any information about the solution.
So, what do we do when faced with a differential equation that we can’t solve? The answer depends on what you are looking for. If you are only looking for long term behavior of a solution you can always sketch a direction field. This can be done without too much difficulty for some fairly complex differential equations that we can’t solve to get exact solutions.
The problem with this approach is that it’s only really good for getting general trends in solutions and for long term behavior of solutions. There are times when we will need something more. For instance, maybe we need to determine how a specific solution behaves, including some values that the solution will take. There are also a fairly large set of differential equations that are not easy to sketch good direction fields for.
In these cases, we resort to numerical methods that will allow us to approximate solutions to differential equations. There are many different methods that can be used to approximate solutions to a differential equation and in fact whole classes can be taught just dealing with the various methods. We are going to look at one of the oldest and easiest to use here. This method was originally devised by Euler and is called, oddly enough, Euler’s Method.
Let’s start with a general first order IVP
(1)dydt=f(t,y)y(t0)=y0
where f(t,y) is a known function and the values in the initial condition are also known numbers. From the second theorem in the Intervals of Validity section we know that if f and fy are continuous functions then there is a unique solution to the IVP in some interval surrounding t=t0. So, let’s assume that everything is nice and continuous so that we know that a solution will in fact exist.
We want to approximate the solution to (1) near t=t0. We’ll start with the two pieces of information that we do know about the solution. First, we know the value of the solution at t=t0 from the initial condition. Second, we also know the value of the derivative at t=t0. We can get this by plugging the initial condition into f(t,y) into the differential equation itself. So, the derivative at this point is.
dydt|t=t0=f(t0,y0)
Now, recall from your Calculus I class that these two pieces of information are enough for us to write down the equation of the tangent line to the solution at t=t0. The tangent line is
y=y0+f(t0,y0)(tt0)
Take a look at the figure below


If t1 is close enough to t0 then the point y1 on the tangent line should be fairly close to the actual value of the solution at t1, or y(t1). Finding y1 is easy enough. All we need to do is plug t1 in the equation for the tangent line.
y1=y0+f(t0,y0)(t1t0)
Now, we would like to proceed in a similar manner, but we don’t have the value of the solution at t1 and so we won’t know the slope of the tangent line to the solution at this point. This is a problem. We can partially solve it however, by recalling that y1 is an approximation to the solution at t1. If y1 is a very good approximation to the actual value of the solution then we can use that to estimate the slope of the tangent line at t1.
So, let’s hope that y1 is a good approximation to the solution and construct a line through the point (t1,y1) that has slope f(t1,y1). This gives
y=y1+f(t1,y1)(tt1)
Now, to get an approximation to the solution at t=t2 we will hope that this new line will be fairly close to the actual solution at t2 and use the value of the line at t2 as an approximation to the actual solution. This gives.
y2=y1+f(t1,y1)(t2t1)
We can continue in this fashion. Use the previously computed approximation to get the next approximation. So,
y3=y2+f(t2,y2)(t3t2)y4=y3+f(t3,y3)(t4t3)etc.
In general, if we have tn and the approximation to the solution at this point, yn, and we want to find the approximation at tn+1 all we need to do is use the following.
yn+1=yn+f(tn,yn)(tn+1tn)
If we define fn=f(tn,yn) we can simplify the formula to
(2)yn+1=yn+fn(tn+1tn)
Often, we will assume that the step sizes between the points t0 , t1 , t2 , … are of a uniform size of h. In other words, we will often assume that
tn+1tn=h
This doesn’t have to be done and there are times when it’s best that we not do this. However, if we do the formula for the next approximation becomes.
(3)yn+1=yn+hfn
So, how do we use Euler’s Method? It’s fairly simple. We start with (1) and decide if we want to use a uniform step size or not. Then starting with (t0,y0) we repeatedly evaluate (2) or (3) depending on whether we chose to use a uniform step size or not. We continue until we’ve gone the desired number of steps or reached the desired time. This will give us a sequence of numbers y1 , y2 , y3 , … yn that will approximate the value of the actual solution at t1 , t2 , t3 , … tn.
What do we do if we want a value of the solution at some other point than those used here? One possibility is to go back and redefine our set of points to a new set that will include the points we are after and redo Euler’s Method using this new set of points. However, this is cumbersome and could take a lot of time especially if we had to make changes to the set of points more than once.
Another possibility is to remember how we arrived at the approximations in the first place. Recall that we used the tangent line
y=y0+f(t0,y0)(tt0)
to get the value of y1. We could use this tangent line as an approximation for the solution on the interval [t0,t1]. Likewise, we used the tangent line
y=y1+f(t1,y1)(tt1)
to get the value of y2. We could use this tangent line as an approximation for the solution on the interval [t1,t2]. Continuing in this manner we would get a set of lines that, when strung together, should be an approximation to the solution as a whole.
In practice you would need to write a computer program to do these computations for you. In most cases the function f(t,y) would be too large and/or complicated to use by hand and in most serious uses of Euler’s Method you would want to use hundreds of steps which would make doing this by hand prohibitive. So, here is a bit of pseudo-code that you can use to write a program for Euler’s Method that uses a uniform step size, h.
  1. define f(t,y).
  2. input t0 and y0.
  3. input step size, h and the number of steps, n.
  4. for j from 1 to n do
    1. m=f(t0,y0)
    2. y1=y0+hm
    3. t1=t0+h
    4. Print t1 and y1
    5. t0=t1
    6. y0=y1
  5. end
The pseudo-code for a non-uniform step size would be a little more complicated, but it would essentially be the same.
So, let’s take a look at a couple of examples. We’ll use Euler’s Method to approximate solutions to a couple of first order differential equations. The differential equations that we’ll be using are linear first order differential equations that can be easily solved for an exact solution. Of course, in practice we wouldn’t use Euler’s Method on these kinds of differential equations, but by using easily solvable differential equations we will be able to check the accuracy of the method. Knowing the accuracy of any approximation method is a good thing. It is important to know if the method is liable to give a good approximation or not.


Example 1 For the IVPy+2y=2e4ty(0)=1Use Euler’s Method with a step size of h=0.1 to find approximate values of the solution at t = 0.1, 0.2, 0.3, 0.4, and 0.5. Compare them to the exact values of the solution at these points.

This is a fairly simple linear differential equation so we’ll leave it to you to check that the solution is
y(t)=1+12e4t12e2tIn order to use Euler’s Method we first need to rewrite the differential equation into the form given in (1).
y=2e4t2yFrom this we can see that f(t,y)=2e4t2y. Also note that t0=0 and y0=1. We can now start doing some computations.
f0=f(0,1)=2e4(0)2(1)=1y1=y0+hf0=1+(0.1)(1)=0.9So, the approximation to the solution at t1=0.1 is y1=0.9.
At the next step we have
f1=f(0.1,0.9)=2e4(0.1)2(0.9)=0.470320046y2=y1+hf1=0.9+(0.1)(0.470320046)=0.852967995Therefore, the approximation to the solution at t2=0.2 is y2=0.852967995.
I’ll leave it to you to check the remainder of these computations.
f2=0.155264954y3=0.837441500f3=0.023922788y4=0.839833779f4=0.1184359245y5=0.851677371Here’s a quick table that gives the approximations as well as the exact value of the solutions at the given points.
Time, tnApproximationExactError
t0=0y0=1y(0)=10 %
t1=0.1y1=0.9y(0.1)=0.9257946462.79 %
t2=0.2y2=0.852967995y(0.2)=0.8895044594.11 %
t3=0.3y3=0.837441500y(0.3)=0.8761912884.42 %
t4=0.4y4=0.839833779y(0.4)=0.8762837774.16 %
t5=0.5y5=0.851677371y(0.5)=0.8837279213.63 %
We’ve also included the error as a percentage. It’s often easier to see how well an approximation does if you look at percentages. The formula for this is,
percent error=|exactapproximate|exact×100We used absolute value in the numerator because we really don’t care at this point if the approximation is larger or smaller than the exact. We’re only interested in how close the two are.

The maximum error in the approximations from the last example was 4.42%, which isn’t too bad, but also isn’t all that great of an approximation. So, provided we aren’t after very accurate approximations this didn’t do too badly. This kind of error is generally unacceptable in almost all real applications however. So, how can we get better approximations?
Recall that we are getting the approximations by using a tangent line to approximate the value of the solution and that we are moving forward in time by steps of h. So, if we want a more accurate approximation, then it seems like one way to get a better approximation is to not move forward as much with each step. In other words, take smaller h’s.


Example 2 Repeat the previous example only this time give the approximations at t=1t=2t=3t=4, and t=5. Use h=0.1h=0.05h=0.01h=0.005, and h=0.001 for the approximations.

Below are two tables, one gives approximations to the solution and the other gives the errors for each approximation. We’ll leave the computational details to you to check.
Approximations
TimeExacth=0.1h=0.05h=0.01h=0.005h=0.001
t = 10.94149020.93132440.93646980.94049940.94099570.9413914
t = 20.99100990.99136810.99111260.99101930.99101390.9910106
t = 30.99876370.99905010.99889820.99878900.99877630.9987662
t = 40.99983230.99989760.99986570.99983900.99983570.9998330
t = 50.99997730.99998900.99998370.99997860.99997800.9999774


Percentage Errors
Timeh=0.1h=0.05h=0.01h=0.005h=0.001
t = 11.08 %0.53 %0.105 %0.053 %0.0105 %
t = 20.036 %0.010 %0.00094 %0.00041 %0.0000703 %
t = 30.029 %0.013 %0.0025 %0.0013 %0.00025 %
t = 40.0065 %0.0033 %0.00067 %0.00034 %0.000067 %
t = 50.0012 %0.00064 %0.00013 %0.000068 %0.000014 %
We can see from these tables that decreasing h does in fact improve the accuracy of the approximation as we expected.

There are a couple of other interesting things to note from the data. First, notice that in general, decreasing the step size, h, by a factor of 10 also decreased the error by about a factor of 10 as well.
Also, notice that as t increases the approximation actually tends to get better. This isn’t the case completely as we can see that in all but the first case the t = 3 error is worse than the error at t = 2, but after that point, it only gets better. This should not be expected in general. In this case this is more a function of the shape of the solution. Below is a graph of the solution (the line) as well as the approximations (the dots) for h=0.1.


Notice that the approximation is worst where the function is changing rapidly. This should not be too surprising. Recall that we’re using tangent lines to get the approximations and so the value of the tangent line at a given t will often be significantly different than the function due to the rapidly changing function at that point.
Also, in this case, because the function ends up fairly flat as t increases, the tangents start looking like the function itself and so the approximations are very accurate. This won’t always be the case of course.
Let’s take a look at one more example.


Example 3 For the IVPyy=12et2sin(5t)+5et2cos(5t)y(0)=0Use Euler’s Method to find the approximation to the solution at t=1t=2t=3t=4, and t=5. Use h=0.1h=0.05h=0.01h=0.005, and h=0.001 for the approximations.

We’ll leave it to you to check the details of the solution process. The solution to this linear first order differential equation is.
y(t)=et2sin(5t)Here are two tables giving the approximations and the percentage error for each approximation.
Approximations
TimeExacth=0.1h=0.05h=0.01h=0.005h=0.001
t = 1-1.58100-0.97167-1.26512-1.51580-1.54826-1.57443
t = 2-1.478800.65270-0.34327-1.23907-1.35810-1.45453
t = 32.914397.302095.346823.444883.182592.96851
t = 46.7458015.5612811.848397.898087.330936.86429
t = 5-1.6123721.9546512.240181.560560.0018864-1.28498


Percentage Errors
Timeh=0.1h=0.05h=0.01h=0.005h=0.001
t = 138.54 %19.98 %4.12 %2.07 %0.42 %
t = 2144.14 %76.79 %16.21 %8.16 %1.64 %
t = 3150.55 %83.46 %18.20 %9.20 %1.86 %
t = 4130.68 %75.64 %17.08 %8.67 %1.76 %
t = 51461.63 %859.14 %196.79 %100.12 %20.30 %
So, with this example Euler’s Method does not do nearly as well as it did on the first IVP. Some of the observations we made in Example 2 are still true however. Decreasing the size of h decreases the error as we saw with the last example and would expect to happen. Also, as we saw in the last example, decreasing h by a factor of 10 also decreases the error by about a factor of 10.
However, unlike the last example increasing t sees an increasing error. This behavior is fairly common in the approximations. We shouldn’t expect the error to decrease as t increases as we saw in the last example. Each successive approximation is found using a previous approximation. Therefore, at each step we introduce error and so approximations should, in general, get worse as t increases.
Below is a graph of the solution (the line) as well as the approximations (the dots) for h = 0.05.
As we can see the approximations do follow the general shape of the solution, however, the error is clearly getting much worse as t increases.

So, Euler’s method is a nice method for approximating fairly nice solutions that don’t change rapidly. However, not all solutions will be this nicely behaved. There are other approximation methods that do a much better job of approximating solutions. These are not the focus of this course however, so I’ll leave it to you to look further into this field if you are interested.

Also notice that we don’t generally have the actual solution around to check the accuracy of the approximation. We generally try to find bounds on the error for each method that will tell us how well an approximation should do. These error bounds are again not really the focus of this course, so I’ll leave these to you as well if you’re interested in looking into them.

Comments

Popular posts from this blog

Digital Signal Processing - Basic Continuous Time Signals

To test a system, generally, standard or basic signals are used. These signals are the basic building blocks for many complex signals. Hence, they play a very important role in the study of signals and systems. Unit Impulse or Delta Function A signal, which satisfies the condition,   δ ( t ) = lim ϵ → ∞ x ( t ) δ ( t ) = lim ϵ → ∞ x ( t )   is known as unit impulse signal. This signal tends to infinity when t = 0 and tends to zero when t ≠ 0 such that the area under its curve is always equals to one. The delta function has zero amplitude everywhere except at t = 0. Properties of Unit Impulse Signal δ(t) is an even signal. δ(t) is an example of neither energy nor power (NENP) signal. Area of unit impulse signal can be written as; A = ∫ ∞ − ∞ δ ( t ) d t = ∫ ∞ − ∞ lim ϵ → 0 x ( t ) d t = lim ϵ → 0 ∫ ∞ − ∞ [ x ( t ) d t ] = 1 Weight or strength of the signal can be written as; y ( t ) = A δ ( t ) y ( t ) = A δ ( t ) Area of the weighted impulse signal can

Differential Equations - First Order: Bernoulli

In this section we are going to take a look at differential equations in the form, y ′ + p ( x ) y = q ( x ) y n y ′ + p ( x ) y = q ( x ) y n where  p ( x ) p ( x )  and  q ( x ) q ( x )  are continuous functions on the interval we’re working on and  n n  is a real number. Differential equations in this form are called  Bernoulli Equations . First notice that if  n = 0 n = 0  or  n = 1 n = 1  then the equation is linear and we already know how to solve it in these cases. Therefore, in this section we’re going to be looking at solutions for values of  n n  other than these two. In order to solve these we’ll first divide the differential equation by  y n y n  to get, y − n y ′ + p ( x ) y 1 − n = q ( x ) y − n y ′ + p ( x ) y 1 − n = q ( x ) We are now going to use the substitution  v = y 1 − n v = y 1 − n  to convert this into a differential equation in terms of  v v . As we’ll see this will lead to a differential equation that we can solve. We are going to have to be c

Differential Equations - Systems: Solutions

Now that we’ve got some of the basics out of the way for systems of differential equations it’s time to start thinking about how to solve a system of differential equations. We will start with the homogeneous system written in matrix form, → x ′ = A → x (1) (1) x → ′ = A x → where,  A A  is an  n × n n × n  matrix and  → x x →  is a vector whose components are the unknown functions in the system. Now, if we start with  n = 1 n = 1 then the system reduces to a fairly simple linear (or separable) first order differential equation. x ′ = a x x ′ = a x and this has the following solution, x ( t ) = c e a t x ( t ) = c e a t So, let’s use this as a guide and for a general  n n  let’s see if → x ( t ) = → η e r t (2) (2) x → ( t ) = η → e r t will be a solution. Note that the only real difference here is that we let the constant in front of the exponential be a vector. All we need to do then is plug this into the differential equation and see what we get. First notice that

Calculus III - 3-Dimensional Space: Equations of Lines

In this section we need to take a look at the equation of a line in  R 3 R 3 . As we saw in the previous section the equation  y = m x + b y = m x + b  does not describe a line in  R 3 R 3 , instead it describes a plane. This doesn’t mean however that we can’t write down an equation for a line in 3-D space. We’re just going to need a new way of writing down the equation of a curve. So, before we get into the equations of lines we first need to briefly look at vector functions. We’re going to take a more in depth look at vector functions later. At this point all that we need to worry about is notational issues and how they can be used to give the equation of a curve. The best way to get an idea of what a vector function is and what its graph looks like is to look at an example. So, consider the following vector function. → r ( t ) = ⟨ t , 1 ⟩ r → ( t ) = ⟨ t , 1 ⟩ A vector function is a function that takes one or more variables, one in this case, and returns a vector. Note as we

Digital Signal Processing - Miscellaneous Signals

There are other signals, which are a result of operation performed on them. Some common type of signals are discussed below. Conjugate Signals Signals, which satisfies the condition  x ( t ) = x ∗ ( − t ) are called conjugate signals. Let  x ( t ) = a ( t ) + j b ( t ) So,  x ( − t ) = a ( − t ) + j b ( − t ) And  x ∗ ( − t ) = a ( − t ) − j b ( − t ) By Condition,  x ( t ) = x ∗ ( − t ) If we compare both the derived equations 1 and 2, we can see that the real part is even, whereas the imaginary part is odd. This is the condition for a signal to be a conjugate type. Conjugate Anti-Symmetric Signals Signals, which satisfy the condition  x ( t ) = − x ∗ ( − t ) are called conjugate anti-symmetric signal Let  x ( t ) = a ( t ) + j b ( t ) So  x ( − t ) = a ( − t ) + j b ( − t ) And  x ∗ ( − t ) = a ( − t ) − j b ( − t ) − x ∗ ( − t ) = − a ( − t ) + j b ( − t ) By Condition  x ( t ) = − x ∗ ( − t ) Now, again compare, both the equations just as w

Differential Equations - First Order: Modeling - i

We now move into one of the main applications of differential equations both in this class and in general. Modeling is the process of writing a differential equation to describe a physical situation. Almost all of the differential equations that you will use in your job (for the engineers out there in the audience) are there because somebody, at some time, modeled a situation to come up with the differential equation that you are using. This section is not intended to completely teach you how to go about modeling all physical situations. A whole course could be devoted to the subject of modeling and still not cover everything! This section is designed to introduce you to the process of modeling and show you what is involved in modeling. We will look at three different situations in this section : Mixing Problems, Population Problems, and Falling Objects. In all of these situations we will be forced to make assumptions that do not accurately depict reality in most cases, but wi

Differential Equations - Basic Concepts: Definitions

Differential Equation The first definition that we should cover should be that of  differential equation . A differential equation is any equation which contains derivatives, either ordinary derivatives or partial derivatives. There is one differential equation that everybody probably knows, that is Newton’s Second Law of Motion. If an object of mass  m m  is moving with acceleration  a a  and being acted on with force  F F  then Newton’s Second Law tells us. F = m a (1) (1) F = m a To see that this is in fact a differential equation we need to rewrite it a little. First, remember that we can rewrite the acceleration,  a a , in one of two ways. a = d v d t OR a = d 2 u d t 2 (2) (2) a = d v d t OR a = d 2 u d t 2 Where  v v  is the velocity of the object and  u u  is the position function of the object at any time  t t . We should also remember at this point that the force,  F F  may also be a function of time, velocity, and/or position. So, with all these things in

Differential Equations - Partial: Summary of Separation of Variables

Throughout this chapter we’ve been talking about and solving partial differential equations using the method of separation of variables. However, the one thing that we’ve not really done is completely work an example from start to finish showing each and every step. Each partial differential equation that we solved made use somewhere of the fact that we’d done at least part of the problem in another section and so it makes some sense to have a quick summary of the method here. Also note that each of the partial differential equations only involved two variables. The method can often be extended out to more than two variables, but the work in those problems can be quite involved and so we didn’t cover any of that here. So with all of that out of the way here is a quick summary of the method of separation of variables for partial differential equations in two variables. Verify that the partial differential equation is linear and homogeneous. Verify that the boundary condi

Differential Equations - Systems: Repeated Eigenvalues - i

This is the final case that we need to take a look at. In this section we are going to look at solutions to the system, → x ′ = A → x x → ′ = A x → where the eigenvalues are repeated eigenvalues. Since we are going to be working with systems in which  A A  is a  2 × 2 2 × 2  matrix we will make that assumption from the start. So, the system will have a double eigenvalue,  λ λ . This presents us with a problem. We want two linearly independent solutions so that we can form a general solution. However, with a double eigenvalue we will have only one, → x 1 = → η e λ t x → 1 = η → e λ t So, we need to come up with a second solution. Recall that when we looked at the double root case with the second order differential equations we ran into a similar problem. In that section we simply added a  t t  to the solution and were able to get a second solution. Let’s see if the same thing will work in this case as well. We’ll see if → x = t e λ t → η x → = t e λ t η → will also be a

Differential Equations - First Order: Modeling - ii

Example 4  A 50 kg object is shot from a cannon straight up with an initial velocity of 10m/s off a bridge that is 100 meters above the ground. If air resistance is given by 5 v v  determine the velocity of the mass when it hits the ground. First, notice that when we say straight up, we really mean straight up, but in such a way that it will miss the bridge on the way back down. Here is a sketch of the situation. Notice the conventions that we set up for this problem. Since the vast majority of the motion will be in the downward direction we decided to assume that everything acting in the downward direction should be positive. Note that we also defined the “zero position” as the bridge, which makes the ground have a “position” of 100. Okay, if you think about it we actually have two situations here. The initial phase in which the mass is rising in the air and the second phase when the mass is on its way down. We will need to examine both situations and set up an IVP for