¤³¤ó¤Ë¤Á¤ï¡£
>±ß¼þΨ¤òµá¤á¤ë¥½¥Õ¥È¤òºîÀ®¤·¤è¤¦¤È»×¤Ã¤Æ¤¤¤ë¤Î¤Ç¤¹¤¬¡¢
>ÇüÂç¤Ê·å¿ô¤Î¾¯¿ô¤òÊݴɤǤ¤ëÊýË¡¤¬¤ï¤«¤ê¤Þ¤»¤ó¡£
GENKI¤µ¤ó¤¬¶Ä¤ë¤è¤¦¤Ë¡¢dim ¤Þ¤¿¤Ï sdim ¤ò»ÈÍѤ¹¤ë¤Î¤¬Îɤ¤¤«¤È»×¤¤¤Þ¤¹¡£
¶ñÂÎŪ¤ÊÊýË¡¤Ï¡¢±ß¼þΨ¤òµá¤á¤ëÊýË¡¤Ë¤è¤Ã¤ÆÊѤï¤Ã¤Æ¤¯¤ë¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
¤¿¤À¡¢¥¢¡¼¥¯¥¿¥ó¥¸¥§¥ó¥ÈË¡¤Ë¤·¤í¡¢»»½Ñ´ö²¿Ê¿¶ÑË¡¤Ë¤·¤í¡¢
̵¸Â¤Ë³¤¯±ß¼þΨ¤òµá¤á¤ë¤Î¤Ï£È£Ó£Ð¤Ë¤Ï¸þ¤«¤Ê¤¤¤«¤È»×¤¤¤Þ¤¹¡£
¤·¤«¤·¡¢¤â¤·¤½¤Î¥¢¥ë¥´¥ê¥º¥à¤òÍý²ò¤Ê¤µ¤Ã¤Æ¤¤¤Æ¡¢
±ß¼þΨ¤Î¶á»÷Ãͤòµá¤á¤ë¤Î¤¬ÌÜŪ¤Ç¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢¶á¤¤¤³¤È¤Ï¤Ç¤¤½¤¦¤Ç¤¹¡£
°ìÈÖ´Êñ¤ÊÊýË¡¤òÎã¤Ëµó¤²¤Þ¤¹¡£
HSP¤Ï¡¢É¸½à¤Ç¤Ï double·¿¤¬¸Â³¦¤Ç¡¢±ß¼þΨ¤Î¶á»÷Ãͤò sin´Ø¿ô¤Çµá¤á¤ë¤È¡¢
mes " PI = 3.14159265\n"
repeat 5
x = 3.
repeat ( cnt )
x += sin( x )
loop
mes str( cnt + 1 ) + "²óÌÜ : " + x
loop
stop
£³²óÌܤǸ³¦¤Ë㤷¤Þ¤¹¡£
¤³¤ì¤Ï sin(x) ¤Ë¤â double·¿ ¤Ë¤â¸¶°ø¤¬¤¢¤ë¤¿¤á¤Ç¤¹¡£
sin´Ø¿ô¤Ï½éÅù´Ø¿ô¤Ê¤Î¤Ç¡¢¼Â¼Á¾å¤Ï̵¸Â²óϢ³Èùʬ¤¬²Äǽ¤Ê¤Ï¤º¤Ç¤¹¡£
¤½¤³¤Ç¡¢sin´Ø¿ô¤òTaylorŸ³«¤Ë¤è¤Ã¤Æ¡¢ÃÖ¤´¹¤¨¤Æ¤ß¤Þ¤¹¡£
sin(x) = ... + { ( -1 )~( n - 1 ) } * { ( x~( 2n - 1 ) )/( ( 2n - 1 )! ) } + ...
¡Ê ¥Á¥ë¥À(~) ¤ÏÎß¾è¤ò°ÕÌ£¤·¡¢{ } ¤ÏÂç³ç¸Ì¤ò°ÕÌ£¤·¤Þ¤¹¡Ë
¤½¤¦¤¹¤ë¤È¡¢
[A] = ( -1 )~( n - 1 )
[B] = ( x~( 2n - 1 ) )
[C] = ( ( 2n - 1 )! )
¤Ëʬ²ò¤Ç¤¤ë¤Î¤Ç¡¢¤½¤ì¤¾¤ì¤ò·×»»¤·¤Þ¤¹¡£
n (int·¿¡¦Àµ¤ÎÀ°¿ô)¤òµá¤á¤ë¹à¿ô¡¢t (double·¿)¤ò¹ç·×¤È¤¹¤ë¤È¡¢
repeat ( n )
_cnt = cnt + 1
lp = ( 2*_cnt - 1 )
// [A]
sign = ( _cnt\2 )*2 - 1
// [B]
vp = 1.0
repeat ( lp )
vp *= x
loop
// [C]
vw = 0
repeat ( lp )
vw += lp
lp --
loop
// sin(x)
t += ( vp / vw * sign )
loop
¤Çµá¤Þ¤ë¤Ï¤º¤Ç¤¹¡£
¤³¤ì¤ò¸«¤ë¤È¡¢¼ÂºÝ¤Ë̵¸ÂÂç¤Î¼Â¿ô¤¬É¬ÍפʤΤϡ¢
vp *= x¡¡¤Ç¡È¼Â¿ô¤ÈÀ°¿ô¤Î¾è»»¡É
t += ( vp / vw * sign )¡¡¤Ç¡È¼Â¿ô¤ÈÀ°¿ô¤Î½ü»»¡É¤È¡È¼Â¿ô¤È¼Â¿ô¤Î²Ã¸º»»¡É
¤Î£´ÅÀ¤À¤±¤ÇºÑ¤à¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
ÌÞÏÀ¡¢¤³¤ÎÊýË¡¤Ç¤â double·¿¤Î¸Â³¦¤¬¤¢¤ê¤Þ¤¹¡£
¤Ê¤Î¤Ç¡¢double·¿¤âsdim·¿(str)¤ËÃÖ¤´¹¤¨¤Æ¤ß¤Þ¤¹¡£
̵¸ÂŤη¿¤Ï¡¢sdimÌ¿Îá¤Ç¼Â¸½¤·¤Þ¤¹¡£
¤³¤ì¤ò¡ÖXLong·¿¡×¤È¤·¤Þ¤¹¡£
°Ê²¼¤Ï¡¢
vp *= x¡¡¤Ç»È¤¦¤¿¤á¤Î¡¢XLong ¡ß Int ¤Î¥µ¥ó¥×¥ë¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£
#define ctype XLongOut( %1, %2 ) ( %1 + "." + %2 )
#module XLONG_
// ¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£/* by Lisa*/¢£
// ¢£ ̵¸ÂĹ XLong·¿ ¤Î¥µ¥ó¥×¥ë
// ¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£¢£
#deffunc XLongDeclare var p1, var p2, str p3, str p4
sdim p1, strlen( p3 )
sdim p2, strlen( p4 )
p1 = p3
p2 = p4
return
#deffunc XLongMultipleXI var p1, var p2, int p3
cry = 0 // ·«¾å¤²ÍÑÊÑ¿ô
repeat 2
if ( cnt ) {
// ·×»»ºÑ¤ß¤Î¾®¿ôÉô¤ò¡¢¸µ¤Î¾®¿ôÉôÊÑ¿ô¤ËÌ᤹
sdim p2, strlen( val )
p2 = val
// ¼õ¤±¼è¤Ã¤¿À°¿ôÉôÊÑ¿ô¤ò¥³¥Ô¡¼
len = strlen( p1 )
sdim val, len
val = p1
} else {
// ¼õ¤±¼è¤Ã¤¿¾®¿ôÉôÊÑ¿ô¤ò¥³¥Ô¡¼
len = strlen( p2 )
sdim val, len
val = p2
}
// ¾è»»¤Î¥ë¡¼¥×
repeat ( len )
// ¸åÈø¤«¤éÀèƬ¤Ø¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤¹¤ë
idx = len - cnt - 1
// Æɤ߽Ф·¡¢¿ôÃͤËÃÖ¤´¹¤¨¡¢¾è»»¤ò¤·¤Æ¡¢·«¤ê¾å¤¬¤ê¤ò¤¹
num = ( peek( val, idx ) - '0' ) * p3 + cry
// °ì·åÌܤòʸ»ú¥³¡¼¥É¤ËÌᤷ¤Æ¡¢½ñ¤´¹¤¨¤ë
poke val, idx, ( ( num \ 10 ) + '0' )
// Æó·åÌܤò·«¤ê¾å¤²ÊÑ¿ô¤ØÊݸ¤¹¤ë
cry = int( num / 10 )
loop
loop
// À°¿ôÉô¤Ç¤Î·«¤ê¾å¤¬¤ê¤¬¤¢¤ë¤«
if ( cry ) :inc = str( cry ) :else :inc = ""
// ·×»»ºÑ¤ß¤ÎÀ°¿ôÉô¤ò¡¢¸µ¤ÎÀ°¿ôÉôÊÑ¿ô¤ËÌ᤹
sdim p1, ( strlen( val ) + strlen( inc ) )
p1 = inc + val
return
#global
/*// XLong·¿¤ò»ÈÍѤ·¤Æ¤ß¤ë //*/
// 321.823546879012345678900001 ¤ò XLong·¿¤ËÂåÆþ
XLongDeclare i, d, "821", "323546879012345678900001"
mes
mes "¸µ¤Ë¤Ê¤ëÃÍ\n" + XLongOut( i, d )
// XLongÊÑ¿ô¤Ë 2 ¤ò³Ý¤±¤ë
XLongMultipleXI i, d, 2
mes
mes "·×»»¤·¤¿ÃÍ\n" + XLongOut( i, d )
stop
¤·¤«¤·¡¢¤´Â¸ÃΤ«¤È»×¤¤¤Þ¤¹¤¬¡¢±ß¼þΨ¤ÎÀ¤³¦¤Ç¤Ï
¤³¤Î¤è¤¦¤ËÉ®»»¥¢¥ë¥´¥ê¥º¥à¤Ç½èÍý¤¹¤ëÊýË¡¤Ï¥¿¥Ö¡¼¤È¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¡Ê½èÍý¤¬·å¿ô¤ÎÆó¾è¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡Ë
¤³¤ì°Ê¾å¾Ü¤·¤¯¤Ï¡¢Ä´¤Ù¤Æ¤ß¤Ê¤¤¤Èʬ¤«¤ê¤Þ¤»¤ó¤¬¡¢
¤³¤Î¥µ¥ó¥×¥ë¤¬²¿¤«¤Î¥Ò¥ó¥È¤Ë¤Ê¤ì¤Ð¤È»×¤¤¡¢Ä¹¡¹¤È½ñ¤«¤»¤ÆÌ㤤¤Þ¤·¤¿¡£
Ĺʸ¡¦Íðʸ¡¢ËÜÅö¤Ë¿½¤·Ìõ¤¢¤ê¤Þ¤»¤ó¡£