新しく発言する  EXIT  インデックスへ

多項式逆数


  多項式逆数 しばっち 2008/03/28 20:30:14 
多項式逆数  返事を書く  ノートメニュー
しばっち <dihjvcfsyu> 2008/03/28 20:30:14
F(X)=A+B*X+C*X^2+D*X^3+...
G(X)=A'+B'X+C'X^2+D'X^3+...
F(X)/G(X)=1 G(X)を求める

恒等式 (A+B*X+C*X^2+D*X^3+E*X^4+...)(A'+B'*X+C'*X^2+D'*X^3+E'*X^4+...)=1

AA'=1
AB'+BA'=0
AC'+BB'+CA'=0
AD'+BC'+CB'+DA'=0
AE'+BD'+CC'+DB'+EA'=0
:

A'=1/A
B'=-BA'/A
C'=-(BB'+CA')/A
D'=-(BC'+CB'+DA')/A
:

PUBLIC NUMERIC MAXLEVEL,MINLEVEL
LET MAXLEVEL=21
LET MINLEVEL=-2
DIM C(MINLEVEL TO MAXLEVEL)
CALL COSINE(C)
PRINT "COS(X)=";
CALL DISPLAY(C)
CALL RECIP(C)
PRINT "1/COS(X)=";
CALL DISPLAY(C)
CALL SINE(C)
PRINT "SIN(X)=";
CALL DISPLAY(C)
CALL RECIP(C)
PRINT "1/SIN(X)=";
CALL DISPLAY(C)
END

EXTERNAL SUB RECIP(C())
DIM XX(MINLEVEL TO MAXLEVEL),X(MINLEVEL TO MAXLEVEL)
LET M=DIMCHECKLOW(C)
LET X(-M)=1/C(M)
FOR K=-M+1 TO MAXLEVEL
CALL CLR(XX)
FOR I=0 TO MAXLEVEL
FOR J=-M TO MAXLEVEL-I
LET XX(I+J)=XX(I+J)+C(I)*X(J)
NEXT J
NEXT I
IF K-M<>-M THEN LET X(K-M)=-XX(K)/C(M)
NEXT K
CALL COPY(C,X)
END SUB

EXTERNAL SUB COPY(X(),Y())
FOR I=MINLEVEL TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB

EXTERNAL SUB CLR(X())
FOR I=MINLEVEL TO MAXLEVEL
LET X(I)=0
NEXT I
END SUB

EXTERNAL SUB DISPLAY(A())
LET N=DIMCHECKHIGH(A)
IF N>1 THEN
IF A(N)<0 THEN PRINT "-";
IF ABS(A(N))<>1 THEN
PRINT STR$(ABS(A(N)));"*X^";STR$(N);
ELSE
PRINT "X^";STR$(N);
END IF
END IF
FOR I=N-1 TO 2 STEP -1
IF A(I)<>0 THEN
IF A(I)<0 THEN PRINT "-"; ELSE PRINT "+";
IF ABS(A(I))<>1 THEN
PRINT STR$(ABS(A(I)));"*X^";STR$(I);
ELSEIF ABS(A(I))=1 THEN
PRINT "X^";STR$(I);
END IF
END IF
NEXT I
IF A(1)<>0 THEN
IF N>1 THEN
IF A(1)<0 THEN PRINT "-"; ELSE PRINT "+";
END IF
IF ABS(A(1))<>1 THEN
PRINT STR$(ABS(A(1)));"*X";
ELSEIF ABS(A(1))=1 THEN
PRINT "X";
END IF
END IF
IF A(0)<>0 THEN
IF A(0)<0 THEN PRINT "-"; ELSE PRINT "+";
PRINT STR$(ABS(A(0)));
END IF
IF MINLEVEL<0 THEN
FOR I=-1 TO MINLEVEL STEP -1
IF A(I)<>0 THEN
IF A(I)<0 THEN PRINT "-"; ELSE PRINT "+";
IF I=-1 THEN
PRINT STR$(ABS(A(I)));"/X";
ELSE
PRINT STR$(ABS(A(I)));"/X^";STR$(ABS(I));
END IF
END IF
NEXT I
END IF
PRINT
END SUB

EXTERNAL FUNCTION DIMCHECKHIGH(X())
FOR N=MAXLEVEL TO MINLEVEL STEP -1
IF X(N)<>0 THEN EXIT FOR
NEXT N
LET DIMCHECKHIGH=N
END FUNCTION

EXTERNAL FUNCTION DIMCHECKLOW(X())
FOR N=MINLEVEL TO MAXLEVEL
IF X(N)<>0 THEN EXIT FOR
NEXT N
LET DIMCHECKLOW=N
END FUNCTION
  続き しばっち 2008/03/28 20:30:59 
  多項式平方根 しばっち 2008/03/28 20:31:48 
   └続き しばっち 2008/03/28 20:32:38 

 インデックスへ  EXIT
新規発言を反映させるにはブラウザの更新ボタンを押してください。