SIN,COS倍角式 しばっち 2008/02/08 20:45:02
SIN,COS倍角式 |
返事を書く ノートメニュー |
しばっち <dihjvcfsyu> 2008/02/08 20:45:02 | |
SIN(X+Y)=SIN(X)*COS(Y)+COS(X)*SIN(Y)
COS(X+Y)=COS(X)*COS(Y)-SIN(X)*SIN(Y) を使っています PUBLIC NUMERIC MAXLEVEL OPTION BASE 0 LET MAXLEVEL=20 DIM COSA(MAXLEVEL),COSB(MAXLEVEL),SINA(MAXLEVEL,MAXLEVEL),SINB(MAXLEVEL,MAXLEVEL) DIM COSINE(MAXLEVEL),SINE(MAXLEVEL,MAXLEVEL) LET COSA(1)=1 LET SINA(1,0)=1 LET COSB(1)=1 LET SINB(1,0)=1 FOR F=2 TO MAXLEVEL CALL COSINEX(MIN(F*2,MAXLEVEL),COSA,SINA,COSB,SINB,COSINE) PRINT "COS(";STR$(F);"X)="; CALL DISPLAYCOS(F,COSINE) CALL SINEX(MIN(F*2,MAXLEVEL),COSA,SINA,COSB,SINB,SINE) PRINT "SIN(";STR$(F);"X)="; CALL DISPLAYSIN(F,SINE) FOR I=0 TO F LET COSB(I)=COSINE(I) LET COSINE(I)=0 FOR J=0 TO F LET SINB(I,J)=SINE(I,J) LET SINE(I,J)=0 NEXT J NEXT I NEXT F END EXTERNAL SUB DISPLAYSIN(F,SINE(,)) FOR I=F TO 0 STEP -1 FOR J=F TO 0 STEP -1 IF SINE(I,J)<>0 THEN IF FL=1 THEN IF SINE(I,J)<0 THEN PRINT "-"; ELSE PRINT "+"; END IF IF FL=0 THEN IF SINE(I,J)<0 THEN PRINT "-"; LET FL=1 END IF IF I>1 THEN PRINT STR$(ABS(SINE(I,J)));"*SIN(X)^";STR$(I); ELSEIF I=1 THEN PRINT STR$(ABS(SINE(I,J)));"*SIN(X)"; END IF IF J>1 THEN PRINT "*COS(X)^";STR$(J); ELSEIF J=1 THEN PRINT "*COS(X)"; END IF END IF NEXT J NEXT I END SUB EXTERNAL SUB DISPLAYCOS(K,COSINE()) PRINT STR$(COSINE(K));"*COS(X)^";STR$(K); FOR I=K-1 TO 1 STEP -1 IF COSINE(I)<>0 THEN IF COSINE(I)<0 THEN PRINT "-"; ELSE PRINT "+"; IF I>1 THEN PRINT STR$(ABS(COSINE(I)));"*COS(X)^";STR$(I); ELSE PRINT STR$(ABS(COSINE(I)));"*COS(X)"; END IF END IF NEXT I IF COSINE(0)<>0 THEN IF COSINE(0)<0 THEN PRINT "-"; ELSE PRINT "+"; PRINT STR$(ABS(COSINE(0))); END IF END SUB EXTERNAL SUB COSINEX(F,COSA(),SINA(,),COSB(),SINB(,),COSINE()) OPTION BASE 0 DIM SINE(MAXLEVEL,MAXLEVEL),C(2) LET C(2)=-1 LET C(0)=1 FOR I=0 TO F FOR J=0 TO F-I LET COSINE(I+J)=COSINE(I+J)+COSA(I)*COSB(J) NEXT J NEXT I FOR M=0 TO F FOR N=0 TO F-M FOR I=0 TO F FOR J=0 TO F-I LET SINE(M+N,I+J)=SINE(M+N,I+J)+SINA(M,I)*SINB(N,J) NEXT J NEXT I NEXT N NEXT M FOR L=F TO 2 STEP -2 FOR I=0 TO F-2 FOR J=0 TO 2 LET SINE(L-2,I+J)=SINE(L-2,I+J)+SINE(L,I)*C(J) NEXT J NEXT I NEXT L FOR K=0 TO F LET COSINE(K)=COSINE(K)-SINE(0,K) NEXT K END SUB |
├EXTERNALSUBSINEX(F,COSA(),SINA(,),COSB()... しばっち 2008/02/08 20:45:37 │└!チェビシェフの多項式Tn(x)からn倍角の公... 山中和義 2008/02/09 15:09:21 │ └山中和義さんご返事ありがとうございます。 しばっち 2008/02/10 17:34:35 (修正1回) └!tanのn倍角の公式 山中和義 2008/02/10 17:34:41 (修正1回) └つづき 山中和義 2008/02/10 17:35:22 (修正1回)