2階数値微分

 投稿者:しばっち  投稿日:2019年 8月30日(金)19時59分59秒
  PUBLIC NUMERIC H
!'LET H=1/10^25 !1000桁モード
LET H=1/65536
INPUT PROMPT "X=":X
PRINT F(X)
PRINT DIFF3(X)
PRINT DIFF5(X)
PRINT DIFF7(X)
PRINT DIFF9(X)
PRINT DIFF11(X)
PRINT DIFF13(X)
PRINT DIFF15(X)
PRINT DIFF17(X)
PRINT DIFF19(X)
END

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

EXTERNAL  FUNCTION DIFF3(X)
LET DIFF3=(F(X-H)-2*F(X)+1*F(X+H))/(H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF5(X)
LET DIFF5=(-1*F(X-2*H)+16*F(X-H)-30*F(X)+16*F(X+H)-1*F(X+2*H))/(12*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF7(X)
LET DIFF7=(2*F(X-3*H)-27*F(X-2*H)+270*F(X-H)-490*F(X)+270*F(X+H)-27*F(X+2*H)+2*F(X+3*H))/(180*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF9(X)
LET DIFF9=(-9*F(X-4*H)+128*F(X-3*H)-1008*F(X-2*H)+8064*F(X-H)-14350*F(X)+8064*F(X+H)-1008*F(X+2*H)+128*F(X+3*H)-9*F(X+4*H))/(5040*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF11(X)
LET DIFF11=(8*F(X-5*H)-125*F(X-4*H)+1000*F(X-3*H)-6000*F(X-2*H)+42000*F(X-H)-73766*F(X)+42000*F(X+H)-6000*F(X+2*H)+1000*F(X+3*H)-125*F(X+4*H)+8*F(X+5*H))/(25200*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF13(X)
LET DIFF13=(-50*F(X-6*H)+864*F(X-5*H)-7425*F(X-4*H)+44000*F(X-3*H)-222750*F(X-2*H)+1425600*F(X-H)-2480478*F(X)+1425600*F(X+H)-222750*F(X+2*H)+44000*F(X+3*H)-7425*F(X+4*H)+864*F(X+5*H)-50*F(X+6*H))/(831600*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF15(X)
LET DIFF15=(900*F(X-7*H)-17150*F(X-6*H)+160524*F(X-5*H)-1003275*F(X-4*H)+4904900*F(X-3*H)-22072050*F(X-2*H)+132432300*F(X-H)-228812298*F(X)+132432300*F(X+H)-22072050*F(X+2*H)+4904900*F(X+3*H)-1003275*F(X+4*H)+160524*F(X+5*H)-17150*F(X+6*H)+900*F(X+7*H))/(75675600*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF17(X)
LET DIFF17=(-735*F(X-8*H)+15360*F(X-7*H)-156800*F(X-6*H)+1053696*F(X-5*H)-5350800*F(X-4*H)+22830080*F(X-3*H)-94174080*F(X-2*H)+538137600*F(X-H)-924708642*F(X)+538137600*F(X+H)-94174080*F(X+2*H)+22830080*F(X+3*H)-5350800*F(X+4*H)+1053696*F(X+5*H)-156800*F(X+6*H)+15360*F(X+7*H)-735*F(X+8*H))/(302702400*H^2)
END FUNCTION

EXTERNAL  FUNCTION DIFF19(X)
LET DIFF19=(7840*F(X-9*H)-178605*F(X-8*H)+1982880*F(X-7*H)-14394240*F(X-6*H)+77728896*F(X-5*H)-340063920*F(X-4*H)+1309875840*F(X-3*H)-5052378240*F(X-2*H)+27788080320*F(X-H)-47541321542*F(X)+27788080320*F(X+H)-5052378240*F(X+2*H)+1309875840*F(X+3*H)-340063920*F(X+4*H)+77728896*F(X+5*H)-14394240*F(X+6*H)+1982880*F(X+7*H)-178605*F(X+8*H)+7840*F(X+9*H))/(15437822400*H^2)
END FUNCTION
 

戻る