{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# One Variable Equations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Throughout this section and the next ones we shall cover the topic of solutions to one variable equations. Many different problems in physics and astronomy require the use of complex expressions, even with implicit dependence of variables. When it is necessary to solve for one of those variable, an analytical approach is not usually the best solution, because of its complexity or even because it does not exist at all. Different approaches for dealing with this comprehend series expansions and numerical solutions. Among the most widely used numerical approaches are the Bisection or Binary-search method, fixed-point iteration, Newton's methods.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- - -\n", "- [Bisection Method](#Bisection-Method) \n", " - [Steps](#Steps-BM)\n", " - [Stop condition](#Stop-condition-BM)\n", " - [Error analysis](#Error-analysis-BM)\n", " - [Example 1](#Example-1)\n", " - [Example 2](#Example-2)\n", "- [Fixed-point Iteration](#Fixed-point-Iteration)\n", " - [Steps](#Steps-FP)\n", " - [Example 3](#Example-3)\n", " - [Stop condition](#Stop-condition-FP)\n", " - [Example 4](#Example-4)\n", " - [Activity](#ACTIVITY-FP)\n", "- [Newton-Raphson Method](#Newton-Raphson-Method)\n", " - [Derivation](#Derivation-NM)\n", " - [Steps](#Steps-NM)\n", " - [Example 5](#Example-5)\n", " - [Stop condition](#Stop-condition-NM)\n", " - [Convergence](#Convergence-NM)\n", "- [Secant Method](#Secant-Method)\n", " - [Derivation](#Derivation-SM)\n", " - [Steps](#Steps-SM)\n", "\n", "- - -" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "source": [ "import numpy as np\n", "%pylab inline\n", "import matplotlib.pyplot as plt\n", "# JSAnimation import available at https://github.com/jakevdp/JSAnimation\n", "from JSAnimation import IPython_display\n", "from matplotlib import animation\n", "from scipy import integrate\n", "from scipy import optimize" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- - - " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Bisection Method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The Bisection method exploits the [intermediate value theorem](http://en.wikipedia.org/wiki/Intermediate_value_theorem), where a continuous and differentiable function $f$ must have a zero between an interval $[a,b]$ such that $f(a)f(b)<0$, or equivalently, there must be a value $p\\in[a,b]$ such that $f(p)=0$. Below the algorithmm is stated explicitly." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Steps BM" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "