Friday 11 May 2018

ordinary differential equations - A nice way to do Euler's method on a calculator?

As part of the calculator paper for IB (International Baccalaureate), we may be asked to do Euler's method, for say, 10 iterations.



While it is feasible to do with a calculator (slightly easier if you have 2 calculators), it is quite a nuisance, and it is quite easy to make a mistake when I have to retype the numbers back into the calculator.




The problem here is that calculators can only store 1 answer (Ans) at a time, and that any attempt to store your answer into a memory slot would delete your calculation line which you would have to type in again.



On the other hand, you can easily use the calculator to execute recursive functions which only rely on 1 variable.



For example, I can calculate the $n$th term of the following recursive sequence by repeatedly pressing the = button:



$$T_{n+1}=T_n^3+\sqrt{T_n}-\frac{1}{T_n},\, T_0=5$$



In this example, I would first press 5 = and then type in ${Ans}^3+\sqrt{Ans}-\frac{1}{Ans}$ and press = $n$ times to get $T_n$.




However, this is not possible with Euler's method which has recursive formulas:



$$x_{n+1}=x_n+h$$
$$y_{n+1}=y_n+h\frac{dy_n}{dx_n}$$



where $h$ is the step (which can be pre-stored in a memory slot) and $\frac{dy_n}{dx_n}=f(x_n, y_n)$.



We are allowed to use a graphical calculator (GDC) which has several functions. I have found a way to do this using the spreadsheet function which is quite fiddly, but at least avoids copying mistakes when retyping numbers into my calculator. I was wondering if there were yet easier methods to do this, so I shall ask for the following methods, if possible:



Method A




I would prefer it if a method with the following restrictions could be used to execute Euler's method:



You have a calculator which is an ordinary scientific calculator which has the ability to store the previous answer (Ans). You have the ability to type in a whole function in terms of (Ans) as shown in the first example. Is it possible to type in a one-liner which would do Euler's method by repeatedly pressing =?



*Note: I am aware that this method is probably possible but may be quite complicated to type in/learn. Therefore I would prefer Method B if it is simpler, as I would be under the time pressure of an exam. Nevertheless, I would still be interested in a method A which can do Euler's method for me as I personally prefer my ordinary scientific calculator to my GDC.



Method B



In addition to the Ans tool given in Method A, you also have the ability to type in $m\times n$ matrices in your calculator. The calculator can take in matrices in its input, and can output matrices which will be stored to Ans. Matrix multiplication (and raising to a power) can be carried out along with transpose, determinant and inverse functions (where possible) on matrices. Note that I cannot "get" cell $(i,j)$ of a matrix - I have to use the matrix as a whole.




However, I can still do something like the following:



$$\pi\begin{bmatrix}\sqrt{\det\left({Ans}^{T} \times \begin{bmatrix}3 & 4\\12 & \det(Ans)\end{bmatrix}^{-1}\right)} & 4\\\det(Ans)^2 & -\det({Ans}^2)\end{bmatrix}^3$$



Similarly, is there a one-liner which would be able to do Euler's method?



EDIT:



Method C




Unfortunately, it turns out that my calculator cannot accept matrices within matrices which is a real shame - my mistake that I thought it could. It can only manipulate matrix answers, and I can only type in constant matrices. Nevertheless, I'm sure there is a way to circumvent this problem with some matrix multiplication.



So ny calculator can only do something like:



$$\begin{bmatrix}1 & 2 \\ 8 & 2\end{bmatrix}^{-2}\times {Ans}^T \times {(Mat\, A)}^{-1}$$



(Where Mat A is previously stored in the memory. Note that Ans can still be a matrix)



Note that my calculators can store values (and matrices in the case of method B) into their memory, but that would only be initial values for variables (like $h$, $x_0$ and $y_0$), as the one-liner must be deleted before I can type in the line which can store memory.




In addition to these methods, if there is some function/tool I am completely missing on these calculators which I could use to simplify my task, I would be glad to hear it.

No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...