57
New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology -1- v.1.1, F2008 Hydrology 510 Quantitative Methods in Hydrology Motive Preview: Example of a function and its limits Consider the solute concentration, C [ML -3 ], in a confined aquifer downstream of a continuous source of solute with fixed concentration, C 0 , starting at time t=0. Assume that the solute advects in the aquifer while diffusing into the bounding aquitards, above and below (but which themselves have no significant flow). (A homology to this problem would be solute movement in a fracture with diffusion into the porous-matrix walls bounding the fracture: the so-called “matrix diffusion” problem. The difference with the original problem is one of spatial scale.) An approximate solution for this conceptual model, describing the space-time variation of concentration in the aquifer, is the function: = 2 / 1 0 ) , ( vB D x vt x B x erfc C t x C or = ) ( 0 x vt v D B x erfc C C where t is time [T] since the solute was first emitted x is the longitudinal distance [L] downstream, v is the longitudinal groundwater (seepage) velocity [L/T] in the aquifer, D is the effective molecular diffusion coefficient in the aquitard [L 2 /T], B is the aquifer thickness [L] and erfc is the complementary error function. Describe the behavior of this function. Pick some typical numbers for D/B 2 (e.g., D ~ 10 -9 m 2 s -1 , typical for many solutes, and B = 2m) and v (e.g., 0.1 m d -1 ), and graph the function vs. time at a one more locations, x, and vs. space at one or more times, t. Later we’ll examine derivatives and integrals of this function and its parent, which includes details of concentrations in the aquitard. And later still we’ll look at its origin, through solutions of PDEs. aquifer (advection controlled) Flow aquitard (diffusion controlled) aquitard (diffusion controlled) Solute x

Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-1- v.1.1, F2008

Hydrology 510 Quantitative Methods in Hydrology

Motive Preview: Example of a function and its limits Consider the solute concentration, C [ML-3], in a confined aquifer downstream of a continuous source of solute with fixed concentration, C0, starting at time t=0. Assume that the solute advects in the aquifer while diffusing into the bounding aquitards, above and below (but which themselves have no significant flow). (A homology to this problem would be solute movement in a fracture

with diffusion into the porous-matrix walls bounding the fracture: the so-called “matrix diffusion” problem. The difference with the original problem is one of spatial scale.) An approximate solution for this conceptual model, describing the space-time variation of concentration in the aquifer, is the function:

−=

2/1

0),(vBD

xvtx

BxerfcCtxC or

−=

)(0 xvtvD

Bxerfc

CC

where t is time [T] since the solute was first emitted x is the longitudinal distance [L] downstream, v is the longitudinal groundwater (seepage) velocity [L/T] in the aquifer, D is the effective molecular diffusion coefficient in the aquitard [L2/T], B is the aquifer thickness [L] and erfc is the complementary error function. Describe the behavior of this function. Pick some typical numbers for D/B2 (e.g., D ~ 10-9 m2 s-1, typical for many solutes, and B = 2m) and v (e.g., 0.1 m d-1), and graph the function vs. time at a one more locations, x, and vs. space at one or more times, t. Later we’ll examine derivatives and integrals of this function and its parent, which includes details of concentrations in the aquitard. And later still we’ll look at its origin, through solutions of PDEs.

aquifer (advection controlled)

Flow

aquitard (diffusion controlled)

aquitard (diffusion controlled)

Solute

x

Page 2: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-2-

Review of calculus (This is review material, taken and expanded from Carol Ash and Robert B. Ash, The Calculus Tutoring Book, IEEE Press, New York, 1986)

Functions Introduction to functions “A function can be thought of as an input-output machine.” Given a particular input, x, the function f(x) is the corresponding output. Functions are usually denoted by single letters. We’ll often used f and g in this review to denote functions. “If the function g produces the output 3 when the input is 2, we write g(2)=3.” Mathematicians represent this process by a mapping table or diagram, as shown here.

In hydrology the machine can represent a model of a process. Then, for example, x could be location in an aquifer and f(x) spatially variable hydraulic conductivity as a function of location. Or for streamflow, x could be time and f(x) stream discharge as a function of time at a stream gauge location. Or x could be a state, such as pressure or temperature, and f(x) a state-dependent property, such as fluid density or viscosity which are functions of pressure or temperature (this is called an equation of state, or EOS). We often consider forcings as an input x, such as precipitation or solar radiation. For precipitation over a watershed as in input, streamflow at the outlet is a typical output, while for radiation over a land-surface plot as an input, evapotranspiration from that plot back to the atmosphere is a typical output. Inputs can be properties (or parameters), location, time, or forcings. Outputs can be states, fluxes, other properties (or parameters), location, or (travel, residence, or arrival) times.

The input, x, is called an independent variable while the output, f(x), is a called a dependent variable.1 Mathematicians say that “f maps x to f(x), and call f(x) the value of the function at x. The set of inputs x is called the domain of f and the set of outputs is called the range.” 1 In this review of calculus we assume one input and one output. Later we’ll extend the review to multivariate calculus with more that one input and often more than one output. In hydrologic applications the multivariate case is the norm.

Input, x Machine or Model, f Output, f(x)

2 3 8 9 10 -1

Input Output 2 3 8 4 9 4 10 -1

TABLE MAPPING DIAGRAM

4

Page 3: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-3-

Formally, a function f(x) is not allowed to send one input to more than one output.

Consider the domain of x, between the limits a and b. The set of all x such that a ≤ x ≤ b is denoted by mathematicians by [a,b] and is called a closed interval. The set of all x such that a < x < b is denoted by mathematicians by (a,b) and is called an open interval. “Similarly we use [a,b) for the set of x where a ≤ x < b, (a,b] for a < x ≤ b, [a,∞) for x ≥ a, and (-∞,a] for x ≤ a, and (-∞,a) for x < a. In general, the square bracket, and the solid dot in … the figure below … , means that the endpoint belongs to the set; a parentheses, and the small circle in … the figure …, means that the end point does not belong to the set. The notation (-∞,∞) refers to the set of all real numbers.”

Issues to review on your own: Equations v. functions One-to-one functions Increasing and decreasing functions Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples

Constant function f(x) = 2 for all x, g(x) = -π for all x Power function x-1, x0.995, x, x2, x2.7, x12 Trigonometric functions sine, cosine, tangent, secant Inverse trigonometric sin-1 x, cos-1 x, tan-1 x Functions Exponential functions 2x, (1/4)-x, 104, and especially ex, where e = 2.71828 … Logarithmic functions log2 x, log10 x, and especially loge x = ln x

Trigonometric functions Commonly encountered in, e.g.,

Not a function

[a,b] (a,b) [a,∞) (-∞,b)

Page 4: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-4-

-problems with periodic forcing (e.g., diurnal, seasonal, decadal) -cylindrical and spherical coordinates (e.g., radial well hydraulics, intra-particle spherical diffusion and adsorption) -geometric definition of object shapes -certain (finite) spatial domain problems (e.g, Fourier series solutions) Definitions of sine, cosine, and tangent

ry

=θsin , rx

=θcos , θθθ

cossintan ==

xy (1)

where (x,y) = Cartesian coordinates (r,θ) = radial coordinates Radius r is always positive, but the signs of x and y depend on the quadrant, thus the signs of the trig functions also depend on quadrant:

Degrees v. radians We measure angles in both degrees and radians. Recall that an angle θ of 180º = π radians. More generally,

180degrees ofnumber

radians ofnumber π= (2)2

Examples of important angle and related trig functions: Degrees Radians sin cos tan

0º 0 0 1 0 90º π/2 1 0 none 180º π 0 -1 0 270º 3π/2 -1 0 none 360º 2π 0 1 0

2 The equation numbers refer to the numbers in Ash and Ash (1986).

Degrees Radians sin cos tan 30º π/6 1/2 √3/4 √1/345º π/4 √1/2 √1/2 1 60º π/3 √3/4 1/2 √3

x

y

sign of sin θ sign of cos θ sign of tan θ

(x,y)r θ

y

x

Page 5: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-5-

s=rθWe prefer to use radians and, in some cases, we must use radians, such as measuring the arc length along a circle. Let s equal the arc length, a fraction of the circumference. The circumference is 2πr, therefore the arc length is s= θ r, (5) where θ is in radians. Reference angle Trig tables list sin θ, cos θ, tan θ for 0º < θ <90º. To find trig functions for other angles use signs given in the box above, plus reference angles. For example, if θ is in the second quadrant (upper left quadrant) then the reference angle is 180º - θ. In particular, if θ is 150º then the reference angle is 30º. Etc. Right angle trigonometry

hypotenuseleg oppositesin =θ

hypotenuselegadjacent cos =θ (6a,b)

legadjacent leg oppositetan =θ (6c)

Graphs of sin x, cos x, and tan x Exercise: Use Matlab to graph these three functions from x= -4π to +4π Graphs of a sin(bx + c) You should be familiar with: -defns. of amplitude (a), period (2π /b), frequency (b), and phase lag (c) (for example, the phase lag describes a shift (in radians) of the peak). -applications to > harmonic motion > (earth and ocean) tides > approximations to diurnal, seasonal, and other periodic temporal signals

(applications: temperature, evapotranspiration, spring discharge)

Application: A monitoring well on Cape Cod, Massachusetts, located 700m from the Atlantic Ocean coast, observes that water table elevations fluctuate over time. The water level data is fit to the model a sin(bx + c) where a is the amplitude (one-half the total range) of the water level fluctuation, the period is 12 hours, x is time (in hours), and the observed phase lag is 3 hours (compared to the local ocean tide; where for a lag of 3 hours c is expressed in radians = π /2). The ratio of tidal amplitude in the well to that in the local ocean, and the phase lag, are compared to a model of aquifer response to a tidal forcing in order to estimate the aquifer parameters hydraulic conductivity and specific yield. (Similar calculations are performed for other periodic forcings, like earth tides and fluctuating stream stage.)

θ adjacent

opposite hypotenuse

Page 6: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-6-

Graphs of g(x)= f(x) sin x If you need to sketch the function g(x) by hand you would first sketch the curve y=f (x) and the curve y= -f (x), its reflection in the x-axis, to serve as an envelope. Then change the amplitude of the sine curve with x, so that it just fits within the envelop. In addition, reflect the sine curve in the x-axis whenever f (x) is negative. Exercise: Use Matlab to graph the function g for f(x)= exp(-|x|), from x= -4π to +4π

Secant, cosecant, and cotangent

θθ

cos1sec = ,

θθ

sin1csc = ,

θθ

θθ

sincos

tan1cot == (7)

or, for a right triangle:

legadjacent hypotenusesec =θ

leg oppositehypotenusecsc =θ (8a,b)

leg oppositelegadjacent cot =θ (8c)

Notation issues: It is common practice to write sin2x for (sin x)2, and sin x2 to mean sin(x2), etc. Standard trigonometric identities. Below are a few examples of common identities. They illustrate the various categories of identities. See standard math tables (e.g., as referenced on next page) for complete list. (9) Negative angle formulas xxxx cos)cos(;sin)sin( +=−−=− That is, sine is an odd function and cosine is an even function (10) Addition formulas yxyxyx sincoscossin)sin( +=+ (11) Double angle formulas

Application (con’t): The model of aquifer response to tidal forcing, mentioned in the previous box, yields a different solution for each distance ℓ from the ocean. That is the water level response is a(ℓ) sin[bx + c(ℓ)] where the amplitude a and the phase lag c depend on location relative to the ocean. Wells that are closer to the ocean have larger amplitude and smaller phase lag. For example, the amplitude decreases exponentially with distance, a(ℓ) ∝ exp(- ℓ).

Page 7: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-7-

xxx cossin2)2sin( = x

xx 2tan1tan2)2tan(

−=

(12) Pythagorean identities 1cossin 22 =+ xx (13) Half-angle formulas

2cos1

2sin2 xx −

=

2cos1

2cos2 xx +

=

(14) Product formulas

2

)sin()sin(cossin yxyxyx −++=

(15) Factoring formulas

2

sin2

cos2sinsin yxyxyx +−=+

(16) Reduction formulas

θθπ sin2

cos =

(17) Law of Sines

cC

bB

aA sinsinsin

==

(18) Law of Cosines Cabbac cos2222 −= (19) Area formula

Area of triangle ABC = Cab sin21

Reference re Math Tables: Standard reference on algebra, calculus, and matrix methods, and ODEs, but no PDEs:

CRC Standard Mathematical Tables and Formulae, 31st Edition Zwillinger, D., CRC Press, Boca Raton, FL, 2003 (or later edition). see www.crcpress.com for latest edition.

Important note: this class, and all your subsequent hydrology classes, assume that you have your own copy of this or another standard math tables and know how to use it!

A

B

C

a

b

c

Page 8: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-8-

f a b f -1

Inverse functions and inverse trig functions The inverse function Given a one-to-one function, f(a) = b, that maps a to b Then a = f -1(b) is its inverse that maps b to a.

Example: A partial table for f (x) = 3x, and its inverse f -1(x) = x/3 : Exercise: Use Matlab to graph f (x) and f -1(x), for this example, over the domain 1≤ x ≤25, on the same plot. The graph of f -1(x). One of the advantages of an inverse function is that its properties, such as its graph, often follow easily from the properties of the original function. Comparing graphs of f (x) and f -1(x) amounts to comparing points such as (2,6) and (6,2) in the example above. The points are reflections of one another in the line y = x, so that the pair of graphs is symmetric with respect to the line. Exercise: If f (x) = x2, and x ≥ 0 so that f is one-to-one, then f -1(x) = √x. Use Matlab to graph f (x) and f -1(x) for this new example, over the domain 0 ≤ x ≤ 1.2, on the same plot. Also on the plot include the straight line y=x as a dashed line. Common inverses of trig functions are -The inverse sine function (sin-1 x or arcsin x) -The inverse cosine function (cos-1 x or arccos x) -The inverse tangent function (tan-1 x or arctan x)

Exponential and logarithmic functions Exponential functions Examples, 2x, (1/2)x, 7-x

-contrast these with power functions like x2, x1/2, x -7

Note that negative bases, e.g. (-4)x can be a problem. Be careful. Try to avoid. Exercise: Use Matlab to plot example graphs of f (x) =3x, 2x and (1/2)x over the domain -3≤ x ≤+3. Do this in two plots. First, use a linear plot and then a semilog plot (ln[f(x)] v. x).

x f(x) 2 6 5 15 7 21

x f -1(x) 6 2 15 5 21 7

Page 9: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-9-

Most popular bases? Computer science uses base 2. We’ll visit this in lab. Algebra and much of science favors base 10 Calculus, ODEs, and PDEs favors base e Powers and roots (examples) ax ay = a (x + y) (ab)x = ax bx a 1/x = x√a a0 = 1 [if a≠ 0 ] ax / ay = a (x – y) a x/y = y√ax

a -x = 1/ax (ax )y = axy x√ab = x√a × x√b The exponential function ex = exp x and especially e-x = exp -x e is an irrational number between 2.71 and 2.72 (= 2.71828 …) (with a particular defn, in terms of a derivative, to be given later/elsewhere) e or exp is known as “The Exponential Function”

Graph of exp x exp x is defined for all x exp x > 0; in fact, the range of exp x is (0,∞) exp x is an increasing function

Exercise: Use Matlab to plot exp x, and compare to graphs of 2x and 3x, for the domain -3≤ x ≤+3

Exercise: Use Matlab to graph e-x = exp (–x) = 1/(exp x) for the domain 0≤ x ≤+2. Compare on the same plot to Matlab graphs of (1/2)x, x-1 , x-2

The natural log function ln x = loge x

ln x is the inverse of ex ; i.e., ln (ex) = x ln a = b only if eb = a since e0 = 1 and e1 = e, then ln 1 = 0 and ln e = 1

Application: It is common to find hydrologic systems that respond exponentially in time, t. The response function has the form exp(-kt), where k is a rate coefficient (per unit time) and k-1, which has units of time, is sometimes called the “time constant”. Notice this function decreases in time. Example applications include radioactive decay, first order biotransformation of organic contaminants, and discharge from a lake or manmade surface impoundment.

Page 10: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-10-

Graphs of ln x ln x is defined for x > 0; you cannot take the logarithm of a negative number or

zero. The range of ln x is (-∞,∞) ln x is negative if 0 < x < 1, and positive if x > 1 ln x is increasing.

Exercise: Use Matlab to graph ln x for the domain 0 ≤ x ≤+3

Exercise: Use Matlab to graph both ln x and its inverse, ex, on the same plot for the domain -3≤ x ≤+3. Also include on the plot the straight line y=x as a dashed line. The pair of graphs should be symmetric with respect to the dashed line. Note that the function ln x is undefined for x ≤ 0.

Laws of exponents and logarithms ex ey = ex + y ex / ey = ex – y e-x = 1/ex (ex )y = exy baab lnlnln +=

baba lnlnln −=

01lnsinceln1ln =−=

bb

abaa bb ln)(lnln == Logarithms with other bases, especially bases 2 and 10 log2 x is the inverse of 2x

log10 x is the inverse of 10x

Solving equations and inequalities involving ex and ln x To solve the equation ex = 7, take ln of both sides and use ln ex = x to get x = ln 7. To solve the equation ln x = -6, take exp of both sides and use exp(ln x)= x to get x = e-6.

Application: Pumping water from an aquifer results in drawdown of hydraulic head. After a while the time behavior of drawdown in an observation well is approximated by a logarithmic function of the form ln(βt), where β is a coefficient (per unit time) that depends on aquifer properties, and distance away from the pumping.

Page 11: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-11-

-3 -2 -1 0 1 2 3 4 5 6

f is zero

f is negative f is negative

f is positivef is positive

f is zero

f

x

f jumps

Solving inequalities involving ex and ln x requires care, but takes advantage of both ex and ln x being increasing functions.

Combinations (e.g., sums, products, compositions) of elementary functions are elementary functions. Examples: x2+x, x2 sin x¸ xsin

Solving equations and inequalities involving elementary functions Review how to use algebra including factorization and zero finding, exercising special caution for inequalities, such as f(x) > 0, when the functions are not increasing. Example: Solve the equation, 4 ln (2x +5) = 8.

Solution: ln (2x +5) = 8/4 = 2 {divide by 4} 2x +5 = exp(2) {take exp} 2x = e2 -5 {subtract 5} x = (½)(e2 -5) {divide by 2}

Consider the example in the sketch below. The function f is zero at x=-2 and +2. These two points both satisfy the equation f(x) = 0. That is, there are two solutions to this equation; we say that the

solution for the independent variable x is non-unique. (Exercise: Pick another value of f and find the solution(s) for x.)

Notice that to the left of x=-2 the function is positive, as it is between x = +2 and up to +4. At x = +4 and to its right the function is negative. If we seek a solution to the inequality f(x) ≥ 0 the solution is x ≤ -2 and +2 ≤ x < 4. The solution to f(x) < 0 is -2 < x < +2 and x ≥ +4 There are some suggested guidelines for solving inequalities. Illustrated by the sketch, these will be useful later.

x=+2 f=0 x= -2

Page 12: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-12-

Step 1. Find the values of x where f is discontinuous, as at x=4 in the sketch. For an elementary function these typically occur where f is not defined, in practice because of a zero in the denominator (as at x=0 for the function1/x). Step 2. Find the values of x where f is zero, as at x=±2 in the sketch; that is, solve the equation f(x)=0. Step 3. Look at the open intervals in between. On each of these intervals f maintains only one sign. To find the sign you can test one number for each interval.

Exercise: Decide where the function f = (x + 1)/( x - 1) is positive and where it is negative. Then plot in Matlab3.

Graphs of translations, reflections, expansions, and sums In many applications it is useful to understand how the graphs of a function change under transformations, mainly horizontal translations in x, horizontal and vertical expansions, and sum or superposition of functions. Reflections are also encountered. You perform many of these operations when you use a drawing program like Adobe Illustrator or the drawing features in MSWord. In the following examples consider the function y=f(x), then transform it. In the first two examples an operation is performed on the variable x. In the next two the operation is performed on the function , i.e., on the entire right side. The fifth example is a composite operation. Horizontal translation: y=f(x - 3) to translate (shift) the graph (otherwise unchanged) along the x-axis three units to the right.

Example: This is precisely what happens when a solute plume in a river advects downstream without mixing, where x is location along the river, and the product of stream velocity and time equals 3 (in the same distance units as x).

Horizontal expansion: y=f(x/2) doubles the x-coordinates of the graph so as to expand the graph (since it doubles all parts of the graph it also shifts it to the right). 3 You may think “Why don’t I just plot in Matlab first and not try to figure this out in my head at all.” The trouble is that Matlab (and other programs) can be fooled. It is a good idea to have a notion for what a function looks like before trusting a program to plot it. Besides, it helps to improve your reasoning ability and understanding.

Applications: There are many applications in hydrology seeking the solution to an inequality. Where are contaminant concentrations greater than an MCL (regulated “maximum contaminant level”)? At what times during a storm do water levels exceed flood stage? Does the suction (negative pressure head) in a soil the wilting point of vegetation? Some applications involve the design or operation of facilities. These often lead to inequalities, referred to as constraints. Well pumping rates are often constrained by the amount of drawdown they cause. Streamflow releases from dams are constrained by their impact on downstream aquatic life and geomorphology.

Page 13: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-13-

Vertical contraction: y=(1/2) f(x) contracts the y value by a factor of 2. Vertical reflection: y= - f(x) refects the graph in the x-axis.

Example: Suppose y=f(x) represents aquifer drawdown at location x due to a pumping well. Then y= - f(x) represents the negative drawdown, or “drawup,” if the well were used to inject water, instead of pump it, at the same rate.

Composite horizontal translation, horizontal expansion, and vertical contraction

−= 3

221 xfy

reduces the graphs value to one half and expands it horizontally by a factor of two, then corrects for the shift caused by the expansion, and finally translates the resulting graph three units to the right.

This crudely mimics a solute plume in a river that advects downstream while mixing, where the mixing deceases concentration by a factor of one half and spreads it out by the factor of two, thus preserving solute mass.

Warning re f(x -1) v. f(x) – 1. The first of these involves a translation of 1 unit to the right. The second translates the graph down. Graph of f(x) + g(x): simply add the “heights” of the respective functions. Use Matlab to plot sin(x), cos (x), and their sum, over the domain x= -4π to +4π.

Some more advanced functions We encounter a large family of more advanced functions in hydrology. Three of the most common advanced functions are mentioned here. Advanced functions can sometimes be found in standard math tables, while the best reference for them is the more advanced and highly cited Abramowitz and Stegun, Handbook Mathematical Functions, Dover Press, New York, 1964. This handbook was originally published by the U.S. National Bureau of Standards, now call NIST (National Institute of Standards and Technology). NIST is currently organizing a web-based successor to the NBS Handbook, called the Digital Library of Mathematical Functions (DLMF). The web site for this uncompleted project is http://dlmf.nist.gov/. Advanced functions can also be found in Matlab (see the specfun directory), Maple, and Mathematica software, but Abramowitz and Stegun remains the main reference. We’ll use the routines in Matlab (from the specfun directory) for the functions below. Error Function, erf x, and Complementary Error Function, erfc x = 1 – erf x, are commonly encountered in groundwater flow, solute transport, and heat transport as a solution to a parabolic partial differential “diffusion” equation4. 4 We’ll learn about these equations, and the meaning of terms like “parabolic”, later in the semester.

Page 14: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-14-

∫ −=x t dtex

0

22 erfπ

the error function

xdtexx

t erf12 erfc2

−== ∫∞ −

π complementary error function

erf (-x) = -erf x Graph of erf x:

erf x is defined for all x erf x > 0 and erfc x > 0 the range of erf x and erfc x is (0,1) erf x is an increasing function; erfc x is a decreasing function ;0erfclim;1erflim ==

∞→∞→xx

xx

2erfclim;1erflim =−=−∞→−∞→

xxxx

Exercise: Using Matlab graph erf x and erfc x on the same plot over the domain -2≤ x ≤+2 Exponential Integral, Ei(x) and E1(x) Ei (x) is most commonly encountered in aquifer well hydraulics. The commonly used model for transient drawdown in response to pumping is called the Exponential Integral Model or the Theis Equation. There are two different, alternative definitions for the exponential integral. The first5,

∫∫ ∞−

−∞

=−=x t

x

t

dtt

edtt

ex)Ei( , x>0 , exponential integral function,

where t is a dummy variable of integration, is the version encountered in well hydraulics. The other version is

∫∞ −

=x

t

dtt

exE )(1 , x>0

The two versions are related by )(-)(Ei 1 xEx =− Note that Matlab uses E1, the second definition, and calls that funcition expint. You need to transform it using this last equation to get Ei. But you have to be careful. From the Matlab help page for EXPINT(x): By analytic continuation, EXPINT is a scalar-valued function in the complex plane cut along the negative real axis. Another common definition of the exponential integral function is the Cauchy principal value integral from -Inf to X of (exp(t)/t)

5 We assume x is real here, but the exponential integral is more generally defined for complex arguments, z=x+iy, as is clear in the relationship between the two definitions given in Matlab.

Page 15: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-15-

dt, for positive X. This is denoted as Ei(x). The relationships between EXPINT(x) and Ei(x) are as follows: EXPINT(-x+i*0) = -Ei(x) - i*pi, for real x > 0 Ei(x) = REAL(-EXPINT(-x)), for real x > 0

Exercise: Using Matlab graph Ei(x) and –Ei(-x) on the same plot over the domain 0≤ x ≤+2. The second of these graphs represents the Theis Well Function (see box). Bessel Function of the first kind6, Jn(x) Bessel functions are commonly encountered in problems involving a radial geometry, such as in well hydraulics, or flow of water to a tree root in the vadose zone. Bessel functions constitute a family of functions. For illustration purposes we mention only the Bessel Functions of first kind. Bessel Function of the first kind of integer order n are defined by

∫+Γ=

πθθθ

π 0

2

21

21

sin)coscos()(

)()(21 dx

nxxJ n

n

n , x>0,

where Γ is the gamma function,

∫∞ −−=Γ

1

1)( dtetz tz , Re(z > 0),

with corresponding specific values for zero and first order Bessel Functions of 21

)( 21 π=Γ and

21

21

21 )( π=Γ , respectively. In particular the zero order function is

∫=π

θθπ 00 )coscos(1)( dxxJ

In the limit, as x→0, )1(

)(~)( 21

+Γ nxxJ

n

n

6 The Bessel Function argument can be complex, z=x+iy, although we won’t be considering that case.

Application: The space-time distribution of drawdown, s [m], near a fully penetrating pumping well in a homogeneous, isotropic, confined aquifer of infinite extent, is given by the Theis model,

)(4

)(Ei4

),( uWT

QuT

Qtrsππ

=−−= , TtSru

4

2

= , ),(Ei)( uuW −−=

where Q [m3s-1] is the pumping rate, r [m] is radius from the well, t [s] is time, T [m2s-1] is aquifer transmissivity, S [-] is the aquifer storage coefficient, u [-] is a dimensionless similarity variable, and W(u) is the “Theis Well Function”. Note: this problem has two independent variables, s and t. It’s an example of multivariate calculus and the solution of a (parabolic) partial differential equation.

Page 16: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-16-

Exercise: Using Matlab graph J0(x) (besselj in Matlab) and K0(x) (besselk) on one plot, for the domain 0 < x ≤ 10, where K0(x) is the Modified Bessel function of the second kind of order zero (i.e., another Bessel Function).

Application: Suppose the confined aquifer, mentioned in the previous box, is leaky. That is, bounding the top of the aquifer is an aquitard and above that is a phreatic aquifer. Pumping the confined aquifer will induce leakage through the aquitard, recharging it from above. Eventually, the pumping will be balanced by leakage and the drawdown in the confined aquifer will reach a steady state. That equilibrium drawdown is described by a Modified Bessel function of the second kind of order zero:

)(K2 0 βπ

rT

Qs = , '

'K

TB=β ,

where β [m] is a “leakage coefficient”, B’ [m] is aquitard thickness, K’ [m s-1] is the vertical hydraulic conductivity of the aquitard, and s, Q, r & T were defined in the previous box. The plot of )(K0 βr shows how drawdown varies with location and leakage coefficient.

Page 17: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-17-

Limits Limits are used to describe:

1. discontinuities 2. the ends of graphs where x→∞ , x→ -∞ 3. asymptotes 4. definitions for derivative and integral (later)

Limits are commonly encountered in hydrology, for example, when examining conditions near or very far from boundaries, when considering what happens as time tends to infinity, and when considering whether property values can be considered constant or must be allowed to vary.

Introduction Limit definition for function f(x) Lxf

ax=

→)(lim

if, for all x sufficiently close to, but not equal, to a, f(x) is forced to stay as close as we like, and possibly equal to L.

Review on your own: One-sided limits Infinite limits Limits as x→∞ , x→ -∞ Limits of continuous functions Various types of discontinuities, especially jumps and “blow ups” Exercise: Consider limits for the sketch:

Exercise: What happens near x = -∞, -3, -2, 0, +2, +4, +6, +∞ ?

Limits for combinations of functions Review finding limits of combinations of functions. Find the limits of components of the expression and put them together sensibly.

Example: xx exx

2ln5lim

2

0

+++→

= 2

)(50 −∞++ =2∞− = ∞−

-3 -2 -1 0 1 2 3 4 5 6

f

x

3 2 1 0 -1 -2

A solid dot means that the point belongs to the set; and the small circle means that the point does not belong to the set.

Page 18: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-18-

Recall that in taking limits of components you end up with sums, products and quotients which must be resolved, as in the example above. Some more examples from Ash and Ash (1986), in which each term is the result of a “sublimit”:

0 × 0 = 0 ∞ - 4= ∞ 0 + 0 = 0 ∞/8 = ∞ 0/3 = 0 -2 × ∞ = -∞ 40 = 1 ∞∞ = ∞ 5/0+ = +∞ ∞ + ∞ = ∞ 5/0- = -∞ ∞ × -∞ = -∞ 3∞ = +∞ 2/-∞ = 0

Warnings: A limit problem of the form 2/0 does not necessarily have the answer ∞. Rather 2/0+ = +∞ while 2/0- = -∞. In general, in a problem of the form (non 0)/0 it is important to examine the denominator carefully.

Indeterminate limits Limits of indeterminate form are commonly encountered:

00 ,1,)0(),()(,,0,0,,,,,00

∞−∞−−∞∞−∞−∞×∞×∞∞

∞∞

∞∞

∞∞ ∞+

Each of these can be resolved. None are truly “indeterminate”. We can use the rule below, for some problems. Others require differential calculus (later). Highest power rule Uses the following principles:

1. As x → ∞ or x → -∞, a polynomial has the same value as its term of highest degree. For example, )232(lim 24 −++

−∞→xxx

x= )(lim 4x

x −∞→= ∞

2. As x → ∞ or x → -∞, a quotient of polynomials has the same limits as the quotient …

rdenominato in degreehighest of term

numerator in degreehighest of term

which cancels to an expression whose limit is easy to evaluate.

For example, 476

1lim 23

35

++−++

−∞→ xxxxx

x= 3

5

6lim

xx

x −∞→=

6lim

2xx −∞→

= +∞

Page 19: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-19-

The Derivative I Preview From freshman physics and calculus recall the concepts of Velocity and Slope:

Velocity of a particle = change in position / change in time ≅ [f(t+∆t) – f(t)] / ∆t Slope of the line f(x) =y is given by the change in y-coordinate / change in x-coordinate, or

slope ≅ [f(x+∆x) – f(x)] / ∆x , or slope =∆y / ∆x = tangent ≅ secant (uses B and A) (if ∆x is “small enough”)

What is a positive slope? negative slope? zero slope?

A= (x, f(x))

B=(x+∆x, f(x+∆x))

tangent secant

Negative slope Positive slope

Zero slope

Applicaton: A number of “diffusion like” fluxes in hydrologic applications are driven by a gradient (slope of a state variable, such as solute concentration, with respect to distance). A flux density is an intensive measure of an amount of “something” passing through a surface, per unit time per unit area. Fluxes of solute mass due to diffusion are described by Fick’s First Law where solute mass flux density [kg m-2 s-1] = -Dm dC/dx. where C [kg m-3] is concentration, x [m] is location, d( )/dx [m-1] is the gradient “operator”, and Dm [m2 s-1] is a diffusion coefficient. That is, the diffusive flux of solute is driven by a concentration gradient. Notes: (a) Notice the negative sign in Fick’s Law. Why? (b) The units of each variable have been written out in SI units. Observe that the units on the left and right hand sides of Fick’s Law are in balance. Balancing units is a useful way to check an equation and its solution for errors.

Page 20: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-20-

Definition and some applications of the derivative

Definition of the derivative of f(x) : x

xfxxfxfdxdf

x ∆−∆+

==→∆

)()(lim)('0

Recall the difference between speed and velocity where speed = |velocity|. The speed gives the magnitude but not the direction (of slope), while the velocity gives both magnitude and direction. Exercise:

Notation: if y=f(x) then the derivative can be written as:

( )dxdyoryDffDxf

dxd

dxdfxff x ,',,),(,,','

In hydrology we typically use the notation dxdyorxf

dxd

dxdf ),(,

A more physical interpretation of the derivative f ' (x) is instantaneous rate of change of f wrt x, where the “average rate of change” of f wrt x, in the interval between x and x+∆x, is

x

xfxxfxf

dxdf

∆−∆+

==)()(

in change in change

-3 -2 -1 0 1 2 100 101

-3 -2 -1 0 1 2 100 101

f

x

f '

x

Graph of y=f ' (x)

Graph of y=f (x)

A

C

E

A

B

C

D

DE

Use the letters to identify the following for the function f(x):

Largest positive slope?

Largest negative slope?

Zero slope?

Zone of small negative

slope?

Zone(s) of ~ constant slope

~ Point(s) of inflection

Concave up

Concave down (f '' issue)

B

Page 21: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-21-

Higher derivatives: The second derivative of f , denoted by f '', is the instantaneous rate of change of f ' wrt x.

Notation: ( ) 2

222

2

2

2

2

,'',,),(,,'',''dx

ydoryfDfDxfdxd

dxfdxff x

Typical application from freshman physics: Acceleration, the derivative of velocity Warning: if f '' is positive then it is not necessarily true that the object is speeding up. Units: example from acceleration, unit of accelerations are m2 s-1, while units of speed or velocity are m s-1. Concavity measure: concave up (f '' positive), concave down (f '' negative), straight line (f '' zero) Point of inflection: a point at which f '' changes sign. Examples: see graphs on previous page

Applications: Other “diffusive” fluxes, or gradient laws, are heat conduction (Fourier’s Law, which describes a diffusive flux of thermal energy due to a temperature gradient), viscous momentum diffusion (Newton’ Law of viscosity, which describes the diffusive flux of fluid momentum due to velocity shear gradients), and groundwater flow (Darcy’s Law, which describes the hydraulic diffusive flux of porous media flow due to gradients of hydraulic head). Insomuch as these processes, and Fick’s Law, have the same math but different physics they are called homologies. Other processes invoking a similar homologous model include turbulent diffusion (momentum, mass, and thermal fluxes due to turbulent velocity fluctuations), dispersion in rivers (due to velocity variations across the channel cross-section), and mechanical dispersion and macrodispersion in aquifers (due to upscaling and averaging of velocity fluctuations caused, respectively, by pore structure/connectivity and aquifer heterogeneity). In all of these models the flux is proportional to the gradient of a state (e.g., concentration, flux density [amount m-2 s-1] = - coefficient × gradient temperature, or velocity), with a proportionality coefficient that must be determined empirically. For example, with Darcy’s Law we observe fluid fluxes (specific discharge) and head gradients and take their ratio to get an estimate of hydraulic conductivity, the proportionality coefficient for that expression.

Page 22: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-22-

Derivatives of basic, elementary functions (consider their graphs) Derivative of a constant function

0.)(=

dxconstd , or written in another notation, Dx(const) = 0

Derivative of the functions x and xr

1)(=

dxxd ; 1)( −= r

r

xrdxxd

Derivative of sin x, cos x, and other trigonometric functions

xdx

xd cos)sin(= ; x

dxxd sin)cos(

−= ; xdx

xd 2sec)tan(=

Radian vs. degrees? Radians preferred (it’s easier).

Derivative of ex, and definition of e:

Defn. of e: “e is the base such that the graph of bx , where b is a fixed positive number, has a slope of one at the point (0,1).” This also leads to the definition of the derivative of e.

xx

edxde

dxxd

==)exp( or, Dx ex = ex

The derivative of an inverse function

dydxdx

dy 1=

Applicaton: Recall the box on Fick’s First Law, using the symbol N to represent flux density. Then N = dxdCDm− . How can we use this to find out how much flux changes with location x? Take the derivative of N:

dxdN =

dxdCD

dxd

m [kg m-3 s-1]

If Dm is constant, move it outside the outer derivative, or

dxdN =

{2

2

0

dxCdD

dxdC

dxdD

dxdC

dxdD m

mm −=−

=

If the diffusion is steady (doesn’t change in time) and if there are no sources or sinks of solute, then N should be constant and its derivative zero. Under this condition we expect that 022 =dxCd . For this special case, this is a model of conservation of solute mass.

Page 23: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-23-

It’s used to find derivatives for ln x, sin-1x, cos-1x, now that we have derivatives of ex, sin x and cos x. For example, … Derivative of ln x

Let y = ln x, then x=ey and xedyde

dydx y

y

=== .

Thus xe

dydxdx

dydx

xdy

111)(ln==== or Dx ln x =1/x

Derivatives of inverse trigonometric functions, use the same idea.

Table of basic derivatives7 … Dx c = 0 Dx sin x = cos x

Dx x = 1 Dx cos x = - sin x Dx sin-1 x =

211

x−

Dx xr = r xr-1 Dx tan x = sec2 x

Dx ln x = 1/x Dx cot x = -csc2 x Dx cos-1 x =

211x−

Dx ex = ex Dx sec x = sec x tan x

Dx csc x = - csc x cot x Dx tan-1 x = 21

1x+

Non-differential functions Discontinuous functions

If f is discontinuous at x=x0, then f is not differentiable at x=x0. (Equivalently, if f is differentiable then f is continuous).

Cusps A cusp arises when a graphs is continuous (in value) but suddently changes direction (so that the curve is not “smooth”), and in this case f is not differentiable. Differentiability is a more exclusive property that continuity. A differentiable function is continuous but a continuous function is not necessarily differentiable. Leads to piecewise continuous functions.

7 Be cautious with the tables presented in these notes. They have not been proofed nearly as well as what you will find in standard math tables and, in any event, they are not complete. You should probably refer to standard tables instead, when solving problems. In any event, if you find an error in these notes bring it to my attention.

Page 24: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-24-

Derivatives of constant multiples, sums, products and quotients Constant multiple rule for c f(x), where c is a constant: Dx (c f ) = c Dx f = c f ' Sum rule for the derivative of f(x)+g(x): Dx (f + g) = Dx f + Dx g = f ' + g' Product rule for derivative of f(x)g(x): Dx (f g) = f Dx g + g Dx f = f g'+ g f ' Warning: don’t differentiate f and g separately and multiply Product rule for more than two factors, e.g., three factors: Dx(f g h) = f g h' + f g' h + f 'g h

Quotient rule for the derivative of f(x)/g(x): Dx (f /g) = 2ggDffDg xx − = 2

''g

gffg −

Derivative of a function “with two formulas”; do it by “intervals”

Example: Suppose f(x) = |ln x|. Then f(x) = ln x when ln x ≥ 0, but f(x) = -ln x when ln x < 0. Thus

≥<<−

=1 ifln

10ifln)(

xxxx

xf so that,

≥<<−

=1 if/1

10if/1)('

xxxx

xf

Derivative of a composition The chain rule for the derivative of a composition y=y(u) is

dxdu

dudy

dxdy

=

or, stated another way for function f, Dxf(u(x)) = f '(u) u'(x) Example:

f(x)A B

CEExercise:

What is happening at the indicated points? D

x

A solid dot means that the point belongs to the set; and the small circle means that the point does not belong to the set.

Page 25: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-25-

What is d(sin x2)/dx? Let y = sin x2. Then u=x2 and y = sin u. The derivatives are dy/du = cos u and du/dx = 2x. Thus d(sin x2)/dx = cos u ⋅ 2x = 2x cos x2

Warning: don’t omit a step in this approach.

Table of basic derivatives incorporating the chain rule: Dx ur = r ur-1 u'(x) Dx sec u = sec u tan u ⋅ u' (x)

Dx ln u = )('1 xuu

Dx csc u = - csc u cot u ⋅ u' (x)

Dx eu = eu u'(x)

Dx sin u = cos u ⋅ u' (x) Dx sin-1 u =

211

u− ⋅ u' (x)

Dx cos u = - sin u ⋅ u' (x)

Dx tan u = sec2 u ⋅ u' (x) Dx cos-1 u =

211u−

− ⋅ u' (x)

Dx cot u = -csc2 u ⋅ u' (x)

Dx tan-1 u = 21

1u+

⋅ u' (x)

Implicit differentiation and logarithmic differentiation Implicit differentiation

Example: What is the slope of the graph of y3 – 6x2 = 3 at the point (-2,3)? This equation defines y(x) implicitly. Solve algebraically for y to obtain y = (6x2 + 3)1/3. This equation expresses y explicitly as a function of x. We can take the derivative of this explicit function and apply it at the subject point to get the desired slope. Try it. The answer is -8/9. But you don’t have to approach the problem this way. In fact there are many cases where you won’t be able to transform an equation to an explicit form. You can find the derivative y' implicitly. Recall the implicit equation, y3 – 6x2 = 3. Differentiate with respect to x on both sides of the equation. In this procedure y is treated as a function of x, so that the derivative of y3 with respect to x is 3y2y' by the chain rule. Thus …

Page 26: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-26-

3y2y' – 12x = 0 y' = 12x /3y2 = 4x /y2

y'(-2,3) = 12⋅(-2) /3⋅32 = -24 /27 = -8/9

yielding the same slope as the explicit approach. The process of finding y' without first solving for y is called implicit differentiation. Be careful, don’t omit extra occurrences of y' demanded by the chain rule.

Logarithmic differentiation Given a function y=f(x) whose base is not e (e.g., not ex) and with an exponent that contains the variable x. Two examples are 2x and (sin x)x. Derivatives of this type of function are approached by first taking the logarithm of both sides of y=f(x) and then finding f ' by implicit differentiation. The approach is called logarithmic differentiation. Example: Consider y=(sin x)x. Take the log of other sides to obtain ln y = x ln (sin x) This describes y implicitly but does so without any exponents. Differentiate implicitly and use the product rule on x ln(sin x) to get

xxxxxxxx

dxxd

xx

dxxdx

dxxdxy

ysinlncotsinln

sincossinln)(sin

sin1)(sinln)sin(ln'1

+=+=+=⋅+=

Therefore,

)sinlncot()(sin)sinlncot(')(sin xxxxxxxyydx

xd xx

+=+==

Antidifferentiation Above we concentrated on the differentiation process of finding f ', given f. Now let’s reverse that and seek the function f, given the derivative f '. The process is called antidifferentiation and has several types of application, including integration.

Commonly encountered antiderivatives of basic functions: constanta for stands where kCkxdxk +=∫ (1)

Cxdxx +−=∫ cossin (2)

Cxdxx ++=∫ sincos (3)

Page 27: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-27-

Cxdxx ++=∫ expexp or Cedxe xx ++=∫ (4)

1,1

1

−≠++

=+

∫ rCrxdxx

rr (5)

0,ln1≠+=∫ xCxdx

x (6)

Cedxe xx +=∫

Less commonly encountered antiderivatives of basic functions:

Cxdxx +=∫ tansec2 (7)

Cxdxx +−=∫ cotcsc2 (8)

Cxdxxx +=∫ sectansec (9)

Cxdxxx +−=∫ csccotcsc (10)

Cxdxx

+=−

−∫ 1

2sin

11 (11)

Cxdxx

+=+

−∫ 12 tan

11 (common in gw hydrology) (12)

Antiderivatives of elementary functions dxxfcdxxfc ∫∫ = )()( (13)

and dxxgdxxfdxxgxf ∫∫∫ +=+ )()()]()([ (14)

So, for example,

dxxgcdxxfcdxxgcxfc ∫∫∫ +=+ )()()]()([ 2121

Extending known antiderivative formulas In general, if F(x) is an antiderivative of f(x), then

CbaxFa

dxbaxf ++=+∫ )(1)( (15)

In other words, if x is replaced by ax+b in (1) – (12), anti-differentiate “as usual” but insert the extra factor 1/a. Example: Consider ∫cos(πx + 7) dx, which is of the form in (15), where a=π, b=7, and f = cos( ). Apply (15) to find

Page 28: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-28-

Cxdxx ++=+∫ )7sin(1)7cos( ππ

π

Check by taking the derivative of the RHS (right hand side). Introduction to parametric equations When a process is described by two dependent variables, say x and y, and their equations x(t) and y(t) in terms of a third variable, in this case t, the equations are parametric equations and the third variable is called the parameter. The most common appearance on parametric equations involves kinematics, such as keeping tracking of a fluid parcel or tracer packet as it moves through a multidimensional hydrologic system. You’ve encountered this problem before, in freshman physics … Example: Consider the ballistic model of a bullet fired from a gun. The acceleration, velocity, and position of the bullet are, respectively, described by the following expressions (in English units of feet and seconds, otherwise not shown). They assume that the gun muzzle is aimed at an angle of 30° with the horizontal and that the muzzle velocity is 60fps. From the initial muzzle velocity and muzzle orientation, and given Earth’s gravity, the acceleration at all times and the initial velocity in both the horizontal and vertical directions is known. The velocity at later times (t) and the position (x,y) is determined by sequential antidifferentiation.

Vertical movement:

y''(t) = -32 for all t y'(t) = -32 t + 30 y(t) = -16 t2 + 30 t + 40 (17)

Horizontal movement:

x'(t) = 30 √3 for all t > 0 x(t) = 30 √3 t (18)

Equations (17) and (18) are parametric equations and t is the parameter. If (18) is solved for t and substituted into (17) we have a non-parametric equation for y(x), height as a function of horizontal distance, the path of a parabola.

403675

440330

30330

16)(22

++−=+

+

−=

xxxxxy

Page 29: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-29-

x1 x2 x3 x4 x5 x6 x7

The Derivative II Relative maxima and minima It is useful for a wide variety of reasons to be able to locate the “peaks” and “valleys” of a function. Definition of relative extrema A function has a relative maxima at x0 if f(x0) ≥ f(x) for all x near x0. A function has a relative minina at x0 if f(x0) ≤ f(x) for all x near x0. Where are the relative minima and maxima in the graph? If f is differentiable and f has a relative extreme value at x0 then f '(x0) = 0. Equivalently, if f '(x0) is a nonzero number then f cannot have a relative extreme value at x0. On the other hand, if f ' (x0) =0, then a relative extreme value may (see x2, x3, x4) but need not (see x1) occur. Critical numbers If f '(x0) = 0 or f '(x0) does not exist then x0 is called a critical number. Includes all relative minima, relative maxima, and possible nonextrema (see x1, x6, x7 ) as well. First derivative tests Let f be continuous. To identify a critical number x0 as a relative minima or maxima, examine the sign of the first derivative to the left and right of x0. Example: f(x) = 4x5 - 5x4

- 40x3

Set f '(x0) =0 and solve for critical numbers (the roots). f '(x0) = 20x4 - 20x3

- 120x2 = 20x2 (x2 - x – 6) = 20x2 (x - 3) (x + 2)

x = 0, 3, -2 are the critical points Now examine the sign of f '(x) between the critical points.

Page 30: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-30-

Second derivative tests Applicable to critical points x0 at which f '(x0) =0. (1) If f '(x0) = 0 and f '' (x0) < 0 then f has a relative maximum at x0. (2) If f '(x0) = 0 and f '' (x0) > 0 then f has a relative minimum at x0. (3) If f '(x0) = 0 and f '' (x0) = 0 then no conclusion can be drawn. Continuing previous example where critical points are x = 0, 3, -2 and f(x) = 4x5 - 5x4

- 40x3 f '' (x0) = 80x3 - 60x2

- 240x

f '' (-2) = -400 ; f '' (0) = 0 ; f '' (3) = 900

Suggesting that x = -2 is a local maxima, x = 3 is a local minimum, and we can draw no conclusion about the other point.

Application: How do apply these maxima and minima concepts in hydrology? Here are three types of application.

i. First, consider physical extrema. Suppose the function f represents topography and x represents map coordinate. A local maxima defines a ridge top and drainage divide, while a local minima defines the drainage, which is often the location of a stream. In groundwater hydrology, the local maxima of a water-table aquifer is the water table divide, separating subsurface flow systems, which the local maxima of solute concentration in a contaminant plume identifies the spine of that plume.

ii. For our second type of application imagine designing an engineered facility, like a well

field, contaminant remediation scheme, or dam on a stream. These problems are often set up to (globally) maximize or minimize some objective function such as cost, benefits, or frequency of failure, where x is called a decision variable and represents the design choices being made, such as size of the dam or location and pumping rate for a well. These are called design optimization problems.

iii. The third application type refers to using data to build and parameterize (assign

numbers to parameters) a hydrologic model. The parameters, represented by x, are varied until some measure of model performance, represented by f, approaches an extreme value. The performance measure is usually a sum of squared differences between observed and modeled states, like head or flow rate, and we seek an absolute or global minima. This application is called an inverse problem since you are “solving” for parameters given states, rather than the other way around.

Page 31: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-31-

-3 -2 -1 0 1 2 3 4 5

9 1

MAX

MIN

Absolute maxima and minima As mentioned in the box, we often we want to find the absolute or global maxima or minima, not the local values. Finding maxima and minima Restrict x to the interval of interest, then the absolute maxima or minima will lie at …

(a) A critical value of f - Solve for f '(x)= 0 and also locate places where derivative does not exist. - Let f (x0) represent the resulting list of critical values. - This candidate list contains the relative maxima and minima, as well as other values.

Expand the candidate list to also include: (b) The end values of f (ends of the interval)8 (c) Infinite values of f.

Example: Find maximum value of f(x) = x4 + 4x4

- 6x2 – 8 for 0 ≤ x ≤ 1

- Note that f is continuous in the interval [0,1]

- Find critical values of f in [0,1] ; get x = 0, 2

213±−

- Given the constrained domain [0,1] for x, keep only the two positive roots,

f(0) = -8 and f(2

213+− ) ≅ f(0.79) ≅ -9.4. The largest of these is f(0).

8 When solving an optimization or inverse problem (see box) we often define constraints which restrict the domain of the decision variable x (i.e., the dam can be only so big or the parameter value can’t exceed such-and-such a value). These constraints can be somewhat arbitrary. When the solution lies on one of these constraints then we may have to ask if the domain size has been overly restricted.

Page 32: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-32-

- Find end points; for x = 0, f(0) = -8 is both a critical and an end point; for the end point x = 1, f(1) = -9.

- Evaluate f at critical values and end points; f(0) = -8, f(0.79) ≅ -9.4, f(1) = -9.. - - Pick x for largest f, that f is the maximum value and the corresponding x is its

location: f(0) = -8, the largest value of f in the domain [0,1] is -8 and its located at x=0.

Warning: sometimes we seek f and sometimes x at the maximum (or minimum)

L’Hopital’s Rule and orders of magnitude A way to evaluate indeterminant limit forms. L’Hopital’s Rule

Suppose )()(lim

xgxf

ax→ is one of the inderterminant forms

∞−∞−

∞−∞

∞∞−

∞∞

00 ,

that is, involving indeterminate quotients. Then …

Switch to )(')('lim

xgxf

ax→

If the new limit is L , ∞, or -∞, then the original limit is L, ∞, or -∞, respectively. If the new limit does not exist because f '(x)/g'(x) oscillates badly then we have no information about the original quotient. L’Hopital’s rule doesn’t help in this situation. If the new limit is still an indeterminate quotient, L’Hopital’s rule may be used again. The rule is also valid for limit problems in which x→a+, x→a-, x→ ∞, x→ -∞ Warning: L’Hopital’s rule applies only to indeterminant quotients. Is should not be used (nor is it necessary) for limits in the form of 2/∞ (the answer is immediately zero) or 3/0- (the answer is immediately -∞) or 6/2 (the answer is immediately 3) and so on. Examples:

Find xxx

xxx 352

563lim 23

23

−+−+

∞→ which is of indeterminate form ∞/∞ [Ans: 3/2]

Page 33: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-33-

Find x

xx

sinlim0→

which is of indeterminate form 0/0 [Ans: 1]

Order of magnitude

Suppose f(x) and g(x) both approach ∞ as x→∞ so that )()(lim

xgxf

x ∞→ is of form ∞/∞.

If the limit is ∞ then f(x) is said to be a higher order of magnitude than g(x), that is, f grows faster than g. If the limit is 0 then f(x) is said to be a lower order of magnitude than g(x), If the limit is a positive number L then f(x) and g(x) have the same order of magnitude. “Pecking order” of functions that approach ∞ as x→∞, listing them in increasing order of magnitude, from slower to faster: xexxxxxxxx ...,,,,,,...,,)(ln,)(ln,ln 322/332 (4) Order of magnitude of a constant multiple: In general, f(x) and cf(x) have the same order of magnitude for any positive constant c. Highest order of magnitude rule. In general, as x→∞ (only), a quotient involving functions on the list in (4) has the same limit as

rdenominato thein magnitude oforder highest the withterm

numerator thein magnitude oforder highest the withterm

For example,

−∞=−=−

=∞∞−

=+−

∞→∞→∞→ 333 limlim2

3limxe

xe

xxe x

x

x

x

x

x

Since ex has a higher order of magnitude than x3.

Indeterminant products, differences, and exponential forms For the forms 0 × ∞, or 0 × -∞ use algebra or a substitution to transform to a quotient form and apply L’Hopital’s rule. Warning: Don’t use L’Hopital’s rule indiscriminately. Also, verify your result whenever possible. For the forms ∞ - ∞, or (-∞) - (-∞), use other methods. For the forms (0+)0, ∞0, 1∞, use logarithms to change exponential problems into products.

Page 34: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-34-

Newton’s Method Newton’s method uses calculus to try to solve equations of the form f(x) = 0. Solving f(x) = 0 is equivalent to finding where the graph of the function f(x) crosses the x-axis. Procedure:

- Guess a root of f, calling the first guess x1. - Draw a tangent line to the graph of f at the point (x1, f(x1)). - Let x2 be the x-coordinate of the point where the tangent line crosses the x-axis. - Now start again with x2. - Draw a tangent line to the graph of f at the point (x2, f(x2)). - Let x3 be the x-coordinate of the point where the new tangent line crosses the x-axis. - Now start again with x3, and so on.

The numbers x1, x2, x3, … will approach the root if the method is convergent, or if not, x1, x2, x3, … will diverge. See figures. More often than not the method is convergent (it converges “exactly” if f is quadratic or linear in x). If it is not convergent, try another initial guess. The equation (point-slope formula) for a tangent line is ))((')( 111 xxxfxfy −=− .

Set y=0 and solve for x to find that when the line crosses the x-axis, )(')(

1

11 xf

xfxx −= .

This value of x is taken to be x2. Generalize to the procedure:

)last (')last (last new

xfxfxx −= , or for iteration counter n,

)(')(

1n

nnn xf

xfxx −=+

Exercise for later: We’ll apply this method using Matlab, using standard Matlab Newton routines and also writing our own programs.

Root x2 x1 x3 x2 x3 x1

(x1, f(x1))

(x2, f(x2))

Root

Convergent Divergent

Page 35: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-35-

Differentials Recall the definition of a differential dy = f '(x) dx = change in y when x changes by dx. (1’) Example: d(sin x) = cos x dx, that is, the differential of sin x is cos x dx. If x changes by dx then sin x changes by approximately cos x dx. Example:

The volume of a sphere is V= (4/3)πr3, where r is its radius. What about a spherical shell? volume of a spherical shell = vol. outer sphere – vol. inner sphere

= 33

34)(

34 rdrr ππ −+ = ])(

31)([4 322 drdrrdrr ++π (6)

where the inner sphere is of radius r, and the outer sphere has a larger radius, r + dr. To find an approximate formula use the differential, drrdV 24π= (7) Note that this equals the first term in (6) and is the desired approximation. It is often easier to find such an approximation, using (1’) than it is to solve the problem exactly. The difference between (7) and (6) is the error of the approximation, here equal to

ε = ])(31)([4 32 drdrr +π

which is small if dr is small and approaches zero as dr → 0.

Application: Most fundamental models of hydrologic processes involve conservation of mass, momentum, and/or energy. Sometimes we use an extensive model dealing with amount of these quantities over a spatially lumped model of, for example, a hydrologic body like a plot, hillslope, watershed, river reach, lake, aquifer, region, continent, or even the entire planet. More often we use a spatially distributed, intensive model, where states like hydraulic head, fluid velocity, thermal energy, and solute concentration vary over space, and we examine intensive quantities (usually quantity per unit area or unit volume). To develop these distributed models we use differentials. We use them to describe how fluxes of mass, momentum or energy change in space, where in equation (1’) y is the flux density and x is location, or to describe how intensive quantities vary over time, where y is the amount of a quantity per unit volume (or area) and x is time.

Page 36: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-36-

Separable differential equations It is often possible to separate the variables in the (DE) differential equation dy = f '(x,y) dx, so that the equation has the differential form (expression in x) dx = (expression in y) dy Then the equation is called separable, and is solved by antidifferentiating both sides. (This works on first order equations only !!!!) We call this approach separation of variables (SOV). Example:

Consider the DE )(

)(' 2 xyxxy = . Rewrite as xxyxy =)(')(2 .

Integrate (antidifferentiate) both sides to yield Cxy += 23

21

31 .

More conventionally and conveniently, 2yx

dxdy

= , leading to separation as xdxdyy =2 .

Then antidifferentiate, dxxdyy ∫∫ =2 to get Cxy += 23

21

31 .

These are implicit solutions for y. You can solve algebraically to get explicit solutions. Example: exponential decay or growth …

This type of problem occurs widely in hydrology. For example, decay can be due to radioactive decay or 1st order biotransformation or hydrolysis of an organic compound, both of which involve decay of concentration. Another application is discharge from an aquifer to base flow in a stream, or discharge from a lake, where water levels “decay” over time (approximately) exponentially. In all these cases the rate of change of something (the dependent variable) depends on the quantity of that something remaining. As the quantity decreases over time the rate of change slows down. This type of decay is called exponential decay, as is made apparent below. If, on the other hand, something is added and the quantity is increasing over time, according to this model, it is called exponential growth. In the exponential decay model the rate of change of the dependent variable, y, with respect to time, t, is described by9

kydtdy

−=

where k is a rate coefficient10. The model also needs an initial value (IV) of y. Call the IV y(t=0) = y0. Solving by SOV we get

9 The minus sign on the RHS is significant; it leads to decay instead of growth. 10 For example, in radioactive decay the coefficient k is a linear function of radioactive “half-life”.

Page 37: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-37-

dtkdyy

−=1

Ctky +−=ln Using the IV to determine constant C,

Cy += 0ln 0

0lnln ytky +−=

tkyyyy −==−

00 lnlnln

tkeyy −= 0 The dependent variable decays exponentially in time. The dependent variable, y, starts with the initial value y0 and decays exponentially to zero. Exercise: Plot ratio y/y0 using Matlab for three different values of k = 0.5, 1, 2 for the domain 0 ≤ t ≤ 5. Suppose instead of decaying, the process is one of exponential growth of say, population, y (people and their demand for water, bacteria, etc). If λ represents the growth rate constant, then the model is

ydtdy λ+=

You should be able to show that the population is described by )(

00tteyy −+= λ

where the initial value, at time t0, is y(t= t0) = y0.

Page 38: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-38-

The Integral I Preview Integrals appear as models themselves or as part of solutions to models. Often we define new functions (e.g., Erf and Ei) to replace integrals which frequently appear in these solutions. Integrals as models or their solution appear in the calculation of time, length, area, and volume, and in extensive properties like the amount of mass, energy and momentum, or their fluxes. Integrals appear in calculating the amount of something (an extensive quantity) or, by dividing by the interval over which it is calculated, the average amount of something (an intensive quantity, e.g., a flux density) over that interval. Integrals appear in moment equations, and are used to calculate physical moments (like the moment of inertia) or probabilistic moments (like the variance, or square of the standard deviation, which is a second central moment).

Definition and some aspects of the integral The integral is defined by

∑∫ →= dxxfdxxf

dx

b

a)(lim)(

0 (1)

For a simplistic, but useful viewpoint, we can ignore the limit and consider ∫b

adxxf )( as merely Σ

f(x)dx, found using many subintervals of [a,b]. In other words, think of the integral as adding many representative values of f, each value weighted by the length of the subinterval it represents (i.e., the dx’s can vary, as sketched below).

∫b

adxxf )( ∑ dxxf )(

The process of computing the integral is referred to as integration. The integral symbol is an elongated S for “sum” (the same symbol is used in a different context for antidifferentiation). The symbols a and b attached to the it indicate the interval of integration. The numbers a and b are called the limits of integration, and f is called the integrand. The sums of the form Σ f(x)dx are called Reimann sums.

a b dx a b

f(x)

Page 39: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-39-

Consider the application of integrals and average values:

Average value of f in [a,b] = ab

dxxfb

a

−∫ )(

(3)

Think of the numerator as the weighted (dx) values and the denominator as the sum of the weights, b-a = Σdx’s. Some properties of the integral

∫ +b

adxxgxf )]()([ = ∫

b

adxxf )( + ∫

b

adxxg )( (9)

∫∫ =b

a

b

adxxfkdxxfk )()( , where k is constant (10)

∫∫∫ =+c

a

c

b

b

adxxfdxxfdxxf )()()( , if a<b<c (11)

Reminder about dummy variables

∫2

0

3dxx is a number, without the variable x appearing anywhere in the answer. Could also write it as

∫2

0

3dtt or ∫2

0

3daa . The letter x (or t or a) is called a dummy variable because it is entirely arbitrary.

In general, ∫b

adxxf )( = ∫

b

adttf )( = ∫

b

aduuf )( , and so on.

The Fundamental Theorem of Calculus The Fundamental Theorem If f is continuous on [a,b] and F is an antiderivative of f, then

)()()( aFbFdxxfb

a−=∫ (1)

Example 1: ?3

0=∫ dxx

290

29

21 3

0

23

0=−==∫ xdxx

Example 2: Suppose x2/2 + 7 is the antiderivative of x¸ rather than x2. (Why not? 7 is an arbitrary constant.)

29)70()7

29()7

21(

3

0

23

0=+−+=+=∫ xdxx

The 7 cancels out.

Page 40: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-40-

Example 3: ?12

1 2 =∫ dxx

21)1(

2111 2

1

2

1 2 =−−−=−=∫ xdx

x

Integral of a constant function: )( abkdxk

b

a−=∫ (2)

Integral of a zero function: 00 =∫

b

adx (3)

Integral of a piecewise function11 with several formulas.

Suppose

≥−<<+

≤=

7 if1773 if32

3 if)(

2

xxxx

xxxf

To find ∫10

0)( dxxf use (11) of previous section.

∫∫∫∫ −+++=10

7

7

3

3

0

210

0)17()32()( dxxdxxdxxdxxf

= 10

7

27

3

23

0

3

)2

17()3(3

xxxxx−+++ = 9+52+25.5 = 86.5

Definite v. indefinite integrals The symbol ∫ is used in two different and distinct ways.

• First ∫b

adxxf )( is an integral, defined as the limit of the Reimann sum Σ f(x)dx. In this

context dx stands for the length of a typical subinterval of [a,b]. The symbol ∫ is used to signify summation.

• Second, ∫ dxxf )( is the collection of all antiderivatives of f(x). In this context, the symbol

dx is an instruction to antidifferentiate with respect to the variable x. The symbol ∫ is used because one of the methods of computing an integral (using the Fundamental Theorem of calculus) begins with antidifferentiation.

11 One important application of integration of piecewise functions is in finite element numerical models.

Page 41: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-41-

Frequently, both ∫b

adxxf )( and ∫ dxxf )( are referred to as integrals; in particular, ∫

b

adxxf )( is

called an definite integral, while ∫ dxxf )( is called an indefinite integral (rather than integral and

antiderivative). No matter which terminology you choose, it will always be true, for example, that

Cxdxx +=∫ 323 , where C is an arbitrary constant, while

1933

2

2 =∫ dxx

Numerical integration

The evaluation of )()()( aFbFdxxfb

a−=∫ seems like it should be simple, but it is often difficult

and sometimes impossible to find an antiderivative F. We then resort to numerical integration to approximate the (definite) integral. A variety of numerical integration techniques exist, each involving lots of arithmetic, almost always done on a computer. All are approximate and have errors. For some methods it is possible to calculate a theoretical estimation of the errors. For others you simply increase (e.g., double) your resolution, try again, and see how much improvement you get. In calculus you learned about three of these. The first is simply Riemann Summation for finite size dx. The second is the trapezoidal rule. The third is Simpson’s rule. Later we’ll introduce Guassian Quadrature and possibly other methods. Riemann sums: approximate the integral by a series of steps (rectangles). In essence each dx is assumed to have a constant value of f, a constant function. Trapezoidal rule: approximate the integral by a series of trapezoids. In essence you are approximating f over each increment dx by a straight sloped line, that is, a linear function, defined by the value of f at each end of the increment.

Simpson’s rule: approximate the integral over two neighboring increments, fitting a parabola, that is a quadratic function, to the three values (circles in the sketch) of f defining each of the two increments. For the two increments fit a quadratic to the left, middle and right values of the function. Then move on to the next pair of intervals and repeat. If the dx’s are constant (equally spaced), then it can be shown that

a b a b

Rieman Sum Trapezoidal Rule Simpson’s Rulea b

Page 42: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-42-

)42...2424(3

)( 1243210 nnn

b

ayyyyyyyyhdxxf ++++++++≈ −−∫

where h = dx, the size of the x increment. There is no easy error estimator for Simpson’s rule.

Nonintegrable functions Suppose f(x) = 1/√x, and you want to integrate it from 0 to 1, by computing the Riemann sum. What value of f do you apply for the first increment, which has its left edge on zero? What happens when you change dx? Discontinuous functions can be nonintegrable. However, some discontinous functions can be integrated using the following:

Improper integrals For intervals of the form [a, ∞), (-∞,b], (-∞,∞)

Example: ?11

=∫∞

dxx

→ ∫∫ ∞→

∞=

b

bdx

xdx

x 11

1lim1

i.e., to integrate on [1,∞), integrate from x=1 to x= b and then let b approach ∞.

∞=−∞=−===∞→∞→∞→

∫∫ 0)1ln(lnlim)ln(lim1lim1111

bxdxx

dxx b

b

b

b

b

In general,

∫∫ ∞→

∞=

b

abadxxfdxxf )(lim)( and ∫∫ −∞→∞−

=b

aa

bdxxfdxxf )(lim)(

In abbreviated notation, if F is an antiderivative of f then

∞∞=∫ aa

xFdxxf )()( and bbxFdxxf

∞−∞−=∫ )()(

Convergence vs. divergence. Evaluating an improper integral always involves computing an ordinary integral and taking a limit. If the limit is finite, the integral is said to be convergent. If the limit is plus or minus infinity, or no value at all, the integral diverges.

Example: ?12

2 =∫−

∞−dx

x ANS: ½, convergent

Page 43: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-43-

Integrating on the interval (-∞,∞) The usual definition is

∫∫∞→−∞→

∞−=

b

aba

dxxfdxxf )(lim)( or ∞

∞−

∞−=∫ )()( xFdxxf

Example: πππ=−−==

+∞

∞−

−∞

∞−∫ )2

(2

tan1

1 12 xdx

x

Integrating functions which blow up at the end of the interval of integration.

If f blows up at x = a then )()()( +−=∫ aFbFdxxfb

a

If f blows up at x = b then )()()( aFbFdxxfb

a−= −∫

Integrating functions which blow up within the interval of integration. Suppose that a< c < b, and that f blows up at c, then

b

c

c

a

b

c

c

a

b

axFxFdxxfdxxfdxxf

+

+

−+=+= ∫∫∫ )()()()()(

The Integral II Integrals with variable upper limit Suppose we define a new integral

∫=x

adttfxI )()( (2)

Some functions of this form are

∫ −=x t dtex

0

22 Erfπ

error function (3a)

xx Erf1 Erfc −= complementary error function (3b)

∫ ∞−

=x t

dtt

ex Ei exponential integral function (3c)

∫=x

dtt

tx0

sin Si the sine- integral function (3d)

Page 44: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-44-

Computing I(x). If f(t) has a readily available antiderivative, then an explicit formula for I(x) may be found by using the Fundamental Theorem of calculus.

Example: 13)( 3

1

3

1

2 −=== ∫ xtdttxIxx

If f has a simple graph it may be possible to find I(x) by integrating f in sections. The derivative of I(x) Often sought. Example, if W(u)= - Ei(-u) gives well drawdown, its derivative gives groundwater velocities needed to compute fluxes, flowpaths, and travel times. The derivatives of I(x) wrt x are given by the integrand used in the original formulation of I(x). This

is not a coincidence. In general, if I(x) = ∫x

adttf )( then I’(x)= f(x) at all points where f is continuous.

In other words, if a continuous function f is integrated with a variable upper limit x, and then the integral is differentiated with respect to x, the original function is obtained. This result is called the Second Fundamental Theorem of Calculus.

Example: d [erfc(x)] /dx = d1/dx - d [erf(x)] /dx = 0 - ∫ −x t dtedxd

0

22π

=22 xe−−

π

Example: d [Ei(x)] /dx = xedt

te

dxd xx t −

∞−

− −=− ∫

Page 45: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-45-

Antidifferentiation Introduction Standard tables, such as the CRC, contain only a limited number of antiderivatives12. Differentiation is easier. There are many rules to help us (sums, products, quotients, compositions), but in antidifferentiation there are fewer rules. There are no product, quotient or chain rules for antidifferentiation. The best we have are sum and constant multiple rules.

dxxfcdxxfc ∫∫ = )()( (1)

dxxgdxxfdxxgxf ∫∫∫ +=+ )()()]()([ (2)

In the absence of sufficient rules we consult tables of antiderivatives, but even the large volumes of tables13 that you find in the library have their limits. You need to know how to “extend” them and the simpler tables you find in a text book or the CRC math tables. Below we review some basic methods to achieve this “extension”.

Substitution Example: What is ∫ dxxx 2cos2 ? We can find it from the derivative.

By the chain rule, 22 cos2sin xxxDx = so that we know that Cxdxxx +=∫ 22 sincos2 .

But how can we find the antideriviative formula without seeing the derivative first? (For example, because we don’t have the derivative already and we can’t find it in the tables.) Reverse the chain rule to simplify to a form in the tables of antiderivatives. The chain rule for the derivative of a composition y=y(u) is

dxdu

dudy

dxdy

=

In this example, use the device u=x2, du=2x dx. Substitute this into the integral to get

CxCuduudxxx +=+== ∫∫ 22 sinsincoscos2

More examples:

12 The antiderivative tables presented earlier in these notes are but a faint shadow of even the most basic tables, such as you will find in the CRC tables, or a good calculus textbook. You’ll need to consult those tables and not rely only on these notes. 13 There are two readily available exhaustive references for antiderivatives and also for an army of definite derivatives: Gradshteyn, I.S. and I.M. Ryzhik, 1980, Table of Integrals, Series, and Products, Academic Press, New York, NY.; Rectorys, K., 1969, Survey of Applicable Mathematics, MIT Press, Cambridge, MA.

Page 46: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-46-

1. ∫ +dx

xx

24

3

)72(; let u2 =2x4+7 and x3dx =(1/8)du. Ans: C

x+

+ )72(814

2. ∫ xdxx sincos2 ; let u =cos x and du= -sin x. Ans: Cx +− 3cos31

Comment: There is no set rule on when or what to substitute. One useful tactic is to search the integrand for an expression whose derivative is a factor in the integrand, and let u be that expression. In example 1, the expression 2x4+7 has the derivative x3 (give or take an 8), which is a factor. In example 2, the expression is cos x; its derivative is sin x (give or take a negative sign) and is a factor. More than one substitution may work.

Some Algebra including proper/improper fractions & partial fraction decomposition Sometimes you can use algebra to reduce a function to another function listed in the tables. Example 1:

CxxCuau

duua

dxx

dxx

xua

+

++=+++

=+

⋅=+

=+

==

=

∫∫∫

2

2/1

22

/21 a tables;std. in isformula this

2222

21ln

61)ln(

61

16

12/1

16

136

1

2

244 844 76

Improper fractions

Improper fractions, such as 22

5

++ xxx , are those where the degree of the numerator is greater or

equal to the degree of the denominator. Proper fractions, such as 1

32 +x

x , are those where the

degree of the numerator is less than the degree of the denominator. The improper kind are rarely listed in the antiderivative tables. To find an antiderivative for an improper fraction that is not listed, begin with long division (divide out the improper fraction).

Example 2: Consider ∫ ++ 22

5

xxdxx .

Divide out14 the improper fraction integrand:

3

2

23

52+−−

++xxx

xxx with remainder 2

62 ++

−−xx

x

That is, the integrand is expanded as the sum of a polynomial and a proper fraction:

14 Refer to your algebra basics for details.

Page 47: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-47-

fractionproper lpolynomina fractionproper 2

632 2

232

5

+=++

−−++−−=

++ xxxxxx

xxx

(3)

Let’s integrate the polynominal,

Cxxxxdxxxx ++−−=+−−∫ 3234

)3(234

23 (4)

Now for the proper fraction, break it up into digestible pieces,

2

622

6222 ++

−++

−=++

−−xxxx

xxx

x

Then integrate

Cxxx

xxdxxx

xxdxx

++

+++−=

+++++−=

++−

∫∫

712tan

712ln

21

2212ln

21

212

22

2

(6)

and

Cxxx

dx+

+−=

++− −∫ 7

12tan712

26 1

2 (7)

Finally combine (4), (6), and (7),

∫ ++ 22

5

xxdxx = xxxx 3

234

234

+−−7

12tan711 1 +−

− − x 2ln21 2 ++− xx +K

Partial Fractions Tables often omit proper fractions as well, when the denominator is greater than 2. Partial fraction decomposition is an algebraic technique that helps in this and other several other applications we will visit later regarding ordinary and partial differential equations. In each instance it is easier to work separately with the partial fractions than with their sum. We want to decompose a proper fraction which is not in the tables into a sum of partial fractions which are either in the tables or which may be antidifferentiated by substitution or inspection. The decomposition is accomplished in several steps.

Step 1. Factor the denominator as far as possible.

Step 2. The nature of the decomposition depends on the factors in the denominator. - If a factor is linear, such as 2x+3, then a fraction of the form A/(2x+3) appears as one of

the partial fractions.

Page 48: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-48-

- If a non-factorable quadratic, such as x2 + x + 10 appears in the denominator then

102 +++xx

BxA appears in the decomposition.

- If a repeated non-factorable quadratic, such as (x2 + x + 10)4 appears in the denominator

then

4232222 )10()10()10(10 +++

++++

++++

++++

xxHxG

xxFxE

xxDxC

xxBxA

appears in the decomposition. Step 3. Determine A, B, C, … in the decomposition (various methods; see example for one method)

Example:

Decompose )1)(2)(3(

132 2

−++−+

xxxxx and then antidifferentiate. The denominator has already

been factored, accomplishing step 1. Regarding step 2, the three factors in the denominator are all linear, so each has a partial fraction consisting of a constant divided by the respective linear function. Thus

)1)(2)(3(

132 2

−++−+

xxxxx =

123 −+

++

+ xC

xB

xA

Multiply this equation by the denominator, )1)(2)(3( −++ xxx , to get )2)(3()1)(3()1)(2(132 2 +++−++−+=−+ xxCxxBxxAxx (3) This equation is suppose to hold for all x, so we can solve it by taking three arbitrary but convenient numerical value for x. Values -3, -2, 1 are convenient because each of them set two of the three terms in (3) to zero.

If x = -3, then 8 = 4A, A = 2 If x = -2, then 1 = -3B, B = -1/3 If x = 1, then 4 = 12C, C= 1/3

We could use any three values and solve the resulting three equations simultaneously, but it wouldn’t be as convenient. The result is

)1)(2)(3(

132 2

−++−+

xxxxx =

13/1

23/1

32

−+

+−

+ xxx

We can down antidifferentiate this term by term using tabulated antiderivatives.

dxxxx

xx∫ −++

−+)1)(2)(3(

132 2

= Kxxx +−++−+ 1ln312ln

313ln2

Page 49: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-49-

Integration by Parts The idea behind integration by parts is to reverse the derivative product rule. Since Dxuv=uv’ + vu’ we have the integration formula ∫(uv’ + vu’)dx=uv. But problems don’t usually originate in this form, so we continue to a more useful version of the integration formula. Write it is ∫uv’dx= uv - ∫ vu’dx, and to make it easier to apply, use the differential notation dv=v’dx, du=u’dx to get duvuvdvu ∫∫ −= (1)

With this formula you trade one problem for another, which may or may not help depending on how good a trader you are. To apply (1) a factor in the integrand must be called u. The rest of the integrand, including the “factor” dx is labled dv. Success of the method, called integration by parts, depends on being able to find v from dv (this is itself antidifferentiation) and on being able to find ∫ v du. Example: ∫ xdxex cos

Let u= ex and dv = cos x dx. Then du= exdx and v= sin x, and

∫∫ −= xdxexexdxe xxx sinsincos

That’s doesn’t appear to be helpful, but let’s stick with it and apply integration by parts again, to the second term on the RHS. Let u= ex and dv = sin x dx. Then du= exdx and v= -cos x, to get )coscos(sincos ∫∫ +−−= xdxexexexdxe xxxx

The integral on the RHS is our original integral, which seems circular. But note that it now appears on both sides of this equation. Collect terms involving this integral to get

)sincos(21cos xexexdxe xxx +=∫ +C

Recursion formulas Some antiderivative formulas, said to be recursive, can be applied repeatedly without a problem in order to get an answer (especially for forms sinm x and cosm x). Example: ∫ dxxx sin3

Many tables list the pertinent formula ∫∫ −− −−+−= dxxxnnxnxxxdxxx nnnn sin)1(sincossin 21

Applying that here with n=3 ∫∫ −+−= dxxxxxxxdxxx sin)2(3sin3cossin 233

This last integral is usually available in tables and we can finish the job.

Page 50: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-50-

x

a u

22 xa +

Trigonometric substitution A collection of integrals in the tables can be found using a substitution of a special type called a trigonometric substitution. These are based on angle substitutions, e.g.,

2222sin,cos,tan

xaxu

xaau

axu

+=

+==

xxau

axau

xau

2222

csc,sec,cot +=

+==

Example:

{ Cxa

xxa

aCuu

a

duua

duua

uauaxax

dx

+++

−=++−=

−=⋅

=+ ∫∫∫

22

tablesmath standard from

2

22

ln1cotcscln1

csc1sec

costan

1

where x=a tan u yields dx = a sec2u du, and u

axacos

22 =+ .

Choosing a method If a function is not listed in the tables:

(a) Complete the square if the problem involves cbxax ++2 but the only similar formula in the tables does not contain the term x

(b) Substitute if there is an expression in the integrand whose derivative is also a factor in the integrand.

(c) Use long division on improper fractions (d) Decompose proper fractions if they aren’t in the tables (e) Use integration by parts to get recursion formulas. Integration by parts may also work when

other methods don’t seem to apply. (f) If a problem involving 22 xa ± or 22 ax − is not in the tables, try trigonometric substitution.

Series Series representations are useful for a variety of reasons. For example, we may have a complex function that is difficult to work with, but if we represent it by a series we can work with each of the simpler terms in that series (integration, differentiation). We may also find that only the first few terms of the series are all that is needed to approximate the function, making it ever easier. For example, drawdown in a confined aquifer can be represented by an Exponential Integral (Theis

Page 51: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-51-

Well Function), but if enough time has elapsed (typical in application) the higher order terms of the series representation of the Exponential Integral are unimportant. The lower order terms involve a logarithm. Drawdown can then be approximated by a logarithm (the “Jacob Approximation” of well hydraulics). Note: The following review is superficial, but it highlights issues of concern. Consult your calculus text for details.

Introduction The symbol a1 + a2 + a3 + a4 + … is called a series with terms a1, a2, a3 , a4, …

Also written as ∑∞

=1nna or even Σ an.

Partial sums of this series are S1 = a1 S2 = a1 + a2 S3 = a1 + a2 + a3 etc If partial sums approach a number S, that is, if SSnn

=∞→

lim , then S is the sum of the series, and we

write Σ an = S. In this case the series is called convergent; in particular, it converges to S. Else the series is divergent.

Example: K++++=∑∞

= 161

81

41

21)

21(

1n

n has

1615

161

81

41

21,

87

81

41

21,

43

41

21,

21

4221 =+++==++==+== SSSS , etc.

Or, 1lim =∞→ nn

S , and the series has sum 1, that is, converges to 1. We write 1)21(

1

=∑∞

=n

n .

Two convergent series can be added, term by term.

51...

2561

641

161

41

1...161

81

41

21

=+−+−

=++++ →

56...

25615

649

163

43

=++++

Dropping initial terms

Page 52: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-52-

If the first m terms of a series are dropped, then the new series and the original series will both converge or both diverge. In other words, chopping off the beginning of a series doesn’t change convergence or divergence. It does change the sum of a convergence series.

Geometric series

Form: ∑∞

=0n

nar = 0...,432 ≠+++++ aarararara

is called a geometric series with ratio r. Geometric series test. Has simple criterion for convergence and, if the series converges, the sum is easily found.

If r ≥ 1 or r ≤ -1 then ∑∞

=0n

nar diverges

If -1 < r < 1 then ∑∞

=0n

nar converges to r

a−1

Example: 25)

51(3

0

=−∑∞

=n

n

(Application? For example, geometric series are encountered in probability theory.)

Convergence Tests Positive series All positive terms; Four rules to test convergence. Not reviewed here. Standard series

Increasing order of magnitude: !,...,100,2...,,,,,,...,,)(ln,)(ln,ln 322/332 nnnnnnnnn nn

Reciprocals: 1/ !/1,...,100,2...,,,,,,...,,)(ln,)(ln,ln 322/312/132 nnnnnnnnn nn −−−−−−−−− The entries approach 0 as n →∞. The order of magnitude decrease reading from left to right. That is, they approach zero more rapidly.

Subseries of a positive convergent series If Σan is a positive convergent series then every subseries also converges. Limit comparison test Suppose that an and bn , both positive, have the same order of magnitude. Then Σan and Σbn act alike in the sense that either both converge or both diverge

Page 53: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-53-

Alternating series

Let an be positive. A series of the form ∑∞

=

+−1

1)1(n

nna = a1 - a2 + a3 - a4 + … is called a alternating

series. The partial sums of a positive series are increasing, so a positive series either converges or else diverges to ∞. But the partial sums of an alternating series rise and fall since terms are alternately added and substracted; therefore an alternating series either converges, diverges to ∞, diverges to -∞, or diverges but not to ∞ or -∞. Alternating Series Tests. nth term test for divergence:

• If an doesn’t approach 0 then the series diverges. (The partial sums oscillate but are not damped, and hence do not approach a limit.)

• If the series converges then an →0. • If an does approach zero, then the alternating series may converge or may diverge. More

testing is necessary. • If the series diverges then an may or may not approach 0.

Alternating series test:

Consider the alternating series ∑∞

=

+−1

1)1(n

nna . Suppose an →0. Then the series converges to a sum S

between 0 and a1. Furthermore, if the last term of a subtotal involves addition, then the subtotal is greater that S; if the last term of a subtotal involves subtraction then the subtotal is less than S. In either case if only the first n terms are used, then the error, the difference between the subtotal Sn and the series sum S is less than the first term not considered. In other words, |S - Sn| < an+1 . Absolute convergence. Another way to test an alternating series is to remove the alternating signs and test the positive series. If it converges then the alternating series also converges. Conditional convergence. If Σ|an | diverges it is still possible for Σan to converge. In this case Σan is called conditionally convergent. …

Power series ...4

43

32

210 ++++++ xaxaxaxaa Sometimes used to create a new function when elementary functions are inadequate, for example, to solve an ode. That is, assume a power series form for the dependent variable. Solve the resulting algebric equations to satisfy the ode and define the coefficients ai . The resulting series solution essentially defines a new function. Many advanced functions originated this way. Caution. The new function may converge for only a limited interval; you must tests for convergence.

Page 54: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-54-

Power series representations of elementary functions15 It is also useful to have power series expansions for old functions. Polynomials are easy to work with and representing an old function as an “infinite polynomial” is often convenient. Consider a few examples of power series expansions of simple functions. The derivation (not given) of these examples depends on finding a connection between the desired function, f(x), and a known expansion. Example: Consider first the following power series which is also a geometric series:

...11

1 432 +++++=−

xxxxx

for -1 < x < 1 (1)

Binomial series

...!3

)2)(1(!2

)1(1)1( 32 xqqqxqqqxx q −−+

−++=+ for -1 < x < 1 (4)

Another example, this one of an alternating series:

...5432

)1ln(5432

−+−+−=+xxxxxx for -1 < x < 1 (10)

Maclaurin Series We seek a less arbitrary approach to finding a series representation of a function. Given the power series ...)( 4

43

32

210 ++++++= xaxaxaxaaxf A Maclaurin series has coefficients

!

)0()(

nfa

n

n =

It can be shown that there are two possibilities. Either f has no power series of this form (i.e., with these coefficients) or

...!3

)0(!2

)0(!1

)0(!0

)0()( 32 +′′′

+′′

+′

+= xfxfxffxf

This expression can be used to find power series representations of lots of elementary functions. Here are some typical results.

15 See standard math tables for a listing of various power series representations and their interval of convergence.

Page 55: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-55-

...!7!5!3

)sin(753

+−+−=xxxxx for all x (3)

...!6!4!2

1)cos(542

+−+−=xxxx for all x (4)

...!4!3!2

1)exp(432

+++++==xxxxex x for all x (5)

Taylor series introduction The Taylor Series approach is used more often by hydrologists than any other. It is fundamental to developing conservation models for mass, momentum and energy, to various solution methods including the finite difference method, and to making extrapolations and predictions. Its fundamental feature is that it provides an error estimate for its approximations. Here we first use it to derive the value of e. In the next section we introduce the Taylor Series as it is familiar to hydrologists. Suppose we set x=1 in the power series for ex. Then

...!4

1!3

1!2

111 +++++=e (1)

We can approximate e by a partial sum of the series, but since the series does not alternate we don’t have an error bound. How can we introduce an error bound for the Maclaurin series and use it for this special case? Suppose that x is fixed and f(x) is approximated by the beginning of its Maclaurin series, that is, by a Maclaurin polynomial, say of degree 8:

8)8(

32

!8)0(...

!3)0(

!2)0(

!1)0(

!0)0()( xfxfxfxffxf ++

′′′+

′′+

′+≈

If the series alternates then the first term omitted (the 9th term in the series, in this example) supplies the error bound. But whether or not the series alternates, the error in the approximation can be

bounded as follows. Consider all possible values of 9)9(

!9)( xmf for m between 0 and x, and find the

maximum of the values. Taylor’s remainder formula states that the error, in absolute value, is less than or equal to that maximum. In general, the error (in absolute value) in approximating f(x) by its Maclaurin polynomial of degree n is less than or equal to the maximum value of

1)1(

)!1()( +

+

+n

n

xn

mf (2)

Page 56: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-56-

for m between 0 and x. Returning to the problem of approximating e, we can use a graphical method (not shown here) to get a crude estimate which we then refine with Taylor approach. The graphical approach, based on integrating 1/x, yields the estimate that 1 < e < 4. Now suppose we add the first five terms (1) to get

708.2!4

1!3

1!2

111 =++++=e (3)

To estimate the error of this approximation, consider (2) with f(x) = ex, x = 1, n = 4 (since we added terms through x4 in the series for ex), and 0 ≤ m ≤ 1. Then f (5)(x) = ex and

!5

1)!5(

)( 5)5( memf

=

Since 1 < e < 4, the maximum occurs when m=1, and that maximum is less than 4/5! or 1/30. Therefore the approximation in (3) is less than 1/30. Furthermore, when the expansion in (1) stops somewhere, all the terms omitted are positive, so the approximation in (3) is an underestimate. By adding more terms it can be shown that 2.718281 < e < 2.718282.

Taylor Series in powers of x-b Certain basic functions, like ln x, √x, and 1/x, can’t be expressed as a power series of the form Σanxn, because they have derivatives that blow up at x=0. Other functions which have a power series form converge too slowly. These limitations can be overcome by considering a power series of the form

...)()()()( 33

2210

0

+−+−+−+=−∑∞

=

bxabxabxaabxan

nn (1)

called a power series about b. The previous section consider the special case for b = 0. For this more general case the Maclaurin series has coefficients

!

)()(

nbfa

n

n =

If f does not blow up, or have derivatives which blow up, at b, it has the power series representation

...)(!3

)()(!2

)()(!1

)(!0

)()( 32 +−′′′

+−′′

+−′

+= bxbfbxbfbxbfbfxf (2)

which is called a Taylor series for f about b. The partial sums of (2) are called Taylor polynomials. Graphs of successive Taylor polynomials are a line, a parabola, a cubic, and so on, tangent to the graph of f(x) at point (b, f(b)). They supply better and better approximations to the graph. The Taylor series converges more rapidly if x is near b, and more slowly if x is far away. In application, there is a trade off: keep (x-b) small and use a only a couple of terms in (2), or increase (x-b) and use more terms.

Page 57: Hydrology 510 Quantitative Methods in Hydrology...Elementary functions (all of which are common functions in hydrology; also, see the elfun directory in Matlab) Type Examples Constant

New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-57-

Application: In the finite difference method of solving a differential equation for heat transport, the temperature, T, at location x is related to the temperature at location b=x-∆x, where ∆x is the spacing of adjacent finite difference node points at which temperature is to be calculated. Then with x-b=∆x we can write (2) as

2)(11

)()( xOdxdTxxxTxT

xx

∆+∆

+∆−

=∆−

where the higher order terms have been truncated, and the order of their approximation indicated by the last term on the RHS. Solving for the temperature gradient we have

2)()()( xOx

xxTxTdxdT

xx

∆+∆

∆−−=

∆−

which is then used to approximate the gradient in Fourier’s law of heat conduction, and to provide an estimate of the error in the approximation. Similar finite difference approximations are used for solute diffusion and dispersion, groundwater flow, and other gradient driven processes.