New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

aquitard (diffusion controlled)

Flow aquifer Solute (advection controlled)

aquitard (diffusion controlled)

x 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:

1/ 2  x  x  D   C  x D  C(x,t) = C0 erfc    or = erfc   B vt − x vB  C B v(vt − x)      0   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 .

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 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.

-1- v.1.1, F2008 New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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. TABLE MAPPING DIAGRAM Input Output 2 3 2 3 8 4 8 4 9 4 9 10 -1 10 -1

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.

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

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.

-2- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

Not a function

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.”

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

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.,

-3- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

-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 y (x,y) y x y sinθ sinθ = , cosθ = , tanθ = = (1) r θ r r x cosθ x 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:

y

x

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

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

Examples of important angle and related trig functions:

Degrees Radians sin cos tan Degrees Radians sin cos tan 0º 0 0 1 0 30º π/6 1/2 √3/4 √1/3 90º π/2 1 0 none 45º π/4 √1/2 √1/2 1 180º π 0 -1 0 60º π/3 √3/4 1/2 √3 270º 3π/2 -1 0 none 360º 2π 0 1 0

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

-4- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

We prefer to use radians and, in some cases, we must use radians, such as s=rθ r 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 opposite leg adjacent leg hypotenuse sinθ = cosθ = (6a,b) opposite hypotenuse hypotenuse opposite leg θ tanθ = (6c) adjacent leg adjacent

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.)

-5- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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π

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(- ℓ).

Secant, cosecant, and cotangent 1 1 1 cosθ secθ = , cscθ = , cotθ = = (7) cosθ sinθ tanθ sinθ or, for a right triangle:

hypotenuse hypotenuse secθ = cscθ = (8a,b) adjacent leg opposite leg adjacent leg cotθ = (8c) opposite leg

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 sin(−x) = −sin x; cos(−x) = + cos x That is, sine is an odd function and cosine is an even function

(10) Addition formulas sin(x + y) = sin x cos y + cos xsin y

(11) Double angle formulas

-6- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

2 tan x sin(2x) = 2 sin x cos x tan(2x) = 1− tan2 x

(12) Pythagorean identities sin2 x + cos2 x = 1

(13) Half-angle formulas

2  x  1− cos x 2  x  1+ cos x sin   = cos   =  2  2  2  2

(14) Product formulas sin(x + y) + sin(x − y) sin x cos y = 2

(15) Factoring formulas x − y x + y sin x + sin y = 2cos sin 2 2

(16) Reduction formulas  π  cos −θ  = sinθ  2 

(17) Law of Sines B sin A sin B sinC = = c a a b c

C (18) Law of Cosines A b c2 = a 2b2 − 2ab cosC

(19) Area formula 1 Area of triangle ABC = ab sinC 2

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!

-7- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

Example: A partial table for f (x) = 3x, and its inverse f -1(x) = x/3 : x f(x) x f -1(x) 2 6 6 2 5 15 15 5 7 21 21 7

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).

-8- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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 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

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.

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

-9- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

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.

Laws of exponents and logarithms

ex ey = ex + y ex / ey = ex – y e-x = 1/ex (ex )y = exy

ln ab = ln a + lnb a  ln = lna − lnb b 1 ln = −lnb since ln1 = 0 b lna b = ln(a)b = b lna

Logarithms with other bases, especially bases 2 and 10 x log2 x is the inverse of 2 x log10 x is the inverse of 10

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.

-10- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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¸ sinx

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

f f is positive f is positive f jumps f is zero f is zero x -3 -2 -1 0 1 2 3 4 5 6 f is negative f is negative solution for the independent variable x is non-unique. (Exercise: Pick another value of f and find the solution(s) for x.) x=+2 f=0

x= -2

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.

-11- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

Step 1. Find the values of x where f is discontinuous, as at x=4 in the sketch. For an 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.

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.

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.

-12- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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 1  x  y = f  − 3 2  2  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 , 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.

-13- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

2 x 2 erf x = e−t dt the error function π ∫0

2 ∞ 2 erfc x = e−t dt = 1− erf x complementary error function π ∫x 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 ¾ limerf x = 1; limerfc x = 0; x→∞ x→∞ ¾ lim erf x = −1; lim erfc x = 2 x→−∞ x→−∞

Exercise: Using Matlab graph erf x and erfc x on the same plot over the domain -2≤ x ≤+2

Exponential , 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, −t −t ∞ e x e Ei(x) = − dt = dt , x>0 , exponential integral function, ∫−x t ∫−∞ t where t is a dummy variable of integration, is the version encountered in well hydraulics. The other version is −t ∞ e E1(x) = dt , x>0 ∫x t The two versions are related by

− Ei(x) = E1(-x)

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 , 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.

-14- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

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, Q Q r2S s(r,t) = − Ei(−u) = W (u) , u = , W (u) = −Ei(−u ), 4πT 4πT 4Tt 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.

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).

6 Bessel Function of the first kind , 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 n 1 π ( 2 x) 2n J n (x) = 1 cos(x cosθ )sin θ dθ , x>0, 2 1 ∫0 π Γ(n + 2 ) where Γ is the gamma function, ∞ Γ(z) = t z−1e−t dt , Re(z > 0), ∫1 1 1 2 with corresponding specific values for zero and first order Bessel Functions of Γ( 2 ) = π and 1 1 1 2 Γ( 2 ) = 2 π , respectively. In particular the zero order function is 1 π J 0 (x) = cos(x cosθ )dθ π ∫0 ( 1 x)n In the limit, as x→0, J (x) ~ 2 n Γ(n +1)

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

-15- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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: Q B'T s = K (r β ) , β = , 2πT 0 K' 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.

-16- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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) limf (x) = L x→a 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: 3 A solid dot means that f the point belongs to the set; and the small circle 2 means that the point does not belong to the set. 1

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

-2

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.

x2 + 5 + ln x 0 + 5 + (−∞) − ∞ Example: lim = = = − ∞ x→0+ 2ex 2 2

-17- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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: 0 ∞ ∞ ∞ ∞ , , , , , 0× ∞, 0× −∞, ∞ − ∞, (−∞) − (−∞), (0+ )0 , 1∞ , ∞0 0 ∞ ∞ ∞ ∞

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, lim (x4 + 2x2 + 3x − 2) = lim (x4 ) = ∞ x→−∞ x→−∞

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

term of highest degree in numerator

term of highest degree in denominator

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

x5 + x3 +1 x5 x2 For example, lim = lim = lim = +∞ x→−∞ 6x3 − 7x2 + x + 4 x→−∞ 6x3 x→−∞ 6

-18- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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”)

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

A= (x, f(x)) What is a positive slope? Negative slope negative slope? Positive slope zero 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

-2 -1 solute mass flux density [kg m s ] = -Dm dC/dx.

where C [kg m-3] is concentration, x [m] is location, d( )/dx [m-1] is the gradient “operator”, and 2 -1 Dm [m s ] 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.

-19- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

Definition and some applications of the derivative df f (x + ∆x) − f (x) Definition of the derivative of f(x) : = f '(x) = lim dx ∆x→0 ∆x

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: B Use the letters to f identify the following Graph of y=f (x) A C for the function f(x): -3 -2 -1 0 1 2 100 101 Largest positive slope? x

Largest negative slope? D E Zero slope?

Zone of small negative A f ' slope? Graph of y=f ' (x) Zone(s) of ~ constant slope -3 -2 -1 0 1 2 100 101 x ~ Point(s) of inflection B E D Concave up Concave down (f '' issue) C

Notation: if y=f(x) then the derivative can be written as: df d dy f ', f '()x , , f (x), D f , Df , y', or dx dx x dx

df d dy In hydrology we typically use the notation ,f (x),or dx dx dx

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 df change in f f (x + ∆x) − f (x) = = dx change in x ∆x

-20- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

Higher derivatives:

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

d 2 f d 2 d 2 y Notation: f '', f ''()x , , f (x), D2 f , D2 f , y'',or dx2 dx2 x dx2

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

-21- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

Applicaton: Recall the box on Fick’s First Law, using the symbol N to represent flux

density. Then N = − Dm dC dx . How can we use this to find out how much flux changes with location x? Take the derivative of N:

dN d  dC  -3 -1 = − Dm  [kg m s ] dx dx  dx  If Dm is constant, move it outside the outer derivative, or dN d  dC  dD dC d 2C = − D   − m = −D dx m dx dx dx dx m dx2   { =0 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 d 2C dx2 = 0. For this special case, this is a model of conservation of solute mass.

Derivatives of basic, elementary functions (consider their graphs) Derivative of a constant function d(const.) = 0 , or written in another notation, Dx(const) = 0 dx

Derivative of the functions x and xr d(x) d(x r ) = 1 ; = r xr −1 dx dx

Derivative of sin x, cos x, and other trigonometric functions d sin(x) d cos(x) d tan(x) = cos x ; = −sin x ; = sec2 x dx dx dx

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.

x d exp(x) de x x x = = e or, Dx e = e dx dx

The derivative of an inverse function dy 1 = dx dx dy

-22- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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 dx de y Let y = ln x, then x=ey and = = e y = x . dy dy d(ln x) dy 1 1 1 Thus = = = = or Dx ln x =1/x dx dx dx e y x dy Derivatives of inverse trigonometric functions, use the same idea.

Table of basic derivatives7 … Dx c = 0 Dx sin x = cos x -1 1 Dx sin x = 2 Dx x = 1 Dx cos x = - sin x 1− x r r-1 2 Dx x = r x Dx tan x = sec x -1 −1 Dx cos x = 2 2 Dx ln x = 1/x Dx cot x = -csc x 1− x x x Dx e = e Dx sec x = sec x tan x -1 1 Dx tan x = 1+ x2 Dx csc x = - csc x cot x

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.

-23- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

A f(x) A solid dot means that the point Exercise: B belongs to the set; E and the small What is C circle means that happening at the point does not the indicated belong to the set. points? D x

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

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

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 − ln x if 0 < x < 1 −1/ x if 0 < x < 1 f (x) =  so that, f '(x) =   ln x if x ≥ 1  1/ x if x ≥ 1

Derivative of a composition The chain rule for the derivative of a composition y=y(u) is dy dy du = dx du dx or, stated another way for function f,

Dxf(u(x)) = f '(u) u'(x)

Example:

-24- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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: r r-1 Dx u = r u u'(x) Dx sec u = sec u tan u ⋅ u' (x)

1 Dx csc u = - csc u cot u ⋅ u' (x) Dx ln u = u'(x) u u u Dx e = e u'(x) -1 1 Dx sin u = ⋅ u' (x) 2 Dx sin u = cos u ⋅ u' (x) 1− u

Dx cos u = - sin u ⋅ u' (x) -1 −1 Dx cos u = ⋅ u' (x) 2 2 Dx tan u = sec u ⋅ u' (x) 1− u 2 Dx cot u = -csc u ⋅ u' (x) -1 1 Dx tan u = 2 ⋅ u' (x) 1+ u

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 …

-25- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

1 d(lnsin x) d(x) 1 d(sin x) cos x y' = x + lnsin x ⋅ = x + lnsin x = x + lnsin x = x cot x + lnsin x y dx dx sin x dx sin x

Therefore, d(sin x) x = y' = y(x cot x + lnsin x) = (sin x) x (x cot x + lnsin x) dx

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: ∫ kdx = kx + C where k stands for a constant (1) ∫ sinx dx = − cos x + C (2) ∫ cosx dx = + sin x + C (3)

-26- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

∫ expx dx = + exp x + C or ∫ e x dx = +e x + C (4) x r+1 x r dx = + C, r ≠ −1 (5) ∫ r + 1 1 dx = ln x + C, x ≠ 0 (6) ∫ x ∫ e x dx = e x + C

Less commonly encountered antiderivatives of basic functions: ∫ sec2 x dx = tan x + C (7) ∫ csc2 x dx = − cot x + C (8) ∫ secx tan x dx = sec x + C (9) ∫ cscx cot x dx = − csc x + C (10) 1 dx = sin−1 x + C (11) ∫ 1− x2 1 dx = tan −1 x + C (common in gw hydrology) (12) ∫ 1+ x 2

Antiderivatives of elementary functions

∫ c f (x) dx = c ∫ f (x) dx (13) and ∫ [f (x) + g(x)]dx = ∫ f (x) dx + ∫ g(x) dx (14)

So, for example, [c f (x) + c g(x)]dx = c f (x) dx + c g(x) dx ∫ 1 2 1 ∫ 2 ∫

Extending known antiderivative formulas

In general, if F(x) is an antiderivative of f(x), then 1 f (ax + b) dx = F(ax + b) + C (15) ∫ a 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

-27- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

1 cos(π x + 7)dx = sin(π x + 7) + C ∫ π 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. 2  x   x  4x2 x y(x) = −16  + 30  + 40 = − + + 40  30 3   30 3  675 3

-28- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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 x x x x x x x 1 2 3 4 5 6 7 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.

5 4 3 Example: f(x) = 4x - 5x - 40x

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

4 3 2 2 2 2 f '(x0) = 20x - 20x - 120x = 20x (x - x – 6) = 20x (x - 3) (x + 2)

x = 0, 3, -2 are the critical points

Now examine the sign of f '(x) between the critical points.

-29- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

5 4 3 Continuing previous example where critical points are x = 0, 3, -2 and f(x) = 4x - 5x - 40x

3 2 f '' (x0) = 80x - 60x - 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.

-30- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

9 MAX

1 MIN

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

4 4 2 Example: Find maximum value of f(x) = x + 4x - 6x – 8 for 0 ≤ x ≤ 1

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

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

- Given the constrained domain [0,1] for x, keep only the two positive roots, − 3+ 21 f(0) = -8 and f( ) ≅ f(0.79) ≅ -9.4. The largest of these is f(0). 2

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.

-31- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

- 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 f (x) 0 ∞ − ∞ ∞ − ∞ Suppose lim is one of the inderterminant forms , x→a g(x) 0 ∞ ∞ − ∞ − ∞ that is, involving indeterminate quotients. Then …

f '(x) Switch to lim x→a g'(x)

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:

3x3 + 6x 2 − 5 Find lim which is of indeterminate form ∞/∞ [Ans: 3/2] x→∞ 2x 3 + 5x 2 − 3x

-32- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

sin x Find lim which is of indeterminate form 0/0 [Ans: 1] x→0 x

Order of magnitude f (x) Suppose f(x) and g(x) both approach ∞ as x→∞ so that lim is of form ∞/∞. x→∞ g(x) 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: ln x, (ln x)2 , (ln x)3 , ..., x, x, x3/ 2 , x 2 , x3 , ..., e x (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

term with the highest order of magnitude in the numerator

term with the highest order of magnitude in the denominator

For example, 3− ex − ∞ − ex ex lim = = lim = −lim = −∞ x→∞ x3 + 2x ∞ x→∞ x3 x→∞ x3

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.

-33- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

Convergent Divergent (x1, f(x1))

Root Root x2 x3 x1 x2 x1 x3

(x2, f(x2))

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 y − f (x1 ) = f ' (x1 )(x − x1 ) .

f (x1 ) Set y=0 and solve for x to find that when the line crosses the x-axis, x = x1 − . f '(x1 ) This value of x is taken to be x2.

Generalize to the procedure:

f (last x) f (xn ) new x = last x − , or for iteration counter n, xn+1 = xn − f '(last x) f '(xn )

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

-34- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

4 4 1 =π (r + dr)3 − πr3 = 4π[r2dr + r (dr)2 + (dr)3 ] (6) 3 3 3 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,

dV = 4π r2dr (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 1 ε = 4π[r (dr)2 + (dr)3 ] 3 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.

-35- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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: x Consider the DE y'(x) = . Rewrite as y 2 (x) y'(x) = x . y 2 (x) 1 1 Integrate (antidifferentiate) both sides to yield y 3 = x 2 + C . 3 2 dy x More conventionally and conveniently, = , leading to separation as y 2dy = xdx . dx y 2 1 1 Then antidifferentiate, y 2dy = xdx to get y 3 = x 2 + C . ∫ ∫ 3 2

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 dy = −ky dt 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”.

-36- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

1 dy = −k dt y lny = −k t + C

Using the IV to determine constant C,

ln y0 = 0 + C

ln y = −k t + ln y0

y ln y − ln y0 = ln = −k t y0

−k t y = y0e

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 dy = +λy dt

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

+λ ( t−t0 ) y = y0e

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

-37- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

b f (x)dx = lim f (x)dx (1) ∫a dx→0 ∑

b For a simplistic, but useful viewpoint, we can ignore the limit and consider f (x)dx as merely Σ ∫a 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 f (x)dx f (x)dx ∫a ∑

f(x)

a b a b dx

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.

-38- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

Consider the application of integrals and average values:

b f (x)dx Average value of f in [a,b] = ∫a (3) b − a

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 b b [ f (x) + g(x)]dx = f (x)dx + g(x)dx (9) ∫a ∫a ∫a b b k f (x)dx = k f (x)dx , where k is constant (10) ∫a ∫a b c c f (x)dx + f (x)dx = f (x)dx , if a

Reminder about dummy variables 2 x 3dx is a number, without the variable x appearing anywhere in the answer. Could also write it as ∫0 2 2 t 3dt or a 3da . The letter x (or t or a) is called a dummy variable because it is entirely arbitrary. ∫0 ∫0 b b b In general, f (x)dx = f (t)dt = f (u)du , and so on. ∫a ∫a ∫a

The Fundamental Theorem of Calculus The Fundamental Theorem If f is continuous on [a,b] and F is an antiderivative of f, then b f (x)dx = F(b) − F(a) (1) ∫a

3 Example 1: x dx = ? ∫0 3 3 1 9 9 x dx = x 2 = − 0 = ∫0 2 0 2 2

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

3 3 1 9 9 x dx = ( x 2 + 7) = ( + 7) − (0 + 7) = ∫0 2 0 2 2 The 7 cancels out.

-39- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

2 1 Example 3: dx = ? ∫1 x 2 2 2 1 1 1 1 dx = − = − − (−1) = ∫1 2 x x 1 2 2

Integral of a constant function: b k dx = k(b − a) (2) ∫a

Integral of a zero function: b 0 dx = 0 (3) ∫a

Integral of a piecewise function11 with several formulas.

x 2 if x ≤ 3  Suppose f (x) = 2x + 3 if 3 < x < 7  17 − x if x ≥ 7 10 To find f (x)dx use (11) of previous section. ∫0 10 3 7 10 f (x)dx = x 2dx + (2x + 3)dx + (17 − x)dx ∫0 ∫0 ∫3 ∫7 3 3 2 10 x 7 x = + (x 2 + 3x) + (17x − ) = 9+52+25.5 = 86.5 3 3 0 2 7 Definite v. indefinite integrals

The symbol ∫ is used in two different and distinct ways. b • First f (x)dx is an integral, defined as the limit of the Reimann sum Σ f(x)dx. In this ∫a context dx stands for the length of a typical subinterval of [a,b]. The symbol ∫ is used to signify summation.

• Second, ∫ f (x)dx 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.

-40- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

b b Frequently, both f (x)dx and f (x)dx are referred to as integrals; in particular, f (x)dx is ∫a ∫ ∫a called an definite integral, while ∫ f (x)dx is called an indefinite integral (rather than integral and antiderivative). No matter which terminology you choose, it will always be true, for example, that ∫ 3x 2dx = x3 + C , where C is an arbitrary constant, while 3 3x 2dx = 19 ∫2

Numerical integration b The evaluation of f (x)dx = F(b) − F(a) seems like it should be simple, but it is often difficult ∫a 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.

a b a b a b Rieman Sum Trapezoidal Rule Simpson’s Rule

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

-41- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

b h f (x)dx ≈ ( y0 + 4y1 + 2y2 + 4y3 + 2y4 + ... + 2yn−2 + 4yn−1 + y n ) ∫a 3 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], (-∞,∞)

∞ 1 ∞ 1 b 1 Example: dx = ? → dx = lim dx ∫1 x ∫1 x b→∞ ∫1 x i.e., to integrate on [1,∞), integrate from x=1 to x= b and then let b approach ∞.

∞ 1 b 1 b dx = lim dx = lim(ln x ) = lim(ln b − ln1) = ∞ − 0 = ∞ ∫1 x b→∞ ∫1 x b→∞ 1 b→∞

In general, ∞ b b b f (x)dx = lim f (x)dx and f (x)dx = lim f (x)dx ∫a b→∞ ∫a ∫−∞ a→−∞ ∫a

In abbreviated notation, if F is an antiderivative of f then ∞ b f (x)dx = F(x) ∞ and f (x)dx = F(x) b ∫a a ∫−∞ −∞

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.

−2 1 Example: dx = ? ANS: ½, convergent ∫−∞ x 2

-42- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

Integrating on the interval (-∞,∞)

The usual definition is ∞ b ∞ f (x)dx = lim f (x)dx or f (x)dx = F(x) ∞ ∫−∞ a→−∞ ∫a ∫−∞ −∞ b→∞

∞ 1 ∞ π π Example: dx = tan −1 x = − (− ) = π ∫−∞ 1 + x 2 −∞ 2 2

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

b If f blows up at x = a then f (x)dx = F(b) − F(a + ) ∫a

b If f blows up at x = b then f (x)dx = F(b− ) − F(a) ∫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− b f (x)dx = f (x)dx + f (x)dx = F(x) c− + F(x) b ∫a ∫a ∫c+ a c+

The Integral II Integrals with variable upper limit

Suppose we define a new integral x I(x) = f (t)dt (2) ∫a

Some functions of this form are

2 x 2 Erf x = e−t dt error function (3a) π ∫0 Erfc x = 1 − Erf x complementary error function (3b) −t x e Ei x = dt exponential integral function (3c) ∫−∞ t x sin t Si x = dt the sine- integral function (3d) ∫0 t

-43- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

x x Example: I(x) = 3t 2dt = t 3 = x 3 −1 ∫1 1

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 x is not a coincidence. In general, if I(x) = f (t)dt then I’(x)= f(x) at all points where f is continuous. ∫a 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.

2 d x 2 − 2 2 Example: d [erfc(x)] /dx = d1/dx - d [erf(x)] /dx = 0 - e −t dt = e −x π dx ∫0 π

−t − x d x e − e Example: d [Ei(x)] /dx = − dt = dx ∫−∞ t x

-44- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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.

∫ c f (x) dx = c ∫ f (x) dx (1) ∫ [f (x) + g(x)]dx = ∫ f (x) dx + ∫ g(x) dx (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 ∫ 2x cos x 2dx ? We can find it from the derivative. By the chain rule, D sin x 2 = 2x cos x 2 so that we know that 2.x cos x 2dx = sin x 2 + C x ∫

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 dy dy du = dx du dx

In this example, use the device u=x2, du=2x dx. Substitute this into the integral to get ∫ 2x cos x 2dx = ∫ cosu du = sin u + C = sin x 2 + C

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.

-45- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

x 3 1 1. dx ; let u2 =2x4+7 and x3dx =(1/8)du. Ans: + C ∫ (2x 4 + 7)2 8(2x 4 + 7)

1 2. cos2 x sin xdx ; let u =cos x and du= -sin x. Ans: − cos3 x + C ∫ 3

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: this formula is in std. tables; a 2 = 1/2 6474 484 1 1 1 1 1 dx = dx = ⋅ du = ∫ 2 6 ∫ 2 6 ∫ 2 2 6x + 3 x +1/ 2 a + u

1 2 2 1  1 2  ln(u + a + u ) + C = lnx + + x  + C 6 a2 =1/ 2 6  2  u=x

Improper fractions x5 Improper fractions, such as , are those where the degree of the numerator is greater or x 2 + x + 2 3x equal to the degree of the denominator. Proper fractions, such as , are those where the x 2 + 1 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).

x5dx Example 2: Consider . ∫ x 2 + x + 2 Divide out14 the improper fraction integrand: x3 − x 2 − x + 3 − x − 6 x 2 + x + 2 x5 with remainder x 2 + x + 2 That is, the integrand is expanded as the sum of a polynomial and a proper fraction:

14 Refer to your algebra basics for details.

-46- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

x5 − x − 6 = x 3 − x 2 − x + 3 + x 2 + x + 2 x 2 + x + 2 (3) proper fraction = polynominal + proper fraction

Let’s integrate the polynominal, x 4 x 3 x 2 (x 3 − x 2 − x + 3) dx = − − + 3x + C (4) ∫ 4 3 2

Now for the proper fraction, break it up into digestible pieces, − x − 6 x 6 = − − x 2 + x + 2 x 2 + x + 2 x 2 + x + 2

Then integrate x dx 1 1 dx − = − ln x 2 + x + 2 + ∫ x 2 + x + 2 2 2 ∫ x 2 + x + 2 (6) 1 1 2x + 1 = − ln x 2 + x + 2 + tan −1 + C 2 7 7 and dx −12 2x + 1 − 6 = tan −1 + C (7) ∫ x 2 + x + 2 7 7

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

x5dx x 4 x3 x 2 −11 2x + 1 1 = − − + 3x − tan −1 − ln x 2 + x + 2 +K ∫ x 2 + x + 2 4 3 2 7 7 2

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.

-47- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

- If a non-factorable quadratic, such as x2 + x + 10 appears in the denominator then A x + B appears in the decomposition. x 2 + x +10

- If a repeated non-factorable quadratic, such as (x2 + x + 10)4 appears in the denominator then A x + B C x + D E x + F G x + H + + + x 2 + x +10 (x 2 + x +10)2 (x 2 + x +10)3 (x 2 + x +10)4 appears in the decomposition.

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

Example: 2x 2 + 3x −1 Decompose and then antidifferentiate. The denominator has already (x + 3)(x + 2)(x −1) 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 2x 2 + 3x −1 A B C = + + (x + 3)(x + 2)(x −1) x + 3 x + 2 x −1

Multiply this equation by the denominator, (x + 3)(x + 2)(x −1) , to get

2x 2 + 3x −1 = A(x + 2)(x −1) + B(x + 3)(x −1) + C(x + 3)(x + 2 ) (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 2x 2 + 3x −1 2 1/ 3 1/ 3 = − + (x + 3)(x + 2)(x −1) x + 3 x + 2 x −1

We can down antidifferentiate this term by term using tabulated antiderivatives. 2x 2 + 3x −1 1 1 dx = 2ln x + 3 − ln x + 2 + ln x −1 + K ∫ (x + 3)(x + 2)(x −1) 3 3

-48- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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

∫ u dv = uv − ∫ v du (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: ∫ e x cosxdx Let u= ex and dv = cos x dx. Then du= exdx and v= sin x, and ∫ e x cos xdx = ex sin x − ∫ ex sin xdx 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 ∫ e x cos xdx = ex sin x − (−e x cos x + ∫ ex cos xdx ) 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 1 e x cos xdx = (e x cos x + e x sin x) +C ∫ 2 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: ∫ x3 sin x dx Many tables list the pertinent formula ∫ x n sin x dx = −x n cos x + nx n−1 sin x − n(n −1)∫ x n−2 sin x dx Applying that here with n=3 ∫ x3 sin x dx = −x3 cos x + 3x 2 sin x − 3(2)∫ x sin x dx This last integral is usually available in tables and we can finish the job.

-49- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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., a 2 + x 2 x x a x tanu = , cosu = , sinu = u a a2 + x2 a2 + x2 a a a 2 + x2 a 2 + x2 cot u = , secu = , cscu = x a x

Example: dx 1 1 = asec2 u du = − cscu du ∫ 2 2 ∫ a ∫ x a + x a tanu ⋅ a cosu 1 1 a2 + x2 a = − ln cscu + cotu + C = − ln + + C { from standard math tables a a x x

a where x=a tan u yields dx = a sec2u du, and a2 + x2 = . cosu

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

(a) Complete the square if the problem involves ax 2 + bx + c 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 a 2 ± x 2 or x 2 − a 2 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

-50- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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 ∑an or even Σ an. n=1

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 limSn = S , then S is the sum of the series, and we n→∞ write Σ an = S. In this case the series is called convergent; in particular, it converges to S. Else the series is divergent.

∞ 1 n 1 1 1 1 Example: ∑( ) = + + + + K has n=1 2 2 4 8 16 1 1 1 3 1 1 1 7 1 1 1 1 15 S = , S = + = , S = + + = , S = + + + = , etc. 1 2 2 2 4 4 2 2 4 8 8 4 2 4 8 16 16

∞ 1 n Or, lim Sn = 1, and the series has sum 1, that is, converges to 1. We write ( ) = 1. n→∞ ∑ n=1 2

Two convergent series can be added, term by term.

1 1 1 1 + + + + ... = 1 2 4 8 16 3 3 9 15 6 → + + + + ... = 1 1 1 1 1 4 16 64 256 5 − + − + ... = 4 16 64 256 5

Dropping initial terms

-51- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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: ∑ar n = a + ar + ar2 + ar3 + ar4 + ..., a ≠ 0 n=0 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 ∑ar n diverges n=0 ∞ a If -1 < r < 1 then ∑ar n converges to n=0 1 − r ∞ 1 5 Example: ∑3(− )n = n=0 5 2 (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: ln n, (ln n)2 , (ln n)3 , ..., n, n, n3/ 2 , n 2 , n3 , ...,2n ,100n ,..., n!

Reciprocals: 1/ln n, (ln n)−2 , (ln n)−3 , ..., n −1/ 2 , n −1, n −3/ 2 , n −2 , n −3 , ...,2−n ,100 −n ,...,1/ n ! 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

-52- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

Alternating series ∞ n+1 Let an be positive. A series of the form ∑an (−1) = a1 - a2 + a3 - a4 + … is called a alternating n=1 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: ∞ n+1 Consider the alternating series ∑an (−1) . Suppose an →0. Then the series converges to a sum S n=1 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 2 3 4 a0 + a1x + a2 x + +a3 x + a4 x + ... 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.

-53- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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: 1 = 1 + x + x 2 + x3 + x 4 + ... for -1 < x < 1 (1) 1 − x

Binomial series

q(q −1) q(q −1)(q − 2) (1 + x)q = 1 + qx + x 2 + x3... for -1 < x < 1 (4) 2! 3!

Another example, this one of an alternating series:

x2 x3 x4 x5 ln(1+ x) = x − + − + −... for -1 < x < 1 (10) 2 3 4 5

Maclaurin Series We seek a less arbitrary approach to finding a series representation of a function.

Given the power series 2 3 4 f (x) = a0 + a1x + a2 x + +a3x + a4 x + ...

A Maclaurin series has coefficients f (n) (0) a = 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

f (0) f ′(0) f ′′(0) f ′′′(0) f (x) = + x + x2 + x3 + ... 0! 1! 2! 3! 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.

-54- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

x3 x5 x7 sin(x) = x − + − + ... for all x (3) 3! 5! 7!

x2 x4 x5 cos(x) = 1− + − + ... for all x (4) 2! 4! 6! x2 x3 x4 exp(x) = ex = 1+ x + + + + ... for all x (5) 2! 3! 4!

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

1 1 1 e = 1+1+ + + + ... (1) 2! 3! 4! 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:

f (0) f ′(0) f ′′(0) f ′′′(0) f (8) (0) f (x) ≈ + x + x2 + x3 +... + x8 0! 1! 2! 3! 8!

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 f (9) (m) bounded as follows. Consider all possible values of x9 for m between 0 and x, and find the 9! 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 f (n+1) (m) xn+1 (2) (n +1)!

-55- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology 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

1 1 1 e = 1+1+ + + = 2.708 (3) 2! 3! 4!

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

f (5) (m) em 15 = (5)! 5!

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 n Σanx , 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 ∞ n 2 3 ∑an (x − b) = a0 + a1(x − b) + a2 (x − b) + a3(x − b) + ... (1) n = 0 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 f (n) (b) a = n n!

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

f (b) f ′(b) f ′′(b) f ′′′(b) f (x) = + (x − b) + (x − b)2 + (x − b)3 + ... (2) 0! 1! 2! 3! 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.

-56- New Mexico Tech Hyd 510 Hydrology Program Quantitative Methods in Hydrology

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 T (x − ∆x) ∆x dT T (x) = + + O(∆x)2 1 1 dx x−∆x 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 dT T (x) − T (x − ∆x) = + O(∆x)2 dx x−∆x ∆x 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.

-57-