The Story So Far

Your method for estimating the area under a curve is a smash hit, but it still has some naysayers. Fortunately, you know the best way to convince other academics of your findings: an overwhelming number of cherry-picked examples. Computer-assisted proofs are all the rage ever since some Illinoisians colored a map!

You look back at your favorite function - $x^3 - 3x^2 + 2x + 1$ - and your favorite interval - the squiggly one between $0$ and $2$ - and you want to create a function that can show people that - no matter how many pieces you subdivide it, your method gets the right answer.

To get started, we will first define a function example_quadratic which conforms to the following docstring specification:

"""
Computes $x^3-3x^2+2x+1$ at a value x.

Parameters
----------
x : float
  The value to compute the function at.

Returns
-------
y : The value of the given function at $x$.

Examples
--------
>>> example_quadratic(1)
1.0

>>> example_quadratic(1.5)
0.625
"""

Try it out on a few points, and check by hand whether you are getting the correct value.

Upload a .py file to Brightspace which contains the described function, and - outside of the function - uses input to get a value from the user, then prints the result.

Department of Mathematics, Purdue University
150 N. University Street, West Lafayette, IN 47907-2067
Phone: (765) 494-1901 - FAX: (765) 494-0548
Contact the Webmaster for technical and content concerns about this webpage.
Copyright© 2018, Purdue University, all rights reserved.
West Lafayette, IN 47907 USA, 765-494-4600
An equal access/equal opportunity university
Accessibility issues? Contact the Web Editor (webeditor@math.purdue.edu).