# 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.

• education.ti.com/html/t3_free_courses/calculus84_online/mod22/… Feb 29, 2016 at 22:35
• Thanks, but I already use that method (and the simplification mentioned is not possible when $\frac{dy}{dx}$ is a function of $x$ and $y$.) Feb 29, 2016 at 22:39
• Although I am sure Method B is possible on some calculators, it turns out it is not possible on my calculator (I should've properly checked before typing out this question), and I can only type in constant matrices. Therefore I've made an edit to suit this. I'm sure, however, that Method Bs should be able to be converted quite easily to Method Cs. Feb 29, 2016 at 22:57
• What calculator do you have? Does it support programming in say TI-BASIC? Feb 29, 2016 at 23:03
• Casio fx-9750GII although it's been recently upgraded to a slightly newer software. Yes it does support programming, which I have played around with, but that is slightly more fiddly than the spreadsheet method I've already found - but thanks. Also, we have to clear the memory before the exam starts. Feb 29, 2016 at 23:04

Note that we can extract the individual entries in a vector by taking its dot product with the appropriate standard basis vector. In particular: $$\begin{bmatrix} 1 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = x \qquad\text{and}\qquad \begin{bmatrix} 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = y$$ Suppose that we want to use Euler's method to solve the IVP: $$y'(x, y(x)) = x^2 + (y(x))^3 \text{ where } y(0) = 8$$ Then we could initialize: $$\textsf{Ans} := \begin{bmatrix} 0 \\ 8 \end{bmatrix}$$ And use the first-order recurrence: $$\textsf{Ans} := \begin{bmatrix} (\begin{bmatrix} 1 & 0 \end{bmatrix} \textsf{Ans}) + h \\ (\begin{bmatrix} 0 & 1 \end{bmatrix} \textsf{Ans}) + h((\begin{bmatrix} 1 & 0 \end{bmatrix} \textsf{Ans})^2 + (\begin{bmatrix} 0 & 1 \end{bmatrix} \textsf{Ans})^3) \end{bmatrix}$$
• Note that I still have to take the determinants of the 1x1 matrices as my calculator can't understand $\begin{bmatrix} 1\end{bmatrix} + 1$, but this still solves my problem. Feb 29, 2016 at 22:45