ECT Python Program: Instantaneous Rate of Change


 At a glance…

Core subject(s)

Mathematics

Subject area(s)

Calculus

Suggested age

16 to 18 years old

Overview

Use this program to apply students’ knowledge of determining the instantaneous rate of change for a given function and automatically calculate it for a given function. Have students analyze, fill in parts of, or use the program to check results to exercises they are already working on. This program aligns with CA Math Standard: Calculus 4.2. This program could be used to further your understanding of how you could use Python in the classroom, as a demonstration or discussion with your students, or as a way to introduce various CT concepts, such as pattern recognition or abstraction, to your students by inviting them to extend the existing functionality of the program.

Python Program

# Copyright 2015 Google Inc. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");

# you may not use this file except in compliance with the License.

# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

"""Calculate the instantaneous rate of change"""

def g(x): return x**2

# function D() takes as input g(x), and a small value for h (0.001)

# this function calculates the derivative

def D(function, h = 1e-3):

    def derivative(x):

        deriv=(function(x + h) - function(x)) / h

        return round(deriv, 3)

    return derivative

# compute rate of change

rate_of_change = D(g)

# and then instantaneous rate of change for a particular value

instantaneous_rate_of_change = rate_of_change(26)

print instantaneous_rate_of_change

Additional Information and Resources

Computational Thinking Concepts*

Concept

Definition

Abstraction

Identifying and extracting relevant information to define main idea(s)

Pattern Recognition

Observing patterns, trends, and regularities in data

* Explore the Computational Thinking Concepts Guide for a list of the CT concepts noted on ECT, including tips for implementing each concept in your classroom

Additional Resource Links

Administrative Details

Contact info

For more info about Exploring Computational Thinking (ECT), visit the ECT website (g.co/exploringCT)

Credits

Developed by the Exploring Computational Thinking team at Google and reviewed by K-12 educators from around the world.

Last updated on

01/15/2015

Copyright info

Except as otherwise noted, the content of this document is licensed under the Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache 2.0 License.


 ECT Python Program: Instantaneous Rate of Change                                                                    of