ktongue's picture
download
raw
4.46 kB
{
"metadata": {
"name": "Solvers"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Solvers"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Boilerplate to make the doctester work. "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import sys\n",
"import os\n",
"sys.path.insert(1, os.path.join(os.path.pardir, \"ipython_doctester\"))\n",
"from sympy import *\n",
"from ipython_doctester import test\n",
"# Work around a bug in IPython. This will disable the ability to paste things with >>>\n",
"def notransform(line): return line\n",
"from IPython.core import inputsplitter\n",
"inputsplitter.transform_classic_prompt = notransform\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. Execute the cell to see if you did it right. "
]
},
{
"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 (<ipython-input-7-99cd274c3f68>, line 2)",
"output_type": "pyerr",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-7-99cd274c3f68>\"\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 (<ipython-input-10-258b5a2454f9>, line 2)",
"output_type": "pyerr",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-10-258b5a2454f9>\"\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))$$"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
}
],
"metadata": {}
}
]
}

Xet Storage Details

Size:
4.46 kB
·
Xet hash:
ddffecf65ddb7fedb512c35fb174c5c654a6c0ea639be463432054e3aedd44a3

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.