Forum de Programmation en langage PANORAMIC


Rejoignez le forum, c’est rapide et facile

Forum de Programmation en langage PANORAMIC
Forum de Programmation en langage PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Rechercher
 
 

Résultats par :
 


Rechercher Recherche avancée

Derniers sujets
» Bonne année 2024
La transformation conforme EmptyLun 1 Jan - 0:25 par Papydall-Admin

» A ceux qui célèbre Noël, bonnes fêtes
La transformation conforme EmptyDim 24 Déc - 10:49 par Papydall-Admin

» Joyeux Noël et Bonne Année
La transformation conforme EmptyVen 8 Déc - 1:34 par Papydall-Admin

» Planets of the Solar System : Tilts and Spins
La transformation conforme EmptyLun 20 Mar - 15:43 par Papydall-Admin

» Bonne Année 2023
La transformation conforme EmptySam 31 Déc - 1:39 par Papydall-Admin

» Fractals - Mandelbrot
La transformation conforme EmptyVen 21 Aoû - 22:51 par Papydall-Admin

» Convertisseur Décimal ---> Binaire, Octal, Hexadécimal, ...
La transformation conforme EmptyMer 21 Nov - 1:08 par Papydall-Admin

» Balises {USER...}
La transformation conforme EmptyLun 19 Nov - 22:12 par Papydall-Admin

» Useful Dog
La transformation conforme EmptyVen 6 Avr - 14:25 par Papydall-Admin

Avril 2024
LunMarMerJeuVenSamDim
1234567
891011121314
15161718192021
22232425262728
2930     

Calendrier Calendrier

-39%
Le deal à ne pas rater :
Ordinateur portable ASUS Chromebook Vibe CX34 Flip
399 € 649 €
Voir le deal

La transformation conforme

Aller en bas

La transformation conforme Empty La transformation conforme

Message par Papydall-Admin Jeu 13 Oct - 14:41

Salut tout le monde.

Jean_Debord que je remercie beaucoup, a réalisé une bonne bibliothèque pour les nombres complexes, or certains Panoramiciens disent que c’est très mathématique et très pointu.
C’est tout à fait juste :   c’est le domaine des mathématiques supérieures et je me souviens très vaguement que j’en ai fais beaucoup quand j’étais plus jeune et moins bête que maintenant !
Il m’est impossible de dénombrer les domaines où les nombres complexes entrent en scène, mais  Monsieur tout le monde peut mener son train de vie sans jamais sentir le besoin de recourir aux complexes !

Bon, sans faire de publicité pour les complexes, je vous propose simplement un code pour visualiser ces fonctions complexes en utilisant la bibliothèque de Jean_Debord.

Rappel mathématique que vous pouvez sauter 

Quand on veut visualiser les fonctions réelles, on trace leur graphe en coordonnées cartésiennes : par exemple y = x² représente une parabole. Mais pour tracer les fonctions complexes (appelées aussi fonctions analytiques) on se heurte à un obstacle sérieux :  le nombre z et son image f(z) ont chacun deux coordonnées ce qui signifie qu’il nous faut quatre dimensions pour représenter l’équivalent complexe du graphe d’une fonction.
Or nous ne sommes que des simples créatures tridimensionnelles ! Contentons-nous de ces trois dimensions pour visualiser nos fonctions complexes. Mais notre écran de visualisation est (jusqu’ à nouvel ordre) un vulgaire plan à deux dimensions.
Comme les mathématiciens n’abandonnent pas de si tôt, ils ont inventé la transformation conforme . Cette transformation possède des nombreuses propriétés. L’une d’entre elle est la  conservation des angles 
Par exemple, si on part d’un quadrillage orthogonal, les lignes courbes obtenues par la transformation conforme se couperont à angle droit.

Après ce long discours qui vaut ce qu’il vaut, voici le code qui comporte le graphe d’une vingtaine de fonctions complexes à tester une à une.




Code:
rem ============================================================================
rem            Transformation conforme
rem                Par Papydall
rem Utilisant la bibliothèques de calculs sur les nombres complexes de Jean_Debord
rem ============================================================================

Init()
Variables_Globales()
Transformation()

end
rem ============================================================================
SUB Init()
    dim xi,xm,yi,ym,xmin,xmax,ymin,ymax,dx,dy,lx,ly
    full_space 0 : color 0,0,0,0  : 2d_pen_color 0,255,255
    dx = 51 : dy = 31 : lx = screen_x : ly = screen_y
    xi = -1.55 : xm = 1.55 : yi = -1.55 : ym = 1.55
    xmin = -5  : xmax = 5 : ymin = -3  : ymax = 3
    dim reseauX(dx),reseauY(dy)
END_SUB
rem ============================================================================
SUB Plot(re1,im1,re2,im2)
    dim_local x1,y1,x2,y2
    x1 = int(lx*(re1-xmin)/(xmax-xmin))
    y1 = int(ly*(im1-ymin)/(ymax-ymin))
    x2 = int(lx*(re2-xmin)/(xmax-xmin))
    y2 = int(ly*(im2-ymin)/(ymax-ymin))
    2d_line x1,y1,x2,y2
END_SUB
rem ============================================================================
SUB Transformation()
    dim_local i,j,re,im ,r1,i1
    for i = 0 to dx
        for j = 0 to dy
            re = xi + i *(xm-xi)/dx
            im = yi + j *(ym-yi)/dy
rem ============================================================================
rem &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
rem ============================================================================
' Essayez une à une ces différentes fonctions
           caption 0, "Transformation conforme : f(z) = 1/z"        : CInv(re,im)           : ' f(z) = 1/z
         '  caption 0, "Transformation conforme : f(z) = tan(z)"     : CTan(re,im)           : ' f(z) = tan(z)
         '  caption 0, "Transformation conforme : f(z) = cos(z)"     : CCos(re,im)           : ' f(z) = cos(z)
         '  caption 0, "Transformation conforme : f(z) = sin(z)"     : CSin(re,im)           : ' f(z) = sin(z)
         '  caption 0, "Transformation conforme : f(s) = z*z"        : CSquare(re,im)        : ' f(z) = z*z
         '  caption 0, "Transformation conforme : f(z) = z*z*z"      : CCube(re,im)          : ' f(z) = z*z*z
         '  caption 0, "Transformation conforme : f(z) = sqr(z)"     : CSqrt(re,im)          : ' f(z) = sqr(z)
         '  caption 0, "Transformation conforme : f(z) = Log(z)"     : CLog(re,im)           : ' f(z) = Log(z)
         '  caption 0, "Transformation conforme : f(z) = Exp(z)"     : CExp(re,im)           : ' f(z) = Exp(z)
         '  caption 0, "Transformation conforme : f(z) = z^p"        : CRealPower(re,im,5.3) : ' f(z) = z^p avec p réel = 5.3 dans ce cas
         '  caption 0, "Transformation conforme : f(z) = z^c"        : CPower(re,im,3/2,-1)  : ' f(z) = z^c  avec c complexe = 1.5 - i dans ce cas
         '  caption 0, "Transformation conforme : f(z) = hsin(z)"    : CSinh(re,im)          : ' f(z) = hsin(z)
         '  caption 0, "Transformation conforme : f(z) = hcos(z)"    : CCosh(re,im)          : ' f(z) = hcos(z)
         '  caption 0, "Transformation conforme : f(z) = htan(z)"    : CTanh(re,im)          : ' f(z) = htan(z)
         '  caption 0, "Transformation conforme : f(z) = ArcSin(z)"  : CASin(re,im)          : ' f(z) = ArcSin(z)
         '  caption 0, "Transformation conforme : f(z) = ArcCos(z)"  : CACos(re,im)          : ' f(z) = ArcCos(z)
         '  caption 0, "Transformation conforme : f(z) = ArcTan(z)"  : CATan(re,im)          : ' f(z) = ArcTan(z)
         '  caption 0, "Transformation conforme : f(z) = ArcHsin(z)" : CASinh(re,im)         : ' f(z) = ArcHSin(z)
         '  caption 0, "Transformation conforme : f(z) = ArcHcos(z)" : CACosh(re,im)         : ' f(z) = ArcHcos(z)
         '  caption 0, "Transformation conforme : f(z) = ArcHtan(z)" : CATanh(re,im)         : ' f(z) = ARCHTan(z)
rem ============================================================================
rem &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
rem ============================================================================
            if j > 0 then plot(reseauX(j-1),reseauY(j-1),r_x,r_y)
            if i > 0 then plot(reseauX(j),reseauY(j),r_x,r_y)
            reseauX(j) = r_x : reseauY(j) = r_y
        next j
    next i
END_SUB
            
rem ============================================================================
rem          Bibliothèque de calculs sur les nombres complexes
rem                       Par Jean Debord
rem ============================================================================

rem ============================================================================
SUB Variables_Globales()
' Constantes mathématiques
    dim MaxNum, MinNum, MaxLog, MinLog, PiDiv2
    MaxLog = 709.78 : ' Argument max. pour EXP
    MinLog = -708.39 : ' Argument min. pour EXP
    MaxNum = exp(MaxLog) : ' Nb reel max. ~ 2^1024
    MinNum = exp(MinLog) : ' Nb reel min. ~ 2^(-1022)
    PiDiv2 = Pi / 2

' Résultats des calculs
' Partie réelle, partie imaginaire, module, argument, signe
    dim r_x, r_y, r_mod, r_arg, r_sgn
' Code d'erreur
' 0 = pas d'erreur
' -1 = argument hors bornes
' -2 = singularite
' -3 = overflow
' -4 = underflow
    dim ErrCode%
END_SUB
rem ============================================================================
sub CMul(a_x, a_y, b_x, b_y)
' Multiplication : r_x + i r_y = (a_x + i a_y) * (b_x + i b_y)
    ErrCode% = 0
    r_x = a_x * b_x - a_y * b_y
    r_y = a_x * b_y + a_y * b_x
end_sub
rem ============================================================================
sub CSquare(a_x, a_y)
' Carré : r_x + i r_y = (a_x + i a_y)^2
    ErrCode% = 0
    r_x = a_x * a_x - a_y * a_y
    r_y = 2 * a_x * a_y
end_sub
rem ============================================================================
sub CCube(a_x, a_y)
' Cube : r_x + i r_y = (a_x + i a_y)^3
    dim_local x2, y2, x3, y3
    ErrCode% = 0
    x2 = a_x * a_x : x3 = x2 * a_x
    y2 = a_y * a_y : y3 = y2 * a_y
    r_x = x3 - 3 * a_x * y2
    r_y = 3 * x2 * a_y - y3
end_sub
rem ============================================================================
sub CIntPower(a_x, a_y, n%)
' Puissance entière : r_x + i r_y = (a_x + i a_y)^n
    dim_local m%, b_x, b_y, res_x, res_y
    ErrCode% = 0
    if a_x = 0 and a_y = 0
       if n% = 0
' 0^0 = lim x^x quand x --> 0 = 1
          r_x = 1
          r_y = 0
      else
         if n% > 0
' 0^n = 0 si n > 0
            r_x = 0
            r_y = 0
            else
' 0^n indéfini si n < 0
                ErrCode% = -2
                r_x = MaxNum
                r_y = MaxNum
         end_if
      end_if
    else
      if n% < 0
         m% = abs(n%)
         CInv(a_x, a_y)
         b_x = r_x
         b_y = r_y
      else
         m% = n%
         b_x = a_x
         b_y = a_y
      end_if
      res_x = 1 : res_y = 0
      while m% > 0
            if odd(m%) = 1
               CMul(b_x, b_y, res_x, res_y)
               res_x = r_x
               res_y = r_y
            end_if
            CSquare(b_x, b_y)
            b_x = r_x
            b_y = r_y
            m% = int(m% / 2)
      end_while
      r_x = res_x
      r_y = res_y
    end_if
end_sub
rem ============================================================================
sub CDiv(a_x, a_y, b_x, b_y)
' Division : r_x + i r_y = (a_x + i a_y) / (b_x + i b_y)
' Algorithme d'après "Numerical Recipes"
    dim_local q, t
    if b_x = 0 and b_y = 0
       ErrCode% = -3
       r_x = MaxNum
       r_y = MaxNum
    else
       ErrCode% = 0
       if abs(b_x) >= abs(b_y)
          q = b_y / b_x
          t = b_x + b_y * q
          r_x = (a_x + a_y * q) / t
          r_y = (a_y - a_x * q) / t
       else
          q = b_x / b_y
          t = b_x * q + b_y
          r_x = (a_x * q + a_y) / t
          r_y = (a_y * q - a_x) / t
       end_if
    end_if
end_sub
rem ============================================================================
sub CInv(a_x, a_y)
' Inverse : r_x + i r_y = 1 / (a_x + i a_y)
    dim_local Temp
    if a_x = 0 and a_y = 0
       ErrCode% = -3
       r_x = MaxNum
       r_y = MaxNum
    else
       ErrCode% = 0
       Temp = a_x * a_x + a_y * a_y
       r_x = a_x / Temp
       r_y = 0 - a_y / Temp
    end_if
end_sub
rem ============================================================================
sub CSgn(a_x, a_y)
' Signe complexe
    ErrCode% = 0
    if a_x > 0
       r_sgn = 1
    else
       if a_y < 0
          r_sgn = -1
       else
          if a_y > 0
             r_sgn = 1
          else
             if a_y < 0
                r_sgn= -1
             else
                r_sgn = 0
             end_if
          end_if
       end_if
    end_if
end_sub
rem ============================================================================
sub CAbs(a_x, a_y)
' Module : r_mod = |a_x + i a_y|
' Algorithme d'après "Numerical Recipes"
    ErrCode% = 0
    dim_local AbsX, AbsY, R, C
    AbsX = abs(a_x)
    AbsY = abs(a_y)
    if a_x = 0
       r_mod = abs(a_y)
    else
       if a_y = 0
          r_mod = abs(a_x)
       else
          if AbsX > AbsY
             R = AbsY / AbsX
             C = AbsX
          else
             R = AbsX / AbsY
             C = AbsY
          end_if
          r_mod = C * sqr(1 + R * R)
       end_if
    end_if
end_sub
rem ============================================================================
sub CArg(a_x, a_y)
' Argument : r_arg = arg(a_x + i a_y)
' Résultat dans [-Pi, Pi)
' Equivaut a atan2(a_y, a_x)
    ErrCode% = 0
    if a_x = 0
       r_arg = sgn(a_y) * PiDiv2
    else
' 4e / 1er quadrant : -Pi/2..Pi/2
       r_arg = atn(a_y / a_x)
       if a_x < 0
          if a_y > 0
' 2e quadrant : Pi/2..Pi
             r_arg = r_arg + Pi
          else
' 3e quadrant : -Pi..-Pi/2
             r_arg = r_arg - Pi
          end_if
       end_if
    end_if
end_sub
rem ============================================================================
sub ATan2(y, x)
' atn(y/x) --> Résultat dans [-Pi, Pi)
    CArg(x, y)
end_sub
rem ============================================================================
sub CSqrt(a_x, a_y)
' Racine carrée : r_x + i r_y = sqrt(a_x + i a_y)
' Algorithme d'après "Numerical Recipes"
    dim_local X, Y, W, R
       X = abs(a_x)
       Y = abs(a_y)
    ErrCode% = 0
    if a_x = 0 and a_y = 0
       r_x = 0
       r_y = 0
    else
       if X >= Y
          R = Y / X
          W = sqr(X) * sqr(0.5 * (1 + sqr(1 + R * R)))
       else
          R = X / Y
          W = sqr(Y) * sqr(0.5 * (R + sqr(1 + R * R)))
       end_if
       if a_x >= 0.0
          r_x = W
          r_y = a_y / (2 * r_x)
       else
          if a_y >= 0
             r_y = W
          else
             r_y = 0 - W
          end_if
          r_x = a_y / (2 * r_y)
       end_if
    end_if
end_sub
rem ============================================================================
sub CLog(a_x, a_y)
' Partie principale du logarithme complexe
' r_x + i r_y = ln(a_x + i a_y)
    if a_x = 0 and a_y = 0
       ErrCode% = -2
       r_x = 0 - MaxNum
       r_y = 0
    else
       ErrCode% = 0
       CAbs(a_x, a_y)
       CArg(a_x, a_y)
       r_x = log(r_mod)
       r_y = r_arg
    end_if
end_sub
rem ============================================================================
sub CExp(a_x, a_y)
' Exponentielle complexe : r_x + i r_y = exp(a_x + i a_y)
    dim_local ExpX
    if a_x < MinLog
       ErrCode% = -4
       r_x = 0
       r_y = 0
    else
       if a_x > MaxLog
          ErrCode = -3
          ExpX = MaxNum
       else
          ErrCode% = 0
          ExpX = exp(a_x)
       end_if
       r_x = ExpX * cos(a_y)
       r_y = ExpX * sin(a_y)
   end_if
end_sub
rem ============================================================================
sub CRealPower(a_x, a_y, p)
' Puissance (exposant réel) : (a_x + i a_y)^p
' Résultat dans r_x, r_y
' Résultat aussi dans r_mod, r_arg si a <> 0
    ErrCode% = 0
    if a_x = 0 and a_y = 0
       if p = 0
' 0^0 = lim x^x quand x --> 0 = 1
          r_x = 1
          r_y = 0
       else
          if p > 0
' 0^p = 0 si p > 0
             r_x = 0
             r_y = 0
          else
' 0^p indéfini si p < 0
             ErrCode% = -2
             r_x = MaxNum
             r_y = MaxNum
          end_if
       end_if
    else
       CAbs(a_x, a_y)
       CArg(a_x, a_y)
       r_mod = power(r_mod, p)
       r_arg = r_arg * p
       r_x = r_mod * cos(r_arg)
       r_y = r_mod * sin(r_arg)
    end_if
end_sub
rem ============================================================================
sub CPower(a_x, a_y, b_x, b_y)
' Puissance (exposant complexe) : (a_x + i a_y)^(b_x + i b_y)
' Résultat dans r_x, r_y
    ErrCode% = 0
    if a_x = 0 and a_y = 0
       if b_x = 0 and b_y = 0
' 0^0 = lim x^x quand x --> 0 = 1
          r_x = 1
          r_y = 0
       else
' 0^p = 0 si p > 0
          r_x = 0
          r_y = 0
       end_if
    else
' exp(b ln(a))
       CAbs(a_x, a_y)
       CArg(a_x, a_y)
       CMul(b_x, b_y, log(r_mod), r_arg)
       CExp(r_x, r_y)
    end_if
end_sub
rem ============================================================================
sub CSin(a_x, a_y)
' Sinus complexe : r_x + i r_y = sin(a_x + i a_y)
    ErrCode% = 0
    r_x = sin(a_x) * hcos(a_y)
    r_y = cos(a_x) * hsin(a_y)
end_sub
rem ============================================================================
sub CCos(a_x, a_y)
' Cosinus complexe : r_x + i r_y = cos(a_x + i a_y)
    ErrCode% = 0
    r_x = cos(a_x) * hcos(a_y)
    r_y = 0 - sin(a_x) * hsin(a_y)
end_sub
rem ============================================================================
sub CSinh(a_x, a_y)
' Sinus hyperbolique complexe : r_x + i r_y = sinh(a_x + i a_y)
    ErrCode% = 0
    r_x = hsin(a_x) * cos(a_y)
    r_y = hcos(a_x) * sin(a_y)
end_sub
rem ============================================================================
sub CCosh(a_x, a_y)
' Cosinus hyperbolique complexe : r_x + i r_y = cosh(a_x + i a_y)
    ErrCode% = 0
    r_x = hcos(a_x) * cos(a_y)
    r_y = hsin(a_x) * sin(a_y)
end_sub
rem ============================================================================
sub CTan(a_x, a_y)
' Tangente complexe : r_x + i r_y = tan(a_x + i a_y)
    dim_local X2, Y2, Temp
    X2 = 2 * a_x
    Y2 = 2 * a_y
    Temp = cos(X2) + hcos(Y2)
    if Temp <> 0
       ErrCode% = 0
       r_x = sin(X2) / Temp
       r_y = hsin(Y2) / Temp
    else
' a = Pi/2 + k*Pi
       ErrCode% = -2
       r_x = MaxNum
       r_y = 0
    end_if
end_sub
rem ============================================================================
sub CTanh(a_x, a_y)
' Tangente hyperbolique complexe : r_x + i r_y = tanh(a_x + i a_y)
    dim_local X2, Y2, Temp
    X2 = 2.0 * a_x
    Y2 = 2.0 * a_y
    Temp = hcos(X2) + cos(Y2)
    if Temp = 0
' a = i * (Pi/2 + k*Pi)
       ErrCode% = -2
       r_x = 0
       r_y = MaxNum
    else
       ErrCode% = 0
       r_x = hsin(X2) / Temp
       r_y = sin(Y2) / Temp
    end_if
end_sub
rem ============================================================================
sub CASin(a_x, a_y)
' Arc Sinus complexe : r_x + i r_y = asin(a_x + i a_y)
    dim_local X2, XX, YY, Rp, Rm, S, T
    X2 = 2 * a_x
    XX = a_x * a_x
    YY = a_y * a_y
    S = XX + YY + 1
    Rp = 0.5 * sqr(S + X2)
    Rm = 0.5 * sqr(S - X2)
    T = Rp + Rm
    ErrCode% = 0
    CSgn(a_y, 0 - a_x)
    r_x = asin(Rp - Rm)
    r_y = r_sgn * log(T + sqr(T * T - 1))
end_sub
rem ============================================================================
sub CACos(a_x, a_y)
' Arc Cosinus complexe :
' r_x + i r_y = acos(a_x + i a_y) = Pi/2 - ASin(a)
    CASin(a_x, a_y)
    r_x = PiDiv2 - r_x
    r_y = 0 - r_y
end_sub
rem ============================================================================
sub CATan(a_x, a_y)
' Arc Tangente complexe : r_x + i r_y = atan(a_x + i a_y)
    dim_local XX, YY, Yp1, Ym1, A1, A2
    if a_x = 0 and abs(a_y) = 1
' a = +/- i
       ErrCode% = -2
       r_x = 0
       r_y = sgn(a_y) * MaxNum
    else
       ErrCode% = 0
       XX = a_x * a_x
       YY = a_y * a_y
       Yp1 = a_y + 1
       Ym1 = a_y - 1
       CArg(0 - Ym1, a_x) : A1 = r_arg : ' = atan2(a_x, - Ym1)
       CArg(Yp1, 0 - a_x) : A2 = r_arg : ' = atan2(- Ym1, a_x)
       r_x = 0.5 * (A1 - A2)
       r_y = 0.25 * log((XX + Yp1 * Yp1) / (XX + Ym1 * Ym1))
    end_if
end_sub
rem ============================================================================
sub CASinh(a_x, a_y)
' Argument Sinus hyperbolique complexe :
' r_x + i r_y = asinh(a_x + i a_y) = -i*asin(i*a)
' i * (a_x + i a_y) = -a_y + i a_x
    dim_local t
    CASin(0 - a_y, a_x)
    t = r_x
    r_x = r_y
    r_y = 0 - t
end_sub
rem ============================================================================
sub CACosh(a_x, a_y)
' Argument Cosinus hyperbolique complexe :
' r_x + i r_y = acosh(a_x + i a_y) = csgn(a_y + i(1 - a_x)) * i * acos(a)
    dim_local t
    CSgn(a_y, 1 - a_x)
    CACos(a_x, a_y)
    t = r_x
    r_x = 0 - r_sgn* r_y
    r_y = r_sgn * t
end_sub
rem ============================================================================
sub CATanh(a_x, a_y)
' Argument Tangente hyperbolique complexe :
' r_x + i r_y = atanh(a_x + i a_y) = -i*atan(i*a)
    dim_local t
    CATan(0 - a_y, a_x)
    t = r_x
    r_x = r_y
    r_y = 0 - t
end_sub
rem ============================================================================
Papydall-Admin
Papydall-Admin
Admin

Messages : 93
Réputation : 0
Date d'inscription : 08/09/2015
Age : 73
Localisation : MOKNINE (Tunisie)

https://papydall-panoramic.forumarabia.com

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum