投稿者:しばっち
投稿日:2020年 4月 5日(日)14時27分39秒
|
|
|
X^2+Y^2-3*X*Y+1=0のグラフ
https://hp.vector.co.jp/authors/VA008683/F_GRAPH.htm
導関数 dy/dx=(2*x-3*y)/(3*x-2*y)を求め、dx/dt=3*x-2*y dy/dt=2*x-3*yとして
2元連立常微分方程式をルンゲクッタ法で解く
https://www.wolframalpha.com/input/?i=x%5E2%2By%5E2-3*x*y%2B1%3D0%2Cdy%2Fdx&lang=ja
陰関数 F(x,y)=0のグラフはdy/dx=f(x,y)の解曲線とすれば描画できる。
LET XS=-5
LET XE=5
LET YS=-5
LET YE=5
SET WINDOW XS,XE,YS,YE
DRAW GRID
LET N=100 !'分割数
LET H=(XE-XS)/N
FOR L=1 TO 2
READ XX,YY
DATA 1,1
DATA -1,-1
FOR I=1 TO 2
LET T=0
LET X=XX !'初期値
LET Y=YY
WHEN EXCEPTION IN
FOR J=1 TO N
LET K1=F1(T,X,Y)
LET L1=F2(T,X,Y)
LET K2=F1(T+H/2,X+H/2*K1,Y+H/2*L1)
LET L2=F2(T+H/2,X+H/2*K1,Y+H/2*L1)
LET K3=F1(T+H/2,X+H/2*K2,Y+H/2*L2)
LET L3=F2(T+H/2,X+H/2*K2,Y+H/2*L2)
LET K4=F1(T+H,X+H*K3,Y+H*L3)
LET L4=F2(T+H,X+H*K3,Y+H*L3)
LET X0=X+H*(K1+2*K2+2*K3+K4)/6
LET Y0=Y+H*(L1+2*L2+2*L3+L4)/6
LET T0=T+H
PLOT LINES:X,Y;X0,Y0
LET X=X0
LET Y=Y0
LET T=T0
NEXT J
USE
PLOT LINES
END WHEN
LET H=-H
NEXT I
NEXT L
END
EXTERNAL FUNCTION F1(T,X,Y) !'dx/dt=f1(t,x,y)
LET F1=3*X-2*Y
END FUNCTION
EXTERNAL FUNCTION F2(T,X,Y) !'dy/dt=f2(t,x,y)
LET F2=2*X-3*Y
END FUNCTION
--------------------------------------------------------------------------------
1/(X-Y)-X+3*Y=0のグラフ
dy/dx=((x-y)^2+1)/(3*(x-y)^2+1)
https://www.wolframalpha.com/input/?i=1%2F%28x-y%29-x%2B3*y%3D0%2Cdy%2Fdx&lang=ja
LET XS=-5
LET XE=5
LET YS=-5
LET YE=5
SET WINDOW XS,XE,YS,YE
DRAW GRID
LET N=100 !'分割数
LET H=(XE-XS)/N
FOR L=1 TO 2
READ XX,YY
DATA 1,0
DATA -1,0
FOR I=1 TO 2
LET T=0
LET X=XX !'初期値
LET Y=YY
WHEN EXCEPTION IN
FOR J=1 TO N
LET K1=F1(T,X,Y)
LET L1=F2(T,X,Y)
LET K2=F1(T+H/2,X+H/2*K1,Y+H/2*L1)
LET L2=F2(T+H/2,X+H/2*K1,Y+H/2*L1)
LET K3=F1(T+H/2,X+H/2*K2,Y+H/2*L2)
LET L3=F2(T+H/2,X+H/2*K2,Y+H/2*L2)
LET K4=F1(T+H,X+H*K3,Y+H*L3)
LET L4=F2(T+H,X+H*K3,Y+H*L3)
LET X0=X+H*(K1+2*K2+2*K3+K4)/6
LET Y0=Y+H*(L1+2*L2+2*L3+L4)/6
LET T0=T+H
PLOT LINES:X,Y;X0,Y0
LET X=X0
LET Y=Y0
LET T=T0
NEXT J
USE
PLOT LINES
END WHEN
LET H=-H
NEXT I
NEXT L
END
EXTERNAL FUNCTION F1(T,X,Y) !'dx/dt=f1(t,x,y)
LET F1=3*(X-Y)^2+1
END FUNCTION
EXTERNAL FUNCTION F2(T,X,Y) !'dy/dt=f2(t,x,y)
LET F2=(X-Y)^2+1
END FUNCTION
|
|
|
投稿者:しばっち
投稿日:2020年 4月 8日(水)20時36分41秒
|
|
|
> No.4817[元記事へ]
陰関数 F(x,y)=0 の導関数 dy/dx=f(x,y) は数値微分でも代用できるようです。
LET XS=-5
LET XE=5
LET YS=-5
LET YE=5
SET WINDOW XS,XE,YS,YE
DRAW GRID
LET N=100 !'分割数
LET H=(XE-XS)/N
FOR L=1 TO 2
READ XX,YY
DATA 1,1
DATA -1,-1
FOR I=1 TO 2
LET T=0
LET X=XX !'初期値
LET Y=YY
WHEN EXCEPTION IN
FOR J=1 TO N
LET K1=F1(T,X,Y)
LET L1=F2(T,X,Y)
LET K2=F1(T+H/2,X+H/2*K1,Y+H/2*L1)
LET L2=F2(T+H/2,X+H/2*K1,Y+H/2*L1)
LET K3=F1(T+H/2,X+H/2*K2,Y+H/2*L2)
LET L3=F2(T+H/2,X+H/2*K2,Y+H/2*L2)
LET K4=F1(T+H,X+H*K3,Y+H*L3)
LET L4=F2(T+H,X+H*K3,Y+H*L3)
LET X0=X+H*(K1+2*K2+2*K3+K4)/6
LET Y0=Y+H*(L1+2*L2+2*L3+L4)/6
LET T0=T+H
PLOT LINES:X,Y;X0,Y0
LET X=X0
LET Y=Y0
LET T=T0
IF X>XE OR X<XS OR Y<YS OR Y>YE THEN EXIT FOR
NEXT J
USE
PLOT LINES
END WHEN
LET H=-H
NEXT I
NEXT L
END
EXTERNAL FUNCTION F1(T,X,Y) !'dx/dt=f1(t,x,y)
LET F1=FY(X,Y)
END FUNCTION
EXTERNAL FUNCTION F2(T,X,Y) !'dy/dt=f2(t,x,y)
LET F2=-FX(X,Y)
END FUNCTION
EXTERNAL FUNCTION F(X,Y) !'陰関数 F(x,y)=0
LET F=X^2+Y^2-3*X*Y+1
END FUNCTION
EXTERNAL FUNCTION FX(X,Y) !' ∂/∂x F(x,y)
LET H=1/256
LET FX=(F(X-2*H,Y)-8*F(X-H,Y)+8*F(X+H,Y)-F(X+2*H,Y))/(12*H)
END FUNCTION
EXTERNAL FUNCTION FY(X,Y) !' ∂/∂y F(x,y)
LET H=1/256
LET FY=(F(X,Y-2*H)-8*F(X,Y-H)+8*F(X,Y+H)-F(X,Y+2*H))/(12*H)
END FUNCTION
|
|
|
投稿者:しばっち
投稿日:2020年 4月12日(日)14時46分5秒
|
|
|
> No.4818[元記事へ]
下記のようにしても陰関数のグラフが描画できます。
LET LEFT=-5
LET RIGHT=5
LET BOTTOM=-5
LET TOP=5
SET POINT STYLE 1
SET WINDOW LEF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