calculus review gly-5826. slope slope = rise/run = y/ x = (y 2 – y 1 )/(x 2 – x 1 ) order of...

37
Calculus Review GLY-5826

Upload: blake-jefferson

Post on 17-Dec-2015

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Calculus Review

GLY-5826

Page 2: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Slope

• Slope = rise/run • = y/x • = (y2 – y1)/(x2 – x1)

• Order of points 1 and 2 not critical

• Points may lie in any quadrant: slope will work out

• Leibniz notation for derivative based on y/x; the derivative is written dy/dx

Page 3: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Exponents

• x0 = 1

Page 4: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Derivative of axn

• y = axn

• derivative of y = axn with respect to x:– dy/dx = a n x(n-1)

Page 5: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Derivative of a line

• y = ax + b: Slope a and y-axis intercept b• b is a constant -- think of it as bx0

– its derivative is: 0bx-1 = 0 • derivative of y = axn with respect to x:

– dy/dx = a n x(n-1)

• For a straight line, n = 1 so– dy/dx = a 1 x(0), or because x0 = 1, – dy/dx = a

• derivative of y = ax + b with respect to x:– dy/dx = a– dy/dx = y/x

Page 6: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Derivative of a polynomial

• In differential Calculus, we consider the slopes of curves rather than straight lines

• For polynomial y = axn + bxp + cxq + …– derivative with respect to x is – dy/dx = a n x(n-1) + b p x(p-1) + c q x(q-1) + …

Page 7: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Example

a 3 n 3 b 5 p 2 c 5 q 0

0

2

4

6

8

10

12

14

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

x

y

y = axn + bxp + cxq + …

-5

0

5

10

15

20

25

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

x

y

dy/dx = a n x(n-1) + b p x(p-1) + c q x(q-1) + …

Page 8: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Numerical Derivatives

• Slope between points

• Examples

Page 9: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Derivative of Sine and Cosine

• sin(0) = 0 • period of both sine and cosine is 2• d(sin(x))/dx = cos(x) • d(cos(x))/dx = -sin(x)

-1.5

-1

-0.5

0

0.5

1

1.5

0 1 2 3 4 5 6 7

Sin(x)

Cos(x)

Page 10: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Higher Order Derivatives

• Second derivative:– d2y/dx2 = d(dy/dx)/dx – Note positions of the ‘twos’; dimensionally

consistent

• Practical:– Take derivative– Take derivative again– d2(x3)/dx2 = d(3x2)/dx = 6x

Page 11: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Partial Derivatives

• Functions of more than one variable• Example: h(x,y) = x4 + y3 + xy

1 4 7

10 13 16 19S1

S7

S13

S19

-1.5

-1

-0.5

0

0.5

1

1.5

2

2.5

3

X

Y

2.5-3

2-2.5

1.5-2

1-1.5

0.5-1

0-0.5

-0.5-0

-1--0.5

-1.5--1

Page 12: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Partial Derivatives

• Partial derivative of h with respect to x at a y location y0

• Notation ∂h/∂x|y=y0

• Treat ys as constants• If these constants stand alone, they drop

out of the result• If they are in multiplicative terms involving

x, they are retained as constants

Page 13: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Partial Derivatives

• Example: – h(x,y) = x4 + y3 + xy – ∂h/∂x = 4x3 + y

– ∂h/∂x|y=y0 = 4x3 + y0

1 4 7

10 13 16 19S1

S7

S13

S19

-1.5

-1

-0.5

0

0.5

1

1.5

2

2.5

3

X

Y

2.5-3

2-2.5

1.5-2

1-1.5

0.5-1

0-0.5

-0.5-0

-1--0.5

-1.5--1

Page 14: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Partial Derivatives

• Example: – h(x,y) = x4 + y3 + xy – ∂h/∂y = 3y2 + x

– ∂h/∂y|x=x0 = 3y2 + x0

1 4 7

10 13 16 19S1

S7

S13

S19

-1.5

-1

-0.5

0

0.5

1

1.5

2

2.5

3

X

Y

2.5-3

2-2.5

1.5-2

1-1.5

0.5-1

0-0.5

-0.5-0

-1--0.5

-1.5--1

Page 15: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

WHY?

Page 16: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Gradients

• del C (or grad C)

• Darcy’s Law:

y

h

x

hh

ji

hKq

Page 17: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Basic MATLAB

Page 18: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Matlab

• Programming environment

• Post-processer

• Graphics

• Analytical solution comparisons

Page 19: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Vectors>> a=[1 2 3 4]

a =

1 2 3 4

>> a'

ans =

1 2 3 4

Page 20: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Autofilling and addressing Vectors

> a=[1:0.2:3]'

a =

1.0000 1.2000 1.4000 1.6000 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000

>> a(2:3)ans =

1.2000 1.4000

Page 21: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

xy Plots

>> x=[1 3 6 8 10];

>> y=[0 2 1 3 1];

>> plot(x,y)

Page 22: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Matrices>> b=[1 2 3 4;5 6 7 8]

b =

1 2 3 4 5 6 7 8

>> b'

ans =

1 5 2 6 3 7 4 8

Page 23: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Matrices

>> b=2.2*ones(4,4)

b =

2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000

Page 24: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Reshape>> a=[1:9]

a =

1 2 3 4 5 6 7 8 9

>> bsquare=reshape(a,3,3)

bsquare =

1 4 7 2 5 8 3 6 9

>>

Page 25: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Load

• a = load(‘filename’); (semicolon suppresses echo)

Page 26: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

If

• if(1)

else

end

Page 27: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

For

• for i = 1:10

• …

• end

Page 28: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

BMP Output

bsq=rand(100,100);

%bmp1 output

e(:,:,1)=1-bsq; %r e(:,:,2)=1-bsq; %g e(:,:,3)=ones(100,100); %b imwrite(e, 'junk.bmp','bmp');

image(imread('junk.bmp')) axis('equal')

Page 29: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Quiver (vector plots)

>> scale=10;

>> d=rand(100,4);

>> quiver(d(:,1),d(:,2),d(:,3),d(:,4),scale)

Page 30: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Contours

• h=[…];

• Contour(h)

Page 31: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Contours w/labels

• h=[…];

• [c,d]=contour(h);

• clabel(c,d), colorbar

Page 32: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Numerical Partial Derivatives

• slope between points

• MATLAB – h=[];– [dhdx,dhdy]=gradient(h)

– contour([1:20],[1:20],h)– hold– quiver([1:20],[1:20],-dhdx,-dhdy)

Page 33: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Gradient Function and Streamlines

• [dhdx,dhdy]=gradient(h);

• [Stream]= stream2(-dhdx,-dhdy,[51:100],50*ones(50,1));

• streamline(Stream)

• (This is for streamlines starting at y = 50 from x = 51 to 100 along the x axis. Different geometries will require different starting points.)

Page 34: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Stagnation Points

Page 35: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Integral Calculus

Cn

xaxax

nn

1

)1(

Cx

axax 2

2

Cx

axax 3

32

Page 36: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Integral Calculus: Special Case

Cn

xaxax

nn

1

)1(

????? 1 xax

Page 37: Calculus Review GLY-5826. Slope Slope = rise/run =  y/  x = (y 2 – y 1 )/(x 2 – x 1 ) Order of points 1 and 2 not critical Points may lie in any quadrant:

Integral Calculus: Special Case

Cn

xaxax

nn

1

)1(

Cxaxax ln 1