Python provides a way to get both the value of the function and its
derivative in a single function call. We simply compute and return
both values as follows:
dfdxis done term by term, in the order written, just as we want.
A bunch of comma-separated values is called a ``tuple'' in Python lingo. They can be written inside parentheses. Tuples can have any number of values, including none.
Note that the
quadratic.py example also used a tuple:
evalfunction returns a tuple of three values.