'transco ' 09/08/1993 DEFINT A-Z DECLARE SUB conjuge (c1 AS ANY, c AS ANY) DECLARE SUB Produit (c1 AS ANY, c2 AS ANY, c AS ANY) DECLARE FUNCTION Module! (c AS ANY) DECLARE FUNCTION Argument! (c AS ANY) DECLARE SUB Somme (c1 AS ANY, c2 AS ANY, c AS ANY) DECLARE SUB Division (c1 AS ANY, c2 AS ANY, c AS ANY) DECLARE SUB Exponentielle (c1 AS ANY, c AS ANY) DECLARE SUB plot (c1 AS ANY, c2 AS ANY) DECLARE SUB affiche (c AS ANY) DECLARE SUB Fonction1 (c AS ANY, c1 AS ANY) DECLARE SUB Fonction2 (c AS ANY, c1 AS ANY) DECLARE SUB Fonction3 (c AS ANY, c1 AS ANY) DECLARE SUB Fonction4 (c AS ANY, c1 AS ANY) CONST pi = 3.141592654# CONST dx = 51 CONST dy = 31 CONST lx = 639'459 CONST ly = 199 TYPE complex re AS SINGLE im AS SINGLE END TYPE DIM c AS complex, c1 AS complex DIM xi AS SINGLE, xm AS SINGLE, ym AS SINGLE DIM xmin AS SINGLE, ymin AS SINGLE DIM xmax AS SINGLE, ymax AS SINGLE DIM i AS INTEGER, j AS INTEGER DIM reseau(0 TO dx) AS complex CLS xi = -1.55 xm = 1.55 yi = -1.55 ym = 1.55 xmin = -5 xmax = 5 ymin = -3 ymax = 3 SCREEN 2 Numfonc = 1 FOR i = 0 TO dx FOR j = 0 TO dy c.re = xi + i * (xm - xi) / dx c.im = yi + j * (ym - yi) / dy SELECT CASE Numfonc CASE 1 Fonction1 c, c1 CASE 2 Fonction2 c, c1 CASE 3 Fonction3 c, c1 CASE 4 Fonction4 c, c1 CASE ELSE END SELECT IF (j > 0) THEN plot reseau(j - 1), c1 IF (i > 0) THEN plot reseau(j), c1 reseau(j) = c1 NEXT j NEXT i a$ = INPUT$(1) CLS SCREEN 0 END ' ' ' ' ' ' SUB affiche (c AS complex) PRINT c.re; " + "; c.im; ".i" END SUB ' ' ' ' ' ' FUNCTION Argument! (c AS complex) DIM t AS SINGLE IF (c.re = 0) THEN IF (c.im = 0) THEN Argument! = 0 ELSEIF (c.im > 0) THEN Argument! = pi / 2! ELSE Argument! = -pi / 2! END IF ELSE t = ATN(c.im / c.re) IF (c.re < 0) THEN IF (c.im < 0) THEN Argument! = t - pi ELSE Argument! = t + pi END IF ELSE Argument! = t END IF END IF END FUNCTION ' ' ' ' ' SUB conjuge (c1 AS complex, c AS complex) c.re = c1.re c.im = -c1.im END SUB ' ' ' ' ' ' SUB Division (c1 AS complex, c2 AS complex, c AS complex) DIM cc AS complex, modul2 AS SINGLE conjuge c2, cc Produit c1, cc, c modul2 = c2.re * c2.re + c2.im * c2.im IF (modul2 = 0) THEN modul2 = 1E-20 c.re = c.re / modul2 c.im = c.im / modul2 END SUB ' ' ' ' ' ' SUB Exponentielle (c1 AS complex, c AS complex) c.re = EXP(c1.re) * COS(c1.im) c.im = EXP(c1.re) * SIN(c1.im) END SUB ' ' ' ' ' ' SUB Fonction1 (c AS complex, c1 AS complex) 'f(z)=tan(z) DIM un AS complex, p AS complex, q AS complex DIM r AS complex, s AS complex un.re = 0 un.im = 1! Produit c, un, p 'p -> i.c Exponentielle p, q 'q -> exp(i.c) p.re = -p.re p.im = -p.im Exponentielle p, r 'r -> exp(-i.c) Somme q, r, p 'p -> exp(i.c)+exp(-i.c) r.re = -r.re r.im = -r.im Somme q, r, s 's -> exp(i.c)-exp(-i.c) Division s, p, q 'q -> (exp(i.c)-exp(-i.c)/(exp(i.c)+exp(-i.c)) un.re = 0 un.im = 1 Division q, un, c1 END SUB ' ' ' ' ' ' SUB Fonction2 (c AS complex, c1 AS complex) 'F(z)=cos(z) DIM un AS complex, p AS complex DIM q AS complex, r AS complex un.re = 0 un.im = 1! Produit c, un, p 'p -> i.c Exponentielle p, q 'q -> Exp(i.c) p.re = -p.re p.im = -p.im Exponentielle p, r 'r -> Exp(-ic.) Somme q, r, p 'p -> Exp(ic.)+Exp(-ic.) c1.re = p.re / 2 c1.im = p.im / 2 END SUB ' ' ' ' ' ' SUB Fonction3 (c AS complex, c1 AS complex) DIM un AS complex un.re = 1 un.im = 0 Division un, c, c1 END SUB ' ' ' ' ' ' SUB Fonction4 (c AS complex, c1 AS complex) 'F(z)=cos(z) DIM un AS complex, p AS complex DIM q AS complex, r AS complex un.re = 1 un.im = 0 Produit c, c, p Somme p, un, q un.re = -1 Somme p, un, r Division r, q, c1 END SUB ' ' ' ' ' ' FUNCTION Module! (c AS complex) Module = SQR(c.re * c.re + c.im * c.im) END FUNCTION ' ' ' ' ' ' SUB plot (c1 AS complex, c2 AS complex) DIM x1 AS INTEGER, y1 AS INTEGER DIM x2 AS INTEGER, y2 AS INTEGER SHARED xmin AS SINGLE, xmax AS SINGLE SHARED ymin AS SINGLE, ymax AS SINGLE x1 = INT(lx * (c1.re - xmin) / (xmax - xmin)) y1 = INT(ly * (c1.im - ymin) / (ymax - ymin)) x2 = INT(lx * (c2.re - xmin) / (xmax - xmin)) y2 = INT(ly * (c2.im - ymin) / (ymax - ymin)) LINE (x1, y1)-(x2, y2) END SUB ' ' ' ' ' ' SUB Produit (c1 AS complex, c2 AS complex, c AS complex) c.re = c1.re * c2.re - c1.im * c2.im c.im = c1.re * c2.im + c1.im * c2.re END SUB ' ' ' ' ' ' SUB Racine (c1 AS complex, c AS complex) DIM m AS SINGLE, arg AS SINGLE m = SQR(Module(c1)) arg = Argument(c1) / 2! c.re = m * COS(arg) c.im = m * SIN(arg) END SUB ' ' ' ' ' ' SUB Somme (c1 AS complex, c2 AS complex, c AS complex) c.re = c1.re + c2.re c.im = c1.im + c2.im END SUB