托马斯微积分 从入门到失望
決定把例題用程序都完成一遍。從最基本的開始:語言選擇用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 = 0dtx = diameter/nfor j in range(0,n,1):xp = j*(diameter/n) - radius #if sphere radius is 4,left plot is -4 ,right plot is 4v += 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*rif __name__ == "__main__":#split a sphere to 20 cylinderprint "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) View Code?
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.0def clinder_volume(xpos,dtx):return math.sqrt(xpos*xpos) * dtxdef curve_volume(n):v = 0.0dtx = maxRange/nfor x in range(0,n,1):xpos = x*(maxRange/n)v += clinder_volume(xpos,dtx)return vif __name__ == "__main__":print curve_volume(15) View Code?
?
<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.0h = float(up-down) / float(n)start = func(down)end = func(up)process = 0.0for dt in xrange(0,n+1,1):if dt == 0 or dt == n:continueprocess += 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.0h = float(up-down) / float(n)start = func(down)end = func(up)process = 0.0for dt in xrange(0,n+1,1):if dt == 0 or dt == n:continue# select the 1 3 5 7 9... indexif dt%2 == 1:process += 4 * func(down + dt * h)# select the 2 4 6 8 10... indexif dt%2 == 0:process += 2 * func(down + dt * h)sum = (start + end + process) * (h/3.0)return sumif __name__ == "__main__":# part1# fx = 5x^4 [0,2] n=4func = lambda x:5*x*x*x*xT = Simpson(0,2,4,func)print T# part2# fx = x [1,2] n=4func2 = lambda x:xT2 = Simpson(1,2,4,func2)print T2# part3# fx = x*xfunc3 = lambda x:x*xT3 = Trapezoidal(1,2,4,func3)print T3func4 = lambda x:x*x + 1T_T4 = Trapezoidal(-1,1,4,func4)S_T4 = Simpson(-1,1,4,func4)print T_T4,S_T4 View Code?
?
?
?
<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); View Code?
?
?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?
?
?
?
?
。。
轉載于:https://www.cnblogs.com/gearslogy/p/6831501.html
總結
以上是生活随笔為你收集整理的托马斯微积分 从入门到失望的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: docker mysql关掉后启动_Do
- 下一篇: python游戏设计毕业论文_游戏设计游