托马斯微积分 从入门到失望
决定把例题用程序都完成一遍。从最基本的开始:语言选择用python,vex,Houdini作图
<1>
a,求球的体积.半径为4,中心点为0,左断点为-4,右断点为4
import math radius = 4.000 diameter = radius *2 # sphere r=4 R=8 # this spere is y=sqrt(16-x*x) # per cylinder volume is PI*r*r*dtx def sphere_function(xpos,dtx): return math.sqrt(16.00-xpos*xpos) * math.sqrt(16.00-xpos*xpos)*dtx # @n is the is this sphere that will split to n piece along xpos # if sphere r=4, slice is 8, dtx= R/8 = 1 def calculateVolume(n): v = 0 dtx = diameter/n for j in range(0,n,1): xp = j*(diameter/n) - radius #if sphere radius is 4,left plot is -4 ,right plot is 4 v += sphere_function(xp,dtx) return v # sphere volume use base function : 3/4 * PI * (R*R*R) def ruleCacluateVolume(r): return 4/3.000 * r*r*r if __name__ == "__main__": #split a sphere to 20 cylinder print "use 4 slice :" ,calculateVolume(4) print "use 8 slice :" ,calculateVolume(8) print "use 20 slice :" ,calculateVolume(20) print "use 120 slice :" ,calculateVolume(120) print "use 200 slice :" ,calculateVolume(200)
python volume.py
use 4 slice : 80.0
use 8 slice : 84.0
use 20 slice : 85.12
use 120 slice : 85.3274074074
use 200 slice : 85.3312
use sphere volume function : 85.3333333333
可以看到和标准体积的球体不差多少。200个切片就很精确了 几乎一样
b,半球体积:
<2>求类似火箭头的曲线体积:
import math # # curve function is y=sqrt(x) # x range->0-5 # maxRange = 5.0 def clinder_volume(xpos,dtx): return math.sqrt(xpos*xpos) * dtx def curve_volume(n): v = 0.0 dtx = maxRange/n for x in range(0,n,1): xpos = x*(maxRange/n) v += clinder_volume(xpos,dtx) return v if __name__ == "__main__": print curve_volume(15)
<3> 求a和b为什么值,积分的值最大
<4> 梯形法求积分,simpson法求积分
# Trapezoidal # S = 1/2(y0+ 2y1 + 2y2 + 2y3+...+ 2yn-1 + yn) def Trapezoidal(down,up,n,func): if up==down: return 0.0 h = float(up-down) / float(n) start = func(down) end = func(up) process = 0.0 for dt in xrange(0,n+1,1): if dt == 0 or dt == n: continue process += 2 * func(down + dt * h) sum = (start + end + process) * (h/2.0) return sum # Simpson # S = h/3(y0 + 4y1 + 2y2 + 4y3 + 2y4 + ... + 2yn-1 + yn) # func is f(x) def Simpson(down,up,n,func): if up==down: return 0.0 h = float(up-down) / float(n) start = func(down) end = func(up) process = 0.0 for dt in xrange(0,n+1,1): if dt == 0 or dt == n: continue # select the 1 3 5 7 9... index if dt%2 == 1: process += 4 * func(down + dt * h) # select the 2 4 6 8 10... index if dt%2 == 0: process += 2 * func(down + dt * h) sum = (start + end + process) * (h/3.0) return sum if __name__ == "__main__": # part1 # fx = 5x^4 [0,2] n=4 func = lambda x:5*x*x*x*x T = Simpson(0,2,4,func) print T # part2 # fx = x [1,2] n=4 func2 = lambda x:x T2 = Simpson(1,2,4,func2) print T2 # part3 # fx = x*x func3 = lambda x:x*x T3 = Trapezoidal(1,2,4,func3) print T3 func4 = lambda x:x*x + 1 T_T4 = Trapezoidal(-1,1,4,func4) S_T4 = Simpson(-1,1,4,func4) print T_T4,S_T4
<4> 复习黎曼和 和 定积分关系
5,求椎体体积:
Houdini求出-55
fx = x^2;
则积分为x^3 / 3
上限为y最大值
下限为y最小值
float ptsx[]; float ptsy[]; float ptsz[]; int npt = npoints(0); resize(ptsx,npt); resize(ptsy,npt); resize(ptsz,npt); for(int i=0;i<npt;i++) { vector pos = point(0,"P",i); ptsx[i] = pos.x; ptsy[i] = pos.y; ptsz[i] = pos.z; } float maxy = max(ptsy); float miny = min(ptsy); printf("%f,%f\n",miny,maxy); float dttop = pow(maxy,3) / 3.0; float dtbottom = pow(miny,3) / 3.0; float volume = dttop - dtbottom; adddetailattrib(geoself(),"cvolume",volume);
6,一个立方体x=0 和 x=4 出垂直于x轴的两个平面之间,在0<= X <= 4 垂直于x横截面都是正方形,并且他们对角线都是从抛物线y = -sqrt(x) 和 y = sqrt(x)。
如图:
对角线长度则为2sqrt(x)
对角线一半为d = sqrt(x)
要求变长 h , 已知sina = d / h , 因为a = 45,所以 h =( 2sqrt(x) ) / sqrt(2)
A(x) = h^2 = 2x
求积分2x 0 <=x <= 4
F(x) = x^2
F(4) - F(0) = 16
7,x = sqrt(5) y^2 的曲线(0<y<2),从曲线Y到这条曲线形成的立体,由圆盘组成。
求这个形体体积.
8,
区域有y = x ^2 + 1,y = x+3围成的面积 沿着X轴向旋转,求旋转体体积,。
两线交点:-1 , 2
PI * R(x) ^2 - PI * r(x)^2 的积分.
PI(x+3)^2 - PI(x^2+1)^2 = PI[ (x+3)^2 - (x^2+1)^2 ]
-1<x<2
求积分.
9,y=0与y=5 之间的y = x^2 / 2
a,图像绕Y旋转一周所形成的碗状体积。
b,并且求如果每秒3立方单位的常数速率往碗里灌水,当水深为4个单位时,水面上升的速率。
旋转法求体积,因为绕Y旋转,所以半径是x = sqrt(2y)
面积:PI * r^2 = 2 *PI *y
求积分0,5 区间 , 2*pi*y dy 的积分 是25PI
v(h) = | A(h) dh
则dv/dh = A(h) = 2 * PI * y
dv/dt = (dv/dh) * (dh/dt)
dh/dt 则是我们的速率。 dh/dt = (dv/dt) * (1 / 2*PI*y )
则速率:dh/dt = 3 * ( 1 / 2*PI*4 )
5章 5.2 7题
y=x, y=-x/2 , x=2 求两条曲线 和给定的范围 ,沿着Y旋转的体积。(圆柱薄壳法)
圆柱薄壳法:
微分:根据二阶导y''和一阶导y'大概画函数图像。
<1>
x<2 y'<0 ,y'' <0 2 y=1 y'=0 ,y''<0 2<x<4 y'>0 ,y''<0 4 y=4 4<x<6 y'>9,y''<0 6 y=7 x>6 y'<0.y''<0
。。
posted on 2017-05-09 17:04 gearslogy 阅读(20213) 评论(1) 编辑 收藏 举报