Continuity and Differentiability (Why understand these topics!)
The idea is to review the definition of these topics from both an intuitive and formal point of view. Then we discuss a class of functions that plays an important role in a variety of mathematics and application areas. There is a well-known set of functions that belong to this special class that are easy to work with and are used as building blocks to help solve applied problems in engineering and science. Finally we describe a particular modern-day application and show how to use MATLAB to construct a solution in which continuity and differentiability are prominently evident.
Continuous
Intuitive Definition
A function is continuous if it continues on its way “uninterrupted”; no holes, no jumps, no shooting off to +∞ or -∞. The graphs of continuous functions can be drawn without ever lifting your pencil or pen from the paper.
Formal Definition: (it has three parts)
f(x) is continuous at x = a provided
(1) f(a) is defined (no missing points; x = a is in the domain of the function)
(2) exists (the function is approaching a particular value as x gets closer and closer to a from either side of a)
(3) (the number that f(x) is supposed to be getting close to is the value of the function at x = a; no holes)
(Source: How to Ace Calculus by Adams, Thompson, and Hass)
Differentiable
Intuitive Definition
A function f(x) is differentiable at x = a provided we can construct a tangent line to the function at the point (a, f(a)). (The value of the derivative at a point is the instantaneous rate of change of function at that point; its value is the slope of the tangent line.)
Formal Definition
A function f(x) is differentiable at a point x = a, if its derivative exists at the point; that is, the limit exists. (The slope from the left = the slope from the right at x = a.)
Theory (no proof)
If f(x) is differentiable at x = a, then f(x) is continuous at x = a.
“Smooth Functions”
A continuous function is sort of smooth because we can draw it without picking up our pencil. A differentiable function is even smoother; it is automatically continuous and we can construct a tangent line at each point. But its derivative need not be a continuous function. However, for certain functions the derivative is also a differentiable function. That means that the second derivative exists at all points. For our purpose here we want both the first and second derivative to be continuous. The class of all functions which have their first and second derivatives continuous over an interval (a, b) are very important in certain applications and we often denote the class of functions by the symbol C2(a, b). Members of C2(a, b) are said to be twice continuously differentiable.
Examples:(a)
(b) Functions which are differentiable but their derivative is not differentiable are harder to construct. Here is a basic example:
Its graph is shown next.
In order to show it is differentiable at x = 0 and f’(0) = 0 we need to use the limit definition for differentiable. (We skip that here.)
The derivative is The graph of this derivative is shown next. Again it is difficult to show that this function is discontinuous at x = 0 hence, it is not differentiable.
The good news is that in calculus we do not encounter many functions that are not twice continuously differentiable.
Example: It happens that there is any easy familiar set of functions which are differentiable atall orders and all the higher order derivatives are continuous. One such a set is the family of all polynomials. So polynomials belong to the set C2(a, b) for all intervals (a, b), and even (-∞, ∞).
There are a wide variety of applications where “smooth” functions (those that are twice continuously differentiable) are necessary, included are the following:
sails for boats,
patterns for cutting machines,
the layout of roads,
design ofrailway lines,
the shapes of motor vehicles,
ship hull design,
animations,
fluid flow,
air flow,
andCAM and CAD systems (computer aided designs and computer aided manufacturing.
In science and engineering it is often the case that sets of data are collected from experiments and/or measurements instead of there being a formula for a function that describes the process that is under investigation. Part of the job of the group working on the project then is to build a function based on the data which can be used as a model for the process. If we consider the data as a set of ordered pairs like (x, y) or (time, temperature), for example, one way to build a polynomial model P is to require that P(x) = y or P(time) = temperature for all the data points.This type of “matching” technique is called interpolation. The phrase interpolate the data is often used.
Definition of interpolation, interpolate, etc.(in mathematics)
a. To estimate a value of a functionbetweentwoknownvalues.
b. To create a continuousfunctionthatincorporates (a finiteset of data),such as creating a curvethatpassesthrough a fixedset of points or a surfacethrough a fixedset of curves.
An example of interpolation in computing or imaging is to introduceestimatedvalues of (pixeldata)into a pixelarray to improvethequality of an enlargeddigitalimage.
The simplest interpolation process is called Linear Interpolation. An easy description is connectsuccessive points with straight lines assuming that the data is ordered. That is, the x or time values are increasing order. The result of linear interpolation is a continuous curve that is made up of pieces of straight lines. Graphically we can construct the linear interpolant easily in MATLAB.
Example: The following is a set of temperature measurements taken from the cylinder head of a new engine that is being tested for possible use in a race car.
Time, t / 0 / 1 / 2 / 3 / 4 / 5Temperature, ºF / 0 / 20 / 60 / 68 / 77 / 110
To display this data in MATLAB construct two vectors, one for time and the other for temperature. Now plot the data connecting the successive data points with straight lines. See the next figure.
> t=0:5;
> temp=[0 20 60 68 77 110];
> plot(t,temp,'-*k')
This doesn’t produce a formula for the Linear Interpolant.
Explain how to build a formula for this Linear Interpolant.
Often an interpolation model is used to predict an estimate at a point which is not in the data set. MATLAB makes this easy using a command called interp1. For example, if we wanted to estimate the temperature at t = 2.5 and also at t = 4.6 we use the following commands.
interp1(t,temp,2.5), interp1(t,temp,4.6)
The values returned are respectively 64 and 96.8.Explain how you get these estimates without using MATLAB.
Observe that linear interpolation produces a continuous model, but it is “spiky” and is not differentiable at all points in interval [0, 5]. (Source: D. Etter, Engineering Problem Solving in MATLAB)
There are a wide variety of interpolation techniques available to build models from data. Here we focus on a technique called Cubic Spline Interpolation. A formal definition of the process is beyond the scope of our course at this time. A basic description of the cubic spline interpolation follows:
Given an ordered set of data {(x1, y1), (x2, y2), …, (xn+1, yn+1)} where x1 < x2 < …< xn+1} cubic spline interpolation produces a set of n cubic polynomials one for each of the intervals [x1, x2], [x2, x3], …, [xn, xn+1] so that the resulting function is continuous, its first derivative is continuous, and its second derivative is continuous at all values in the interval [x1, xn+1]. That is, the resulting function goes through all the data points and is “smooth”; it is a C2 function that interpolates the data set.
In MATLAB cubic spline interpolation is easy to use as we show next. If we want to plot a cubic spline curve over a range of values, we must generate a new vector of t-values with the desired resolution of the curve in order to graph the cubic polynomials between data points, then determine corresponding temp-values at values in the new vector. See the comments in the MATLAB code below which generates the graph.
> t=0:5;
> temp=[0 20 60 68 77 110]; %original data
> new_t=0:0.1:5; %stepping from 0 to 5 in steps of 0.1
> new_temp=interp1(t,temp,new_t,'spline'); %values of temp from the spline interpolant
> plot(t,temp,'-*k') %plotting linear interpolant
> hold on %hold the graph so we can plot the spline on the linear interpolant
> plot(new_t,new_temp,':b','linewidth',2)
> title('Linear Interpolant and Cubic Spline')
> hold off %releases the graph
Finally we consider the following applied problem.
Path of a Robot Arm Manipulator(Source: D. Etter, Engineering Problem Solving in MATLAB)
The figure shows a robot arm manipulator from aspace vehicle. Manipulator systems like this one and many others on various types of robots use an advanced control system to guide the manipulator arm to desired locations. One of the requirements of such a control system is that the arm must move from one location to another along a smooth path, avoiding sharp jerks that might cause objects to slip out of its grasp or damage the object or the arm itself. Therefore, the path for the arm is initially designed in terms of a number of points over which the arm is to move. Then, interpolation is used to design a smooth curve that will contain all the points. We will consider this problem assuming that the manipulator arm is moving ina plane, although a manipulator arm generally is moving in three-dimensional instead of two-dimensional space.
Code / 0 / 1 / 2 / 3Interpretation / Home position / Intermediate position / Location of object to grasp / Location of object to release
An important part of developing an algorithm or solution to a problem is to consider carefully whether or not there are any special cases that need to be considered. In this problem, we are assuming that the points over which the arm must pass are in a data file or table. We are also assuming also that the points are in the necessary order for the arm to move to a location to grasp an object, to move to a location to release the object, and to move back to the original position. In addition we assume that intermediate points are included in the path to guide the arm away from obstructions or to guide it over sensors that are collecting information. Therefore, each point will have three coordinates-the x and y coordinates relative to the home position of the manipulator arm and a third coordinate coded as follows:
We want to use a cubic spline to guide the manipulator arm to the object, then to the release point and then back to the original position.
x
/y
/Code
/Interpretation
0
/0
/0
/Home position
2
/4
/1
/Intermediate position
6
/4
/1
/Intermediate position
7
/6
/2
/Object-grasp position
12
/7
/1
/Intermediate position
15
/1
/3
/Object-release position
8
/-1
/1
/Intermediate position
4
/-2
/1
/Intermediate position
0
/0
/0
/Home position
A small example has the following set of data that includes the position of the points along the path for guiding the manipulator arm and the code for each point.
The following code produces a graph of the points along the path of the arm. We connect the points with straight lines. (This is not a linear interpolation. Explain why.)
x=[0 2 6 7 12 15 8 4 0];
y=[0 4 4 6 7 1 -1 -2 0];
> plot(x,y,'o-k')
> axis([-1,16,-4,10]) % resets axis to give a bit of empty space around the polygon
title('Path for manipulator Arm')
As we consider the steps in designing the cubic spline path using MATLAB, we will break the path into three paths; from the home position to the object-grasp position, from the object grasp position to the object release position, and from the object release position to the home position. These three paths are chosen for two reasons. First, the manipulator arm must stop at the end of these three paths, so they really are three separate paths. Second, because the cubic spline function requires the x coordinates be increasing we cannot use a single cubic spline reference to compute a path that essentially move in a circle. The x coordinates in each path must be in ascending order, but we will assume that that has been checked by a preprocessing program. The following figures were generated using the program robot_arm.
Sample directions on how to use robot_arm: In MATLAB first construct vectors x,y, and code, then use the program as shown next.
x=[0 2 6 7 12 15 8 4 0];
y=[0 4 4 6 7 1 -1 -2 0];
> code=[0 1 1 2 1 3 1 1 0];
robot_arm(x,y,code) %executes the program