ガウス・クロンロッド求積

 投稿者:しばっち  投稿日:2015年10月 3日(土)22時26分16秒
  http://keisan.casio.jp/exec/system/1331182061

!'/1
!'| f(x)dx
!'/-1
LET A=1
!'INPUT  PROMPT "下限 =":A
INPUT PROMPT "上限 =":B
LET U=(B+A)/2
LET V=(B-A)/2
FOR I=1 TO 15
   READ X,W
   LET S=S+W*FUNC(U+V*X)*V
NEXT I
PRINT S
PRINT LOG(B)
DATA -0.991455371120813,0.022935322010529
DATA -0.949107912342759,0.063092092629979
DATA -0.864864423359769,0.104790010322250
DATA -0.741531185599394,0.140653259715525
DATA -0.586087235467691,0.169004726639267
DATA -0.405845151377397,0.190350578064785
DATA -0.207784955007898,0.204432940075298
DATA 0.000000000000000,0.20948214108472
DATA 0.991455371120813,0.022935322010529
DATA 0.949107912342759,0.063092092629979
DATA 0.864864423359769,0.104790010322250
DATA 0.741531185599394,0.140653259715525
DATA 0.586087235467691,0.169004726639267
DATA 0.405845151377397,0.190350578064785
DATA 0.207784955007898,0.204432940075298
END

EXTERNAL FUNCTION FUNC(X)
LET FUNC=1/X
END FUNCTION
 

Re: ガウス・クロンロッド求積

 投稿者:たろさ  投稿日:2016年12月 7日(水)17時11分12秒
  > No.3875[元記事へ]

しばっちさんへのお返事です。

微分積分の勉強中です。
有限区間(a,b)の数値積分

プログラムを書いたのですが失敗しました。


しばっちさんの参照しました。

! zeta(2),ζ(2)
DEF f(x)=1/x^2
SET WINDOW -1,5,-1,5
DRAW grid
FOR x=0.01 TO 5 STEP 0.01
   PLOT x,f(x);
NEXT x

SET AREA COLOR 2

FOR x=1 TO PI^2/6 STEP 0.001
   PLOT AREA:x,0;x,f(x);x,0
NEXT x
LET s=.0000001
FOR x=1 TO PI^2/6 STEP 0.0000001
   LET d=s*f(x)
   !PRINT x;f(x)
   LET e=d-s*(f(x)-f(x+s))/2
   LET c=c+e
NEXT x
PRINT c

LET A=1
LET B=PI^2/6

PRINT WOOLHOUSE2(A,B) !#3905
PRINT GAU(a,b)

PRINT 1-6/PI^2
END

EXTERNAL  FUNCTION F(X)
LET F=1/X^2
END FUNCTION

EXTERNAL  FUNCTION GAU(a,b) !#3875
LET U=(B+A)/2
LET V=(B-A)/2
FOR I=1 TO 15
   READ X,W
   LET S=S+W*F(U+V*X)*V
NEXT I
LET GAU=S
!PRINT S
!PRINT LOG(B)
DATA -0.991455371120813,0.022935322010529
DATA -0.949107912342759,0.063092092629979
DATA -0.864864423359769,0.104790010322250
DATA -0.741531185599394,0.140653259715525
DATA -0.586087235467691,0.169004726639267
DATA -0.405845151377397,0.190350578064785
DATA -0.207784955007898,0.204432940075298
DATA 0.000000000000000,0.20948214108472
DATA 0.991455371120813,0.022935322010529
DATA 0.949107912342759,0.063092092629979
DATA 0.864864423359769,0.104790010322250
DATA 0.741531185599394,0.140653259715525
DATA 0.586087235467691,0.169004726639267
DATA 0.405845151377397,0.190350578064785
DATA 0.207784955007898,0.204432940075298
END FUNCTION


EXTERNAL  FUNCTION WOOLHOUSE2(A,B)
LET H=(B-A)/28
LET X=A
LET WOOLHOUSE2=14*H*(7/195*(F(X)+F(X+28*H))+16807/66690*(F(X+2*H)+F(X+26*H))+128/285*(F(X+7*H)+F(X+21*H))+71/135*F(X+14*H))
END FUNCTION


-----------------------------------

精度確認

0.39207289814597337133672322074163416657384735196652


http://blogs.yahoo.co.jp/donald_stinger

 

戻る