{ "metadata": { "name": "", "signature": "sha256:52b4e1b925439cea7aece0b55434232104d00ffa41479c5f22ca5baf2f38e001" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Solvers" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from sympy import *\n", "init_printing()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "markdown", "metadata": {}, "source": [ "For each exercise, fill in the function according to its docstring. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "a, b, c, d, x, y, z, t = symbols('a b c d x y z t')\n", "f, g, h = symbols('f g h', cls=Function)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 9 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Algebraic Equations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Write a function that computes the [quadratic equation](http://en.wikipedia.org/wiki/Quadratic_equation)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def quadratic():\n", " return ???\n", "quadratic()" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (, line 2)", "output_type": "pyerr", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m return ???\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "prompt_number": 7 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Write a function that computes the general solution to the cubic $x^3 + ax^2 + bx + c$." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def cubic():\n", " return ???\n", "cubic()" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (, line 2)", "output_type": "pyerr", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m return ???\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "prompt_number": 10 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Differential Equations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A population that grows without bound is modeled by the differential equation\n", "\n", "$$f'(t)=af(t)$$\n", "\n", "Solve this differential equation using SymPy." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the population growth is bounded, it is modeled by \n", "\n", "$$f'(t) = f(t)(1 - f(t))$$\n", "\n", "Solve this differential equation using SymPy." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 } ], "metadata": {} } ] }