Solvers

Boilerplate to make the doctester work.


In [8]:
import sys
import os
sys.path.insert(1, os.path.join(os.path.pardir, "ipython_doctester"))
from sympy import *
from ipython_doctester import test
# Work around a bug in IPython. This will disable the ability to paste things with >>>
def notransform(line): return line
from IPython.core import inputsplitter
inputsplitter.transform_classic_prompt = notransform
init_printing()

For each exercise, fill in the function according to its docstring. Execute the cell to see if you did it right.


In [9]:
a, b, c, d, x, y, z, t = symbols('a b c d x y z t')
f, g, h = symbols('f g h', cls=Function)

Algebraic Equations

Write a function that computes the quadratic equation.


In [7]:
def quadratic():
    return ???
quadratic()


  File "<ipython-input-7-99cd274c3f68>", line 2
    return ???
           ^
SyntaxError: invalid syntax

Write a function that computes the general solution to the cubic $x^3 + ax^2 + bx + c$.


In [10]:
def cubic():
    return ???
cubic()


  File "<ipython-input-10-258b5a2454f9>", line 2
    return ???
           ^
SyntaxError: invalid syntax

Differential Equations

A population that grows without bound is modeled by the differential equation

$$f'(t)=af(t)$$

Solve this differential equation using SymPy.


In [7]:

If the population growth is bounded, it is modeled by

$$f'(t) = f(t)(1 - f(t))$$

In [7]: