Posts

Showing posts with the label Numerical

Numerical solver - Newton-Raphson method

Image
The program downloadable from this page is a numerical solver. It attempts to find the zeroes of a function $f(x)$, i.e. it attempts to find $x$ such that $f(x)=0$ There are several methods for this. One that requires little computing power is Newton's Method, or the Newton-Raphson method, a description of which can be found on Wikipedia . We have no way of knowing the exact value of $f'(x)$ on the HP-41CX used here because that machine has no symbolic math capabilities, so we calculate an approximation of $f'(x)$ by taking a small value $\epsilon$ and calculating: \[ f'(x) \approx \frac {f(x+\epsilon)-f(x)} \epsilon \] This then allows us to calculate the next value of $x$ to use and display so that we see the calculator homing in on the zero that we're looking for: \[ x_{n+1} = x_n - \frac {f(x_n)} {f'(x_n)} \] Once we find a value of $x$ such that $|f(x)| \lt \epsilon$, we stop and that value of $x$ is deemed to be a zero of $f(x)$. The s...

Numerical Integration - Simpson's Rule

Image
Numerical integration is an operation that many older machines are not able to perform without add-on libraries (e.g. Math Pac for HP-41C) or without writing a program from scratch to do it. There are, of course, some exceptions to this; Hewlett Packard's HP-15C and HP-42S come straight to mind, as does the Casio fx-180P, for example, but these machines are actually the exception, not the rule. There are many methods used to calculate definite integrals, that is integrals between known boundaries yielding a numerical result. One method that is a good trade-off between precision and complexity of application is Simpson's Rule , which attempts to find a quadratic of the form $a\cdot x^2+b\cdot x+c$ that fits or is close to our function. Finding the integral of this polynomial is very easy: \[ \int_{x_1}^{x_2} \! (a\cdot x^2 + b\cdot x + c) \, \partial x = \frac a 3 (x_2^3-x_1^3) + \frac b 2 (x_2^2-x_1^2) + c\cdot (x_2 - x_1) \] Basically, Simpson's Rule states: \[ ...