미분적분학실습2-Week-9

919 days ago by jhlee2chn

13.7. Maximum and Minimum Values

Ex. 1

var('x, y') f(x, y) = x^2 + y^2 - 2*x - 6*y + 14 fx = diff(f, x);fy = diff(f, y) solve([fx == 0, fy == 0], x, y) 
       
[[x == 1, y == 3]]
[[x == 1, y == 3]]
fxx = diff(fx, x);fxy = diff(fx, y);fyy = diff(fy, y) A = fxx(1, 3);B = fxy(1, 3);C = fyy(1, 3);D = A*C-B^2 print A, B, C, D 
       
2 0 2 4
2 0 2 4
f(1, 3) 
       
4
4

Ex. 2

var('x, y') f(x, y) = - x^2 + y^2 fx = diff(f, x);fy = diff(f, y) solve([fx == 0, fy == 0], x, y) 
       
[[x == 0, y == 0]]
[[x == 0, y == 0]]
fxx = diff(fx, x);fxy = diff(fx, y);fyy = diff(fy, y) A = fxx(0, 0);B = fxy(0, 0);C = fyy(0, 0);D = A*C-B^2 print A, B, C, D 
       
-2 0 2 -4
-2 0 2 -4
plot3d(f, (x, -2, 2), (y, -2, 2)) 
       
Sleeping...
If no image appears re-execute the cell. 3-D viewer has been updated.

Ex. 3

var('x, y') f(x, y) = x^4 + y^4 - 4*x*y + 1 fx = diff(f, x);fy = diff(f, y) solve([fx == 0, fy == 0], x, y) 
       
[[x == I*(-1)^(1/4), y == -I*(-1)^(3/4)], [x == -(-1)^(1/4), y ==
-(-1)^(3/4)], [x == -I*(-1)^(1/4), y == I*(-1)^(3/4)], [x == (-1)^(1/4),
y == (-1)^(3/4)], [x == -I, y == I], [x == I, y == -I], [x == -1, y ==
-1], [x == 1, y == 1], [x == 0, y == 0]]
[[x == I*(-1)^(1/4), y == -I*(-1)^(3/4)], [x == -(-1)^(1/4), y == -(-1)^(3/4)], [x == -I*(-1)^(1/4), y == I*(-1)^(3/4)], [x == (-1)^(1/4), y == (-1)^(3/4)], [x == -I, y == I], [x == I, y == -I], [x == -1, y == -1], [x == 1, y == 1], [x == 0, y == 0]]
fxx = diff(fx, x);fxy = diff(fx, y);fyy = diff(fy, y) A = fxx(0, 0);B = fxy(0, 0);C = fyy(0, 0);D = A*C-B^2 print A, B, C, D 
       
0 -4 0 -16
0 -4 0 -16
fxx = diff(fx, x);fxy = diff(fx, y);fyy = diff(fy, y) A = fxx(1, 1);B = fxy(1, 1);C = fyy(1, 1);D = A*C-B^2 print A, B, C, D print f(1, 1) # 극소 
       
12 -4 12 128
-1
12 -4 12 128
-1
fxx = diff(fx, x);fxy = diff(fx, y);fyy = diff(fy, y) A = fxx(-1, -1);B = fxy(-1, -1);C = fyy(-1, -1);D = A*C-B^2 print A, B, C, D print f(-1, -1) # 극소 
       
12 -4 12 128
-1
12 -4 12 128
-1

Ex. 5

var('x, y, z') F(x, y, z) = x + 2*y + z - 4 solve(F(x, y, z) == 0, z) 
       
[z == -x - 2*y + 4]
[z == -x - 2*y + 4]
f(x, y) = (x-1)^2 + y^2 + (-x - 2*y + 4 + 2)^2 fx = diff(f, x);fy = diff(f, y) solve([fx == 0, fy == 0], x, y) 
       
[[x == (11/6), y == (5/3)]]
[[x == (11/6), y == (5/3)]]
fxx = diff(fx, x);fxy = diff(fx, y);fyy = diff(fy, y) A = fxx(11/6, 5/3);B = fxy(11/6, 5/3);C = fyy(11/6, 5/3);D = A*C-B^2 print A, B, C, D print sqrt(f(11/6, 5/3)).simplify_full() 
       
4 4 10 24
5/6*sqrt(6)
4 4 10 24
5/6*sqrt(6)

Ex. 6

var('x, y, z') F(x, y, z) = x*y + 2*x*z + 2*y*z - 12 solve(F(x, y, z) == 0, z) 
       
[z == -1/2*(x*y - 12)/(x + y)]
[z == -1/2*(x*y - 12)/(x + y)]
V(x, y) = x*y*(-1/2*(x*y - 12)/(x + y)) Vx = diff(V, x);Vy = diff(V, y) solve([Vx == 0, Vy == 0], x, y) 
       
[[x == 0, y == 0], [x == 2*I*sqrt(3), y == -2*I*sqrt(3)], [x ==
-2*I*sqrt(3), y == 2*I*sqrt(3)], [x == -2, y == -2], [x == 2, y == 2]]
[[x == 0, y == 0], [x == 2*I*sqrt(3), y == -2*I*sqrt(3)], [x == -2*I*sqrt(3), y == 2*I*sqrt(3)], [x == -2, y == -2], [x == 2, y == 2]]
Vxx = diff(Vx, x);Vxy = diff(Vx, y);Vyy = diff(Vy, y) A = Vxx(2, 2);B = Vxy(2, 2);C = Vyy(2, 2);D = A*C-B^2 print A, B, C, D print V(2, 2) 
       
-1 -1/2 -1 3/4
4
-1 -1/2 -1 3/4
4

Ex. 7

var('x, y') f(x, y) = x^2 - 2*x*y + 2*y fx = diff(f, x);fy = diff(f, y) solve([fx == 0, fy == 0], x, y) 
       
[[x == 1, y == 1]]
[[x == 1, y == 1]]
print f(x, 0) print f(3, y) print f(x, 2) print f(0, y) 
       
x^2
-4*y + 9
x^2 - 4*x + 4
2*y
x^2
-4*y + 9
x^2 - 4*x + 4
2*y
print f(1, 1) print f(0, 0) print f(3, 0) print f(3, 2) print f(2, 2) print f(0, 2) 
       
1
0
9
1
0
4
1
0
9
1
0
4

Exercise 2

var('x, y') f(x, y) = x^2 + x*y + y^2 - 6*y fx = diff(f, x);fy = diff(f, y) solve([fx == 0, fy == 0], x, y) 
       
[[x == -2, y == 4]]
[[x == -2, y == 4]]
print f(x, 0) print f(x, 5) print f(-3, y) print f(3, y) 
       
x^2
x^2 + 5*x - 5
y^2 - 9*y + 9
y^2 - 3*y + 9
x^2
x^2 + 5*x - 5
y^2 - 9*y + 9
y^2 - 3*y + 9
print f(-2, 4) print f(3, 0) print f(-3, 0) print f(0, 0) print f(-5/2, 5) print f(3, 5) print f(-3, 9/2) print f(-3, 5) print f(3, 3/2) 
       
-12
9
9
0
-45/4
19
-45/4
-11
27/4
-12
9
9
0
-45/4
19
-45/4
-11
27/4

14.1. Double Integrals over Rectangles

Ex. 1

var('x, y') f(x, y) = 16 - x^2 - 2*y^2 a, b, c, d = 0, 2, 0, 2 m, n = 20, 20 h = (b - a)/m k = (d - c)/n dA = h*k V = 0 for i in range(0, m): for j in range(0, n): V += f(a + (i + 1)*h, c + (j + 1)*k)*dA print V.n(digits = 5) 
       
46.780
46.780

Ex. 3

The midpoint rule for numerically integrating a function of two variables

by Marshall Hampton

https://wiki.sagemath.org/interact/calculus#The_midpoint_rule_for_numerically_integrating_a_function_of_two_variables 

from sage.plot.plot3d.platonic import index_face_set def cuboid(v1,v2,**kwds): """ Cuboid defined by corner points v1 and v2. """ ptlist = [] for vi in (v1,v2): for vj in (v1,v2): for vk in (v1,v2): ptlist.append([vi[0],vj[1],vk[2]]) f_incs = [[0, 2, 6, 4], [0, 1, 3, 2], [0, 1, 5, 4], [1, 3, 7, 5], [2, 3, 7, 6], [4, 5, 7, 6]] if 'aspect_ratio' not in kwds: kwds['aspect_ratio'] = [1,1,1] return index_face_set(f_incs,ptlist,enclosed = True, **kwds) var('x,y') R16 = RealField(16) npi = RDF(pi) pretty_print(html("<h1>The midpoint rule for a function of two variables</h1>")) @interact def midpoint2d(func = input_box('x-3*y^2',type=str,label='function of x and y'), nx = slider(2,20,1,2,label='x subdivisions'), ny = slider(2,20,1,2,label='y subdivisions'), x_start = slider(-10,10,1,0), x_end = slider(-10,10,1,0), y_start= slider(-10,10,1,0), y_end= slider(-10,10,1,0)): f = sage_eval('lambda x,y: ' + func) delx = (x_end - x_start)/nx dely = (y_end - y_start)/ny xvals = [RDF(x_start + (i+1.0/2)*delx) for i in range(nx)] yvals = [RDF(y_start + (i+1.0/2)*dely) for i in range(ny)] num_approx = 0 cubs = [] darea = delx*dely for xv in xvals: for yv in yvals: num_approx += f(xv,yv)*darea cubs.append(cuboid([xv-delx/2,yv-dely/2,0],[xv+delx/2,yv+dely/2,f(xv,yv)], opacity = .5, rgbcolor = (1,0,0))) pretty_print(html("$$\int_{"+str(R16(y_start))+"}^{"+str(R16(y_end))+"} "+ "\int_{"+str(R16(x_start))+"}^{"+str(R16(x_end))+"} "+func+"\ dx \ dy$$")) pretty_print(html('<p style="text-align: center;">Numerical approximation: ' + str(num_approx)+'</p>')) p1 = plot3d(f,(x,x_start,x_end),(y,y_start,y_end)) show(p1+sum(cubs)) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Ex. 4

var('x, y') f(x, y) = x^2*y integral(integral(f, x, 0, 3), y, 1, 2) 
       
27/2
27/2
var('x, y') f(x, y) = x^2*y integral(integral(f, y, 1, 2), x, 0, 3) 
       
27/2
27/2

Ex. 5

var('x, y') f(x, y) = x-3*y^2 integral(integral(f, y, 1, 2), x, 0, 2) 
       
-12
-12

Ex. 6

var('x, y') f(x, y) = y*sin(x*y) integral(integral(f, x, 1, 2), y, 0, pi) 
       
0
0
var('x, y') f(x, y) = y*sin(x*y) integral(integral(f, y, 0, pi), x, 1, 2) 
       
-1/2*pi*Ei(2*I*pi) + 1/2*pi*Ei(I*pi) + 1/2*pi*Ei(-I*pi) -
1/2*pi*Ei(-2*I*pi) + 1/2*pi*gamma(-1, 2*I*pi) - 1/2*pi*gamma(-1, I*pi) -
1/2*pi*gamma(-1, -I*pi) + 1/2*pi*gamma(-1, -2*I*pi)
-1/2*pi*Ei(2*I*pi) + 1/2*pi*Ei(I*pi) + 1/2*pi*Ei(-I*pi) - 1/2*pi*Ei(-2*I*pi) + 1/2*pi*gamma(-1, 2*I*pi) - 1/2*pi*gamma(-1, I*pi) - 1/2*pi*gamma(-1, -I*pi) + 1/2*pi*gamma(-1, -2*I*pi)

Ex. 7

var('x, y') f(x, y) = 16-x^2-2*y^2 integral(integral(f, x, 0, 2), y, 0, 2) 
       
48
48

Ex. 8

var('x, y') f1(x) = sin(x) f2(y) = cos(y) print integral(integral(f1*f2, x, 0, pi/2), y, 0, pi/2) print integral(f1, x, 0, pi/2)*integral(f2, y, 0, pi/2) 
       
1
1
1
1

14.2. Double Integrals over General Regions

Ex. 1

var('x, y') plot(2*x^2, (x, -2, 2)) + plot(1 + x^2, (x, -2, 2), color = 'red') 
       
solve([y == 2*x^2, y == 1 + x^2], x, y) 
       
[[x == -1, y == 2], [x == 1, y == 2]]
[[x == -1, y == 2], [x == 1, y == 2]]
integral(integral(x + 2*y, y, 2*x^2, 1 + x^2), x, -1, 1) 
       
32/15
32/15

Ex. 2

var('x, y') plot(2*x, (x, -1, 3)) + plot(x^2, (x, -1, 3), color = 'red') 
       
solve([y == 2*x, y == x^2], x, y) 
       
[[x == 2, y == 4], [x == 0, y == 0]]
[[x == 2, y == 4], [x == 0, y == 0]]
integral(integral(x^2 + y^2, y, x^2, 2*x), x, 0, 2) 
       
216/35
216/35

Ex. 3

var('x, y') plot(x - 1, (x, -4, 6)) + implicit_plot(y^2 == 2*x + 6, (x, -4, 6), (y, -5, 5), color = 'red') 
       
solve([y == x - 1, y^2 == 2*x + 6], x, y) 
       
[[x == -1, y == -2], [x == 5, y == 4]]
[[x == -1, y == -2], [x == 5, y == 4]]
solve(y^2 == 2*x + 6, x) 
       
[x == 1/2*y^2 - 3]
[x == 1/2*y^2 - 3]
solve(y == x - 1, x) 
       
[x == y + 1]
[x == y + 1]
integral(integral(x*y, x, 1/2*y^2 - 3, y + 1), y, -2, 4) 
       
36
36

Ex. 4

var('x, y, z') p1 = implicit_plot3d(x + 2*y + z == 2, (x, -2, 2), (y, -2, 2), (z, -2, 2), opacity = 0.4) p2 = implicit_plot3d(x == 2*y, (x, -2, 2), (y, -2, 2), (z, -2, 2), opacity = 0.4, color = 'red') p3 = implicit_plot3d(x == 0, (x, -2, 2), (y, -2, 2), (z, -2, 2), opacity = 0.4, color = 'green') p4 = implicit_plot3d(z == 0, (x, -2, 2), (y, -2, 2), (z, -2, 2), opacity = 0.4, color = 'orange') p1 + p2 + p3 + p4 
       
Sleeping...
If no image appears re-execute the cell. 3-D viewer has been updated.
solve([x == 2*y, x + 2*y == 2], x, y) 
       
[[x == 1, y == (1/2)]]
[[x == 1, y == (1/2)]]
solve(x + 2*y == 2, y) 
       
[y == -1/2*x + 1]
[y == -1/2*x + 1]
solve(x + 2*y + z == 2, z) 
       
[z == -x - 2*y + 2]
[z == -x - 2*y + 2]
integral(integral(-x - 2*y + 2, y, x/2, -1/2*x + 1), x, 0, 1) 
       
1/3
1/3

Ex. 5

var('x, y') integral(integral(sin(y^2), x, 0, y), y, 0, 1) 
       
-1/2*cos(1) + 1/2
-1/2*cos(1) + 1/2

Ex.

var('x, y') plot(x, (x, -2, 2)) + plot(x^3, (x, -2, 2), color = 'red') 
       
solve(x == x^3, x) 
       
[x == -1, x == 1, x == 0]
[x == -1, x == 1, x == 0]
integral(integral(x-1, y, x^3, x), x, 0, 1)+integral(integral(x-1, y, x, x^3), x, -1, 0) 
       
-1/2
-1/2

Exercise 1

integral(integral(x*y, y, 0, sqrt(1 - x^2)), x, 0, 1) 
       
1/8
1/8

Exercise 2

var('x, y, z') p1 = implicit_plot3d(y == x^2, (x, -2, 2), (y, -1, 3), (z, 0, 4), opacity = 0.4) p2 = implicit_plot3d(z == 3*y, (x, -2, 2), (y, -1, 3), (z, 0, 4), opacity = 0.4, color = 'red') p3 = implicit_plot3d(z == 2 + y, (x, -2, 2), (y, -1, 3), (z, 0, 4), opacity = 0.4, color = 'green') p1 + p2 + p3 
       
Sleeping...
If no image appears re-execute the cell. 3-D viewer has been updated.
solve([z == 3*y, z == 2 + y], y, z) 
       
[[y == 1, z == 3]]
[[y == 1, z == 3]]
solve([y == x^2, y == 1], x, y) 
       
[[x == -1, y == 1], [x == 1, y == 1]]
[[x == -1, y == 1], [x == 1, y == 1]]
integral(integral(2 + y - 3*y, y, x^2, 1), x, -1, 1) 
       
16/15
16/15