【文章內(nèi)容簡(jiǎn)介】
m(w.*feval(f,T))。復(fù)化Simpson求積公式 利用在個(gè)等步長(zhǎng)采樣點(diǎn):的逼近積分.注意:復(fù)化Simpson求積算法(MATLAB程序)Function s =simpson(f,a,b,N)%Input f is the integrand input as a string ‘f’% a and b are upper and lower limits of integration% N is the number of subintervals%Output s is the simpson rule sumh= (ba)/(2*N)。s1=0。s2=0。For k=1:N x=a+h*(2*k1)。s1=s1+feval(f,x)endFor k=1:(N1) x=a+h*2*k。s2=s2+feval(f,x)ends=h*( feval(f,a)+ feval(f,b)+4*s1+2*s2)/3。二、數(shù)值試驗(yàn)內(nèi)容1)使用6點(diǎn)GaussLengder求積公式逼近積分:即用求積公式去離散積分方程中的積分項(xiàng),并求積以上積分方程,得到其解函數(shù)的近似表達(dá)式.2)用的復(fù)化Simpson求積公式求下列積分,要求絕對(duì)誤差限為.1.2.3.?dāng)?shù)值實(shí)驗(yàn)4 微分方程數(shù)值解法一、方法與程序4階Rungekutta法4階Rungekutta算法(MATLAB程序)Function R =rk4(f,a,b,ya,N)%Input f is the function entered as string ‘f’% a and b are the lrft and right end points% ya is the initial condition y(a)% N is the number of steps%Output R=[T ’Y’] where T is the vector of abscissas and% Y is the vector of ordinatesh = (ba)/N。T=zeros(1,N+1)。Y=zeros(1,N+1)。T=a:h:b。Y(1)=ya。For k=1:N K1=h*feval(f,T(k),Y(k))。 K2=h*feval(f,T(k)+h/2,Y(k)+k1/2)。 K3=h*feval(f,T(k)+h/2,Y(k)+k2/2)。 K4=h