2. A curve satisfies the differential equation \[\frac{dy}{dx}=\log_{10} (x)\] Starting at the point \( (2, 3)\) on the curve, use a step length or \(0.2\) to estimate the value of \(y\) at \(x=2.4\). Give your answer to three decimal places.
Solution:
Doing this sort of thing professionally leaves one with a large number of available methods, so it is necessary to consult the A-level specification to determine what method you are expected to use. From the 2012 specification it is clear that you are expected to use what is commonly known as the Euler method. This may be summarised as:
\[ \begin{aligned} x_{i+1}&=x_i+ \Delta x\\ y_{i+1}&=y_i+\Delta x \times \left[ y'(x_i)\right]=y_i+\Delta x \times \log_{10}(x_i) \end{aligned} \] where \(\Delta x=0.2 \) starting from initial condition \(x_0=2,\ \ y_0=3\).
\[ \begin{array}{ccccc}i&x_i&y_i&\log_{10}(x_i)&y_{i+1}=y_i+\Delta x \log_{10}(x_i)\\ 0&2&3&0.30103&3.06021\\1&2.2&3.06021&0.34242&3.12869\\2&2.4&3.12869 \end{array} \]
We stop at this point as we have reached \(x=2.4\) and have the corresponding estimate \(y=3.129\ (3DP)\).
The arithmetic has been worked to 5 decimal places as I have assumed this will be sufficient to give the final answer to 3 places. (I have done an error analysis and know that four DP are sufficient, but looking at the mark scheme indicates that an error analysis is not expected and you are expected to assume that 5 DP for the calculations will be adequate to give 3 DP in the final solution).
Discussion:
The Euler method used here is probably the crudest method for numerical integration of Ordinary Differential Equations (ODEs) with initial values. The essense of the method is that we step forwards from \(x_i\) to \(x_{i+1}\) using the trauncated Taylor series: \[y(x_i+\Delta x)=y(x_i)+\Delta x \times y'(x_i)\] We can improve this stepping procedure in many ways but two simple ones are to increase the number of terms in the Taylor approximation, which in the case of our problem above would give (for a single step with \(\Delta x=0.4\) ):
\[y(2.4)=y(2)+0.4 \times \log_{10}(2)+0.4^2\frac{1}{4\ln(10)} \approx 3.138 \ \ (3DP)\]
Another method of improving the approximation is instead of using \(y'(x_i)\) we approximate the average value of the derivative over the step. The simplest way of doing this is to use \((y'(x_i)+y'(x_{i+1})/2\) as our estimate of the derivative over the interval. Then again using \(\Delta x=0.4\) we get:\[y(2.4)=y(2)+0.4\frac{\log_{10}(2)+\log_{10}(2.4)}{2}\approx 3.136 \ \ (3DP)\]
Note we use larger steps in the improved methods above since at each stage we are doing longer computations, so to keep the computational effort approximately constant we increase the step length.
If we are interested in the actual value of the solution at \(x=2.4\) to three decimals we can integrate the ODE with either much more powerful methods and/or smaller step sizes, doing this we find the solution to 3DP is \(3.137\).
We may also note that the exact solution to the initial value problem is:\[y(x)=3+\frac{x(\ln(x)-1)}{\ln(10)}-\frac{2(\ln(2)-1)}{\ln(10)}=3+x\log_{10}(x/e)-2\log_{10}(2/e),\ \ \ x>0\] which can be verified by checking the initial condition and differentiating to show that it gives the right derivative.
The numerical integration of first order ordinary differential equations is of greater interest than we might expect since a differential equation of the form:\[\frac{d^n}{dx^n}y(x)=f(x,y,y',...,y^{(n-1)})\] can always be rewritten as a first order system of ordinary differential equations. These can then be integrated by methods developed for simple first order equations. I will illustrate this with a second order equation:\[y''=f(x,y,y')\]
We introduce \(u(x)=y(x)\) and \(v(x)=y'(x)\), then our second order ODE may be written as the first order system:\[\begin{aligned}v' &=f(x,u,v)\\u' &= v \end{aligned}\] This in turn may be integrated by a numerical method intended for first order ODEs. Using Eulers method we get: \[\begin{aligned}x_{i+1}&=x_i+\Delta x \\ v_{i+1}&=v_i+\Delta x\times v'(x_i) = v_i+\Delta x\times f(x_i,u_i,v_i) \\ u_{i+1}&=u_i+\Delta x\times u'(x_i) = u_i+\Delta x\times v_i \end{aligned}\]
No comments:
Post a Comment