{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Example: First Order ODE" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The idea of this method is to find a paramterization of the equation so that for all input arguments the parameterization satisfies the equation." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The snakeviz extension is already loaded. To reload it, use:\n", " %reload_ext snakeviz\n" ] } ], "source": [ "# This line configures matplotlib to show figures embedded in the notebook, \n", "# instead of opening a new window for each figure. More about that later. \n", "# If you are using an old version of IPython, try using '%pylab inline' instead.\n", "%matplotlib inline\n", "\n", "## snakeviz is a very useful tool to visualizaion cprofile\n", "%load_ext snakeviz\n", "\n", "# numpy scipy and plot\n", "import numpy as np\n", "from scipy.optimize import minimize\n", "from scipy.optimize import rosen, differential_evolution\n", "import matplotlib.pyplot as plt\n", "import scipy\n", "\n", "from matplotlib.lines import Line2D\n", "\n", "\n", "## To time the functions\n", "import timeit\n", "\n", "## The following is need for plotly\n", "\n", "#import pandas as pd\n", "\n", "#import plotly.plotly as py\n", "#from plotly.graph_objs import *\n", "#import plotly.tools as tls" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Solving first order differential equation\n", "\n", "$$\\frac{dy(t)}{dt}=-y(t)$$.\n", "\n", "Here a parameterization like the fourier mode is used.\n", "\n", "$$ y = \\sum_m^{N} ( A_m \\sin(mx) + B_m \\cos(mx) ). $$\n", "\n", "The first order derivative is\n", "\n", "$$ \\frac{dy}{dt} = \\sum_m^{N} ( A_m m \\cos(mx) - B_m m \\sin(mx) ) .$$\n", "\n", "The most important question after we have chosen a parameterization method is how many parameters is needed. We'll find out." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Define the equation.\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }