Créer des matrices et les aligner

Bonjour,

je vois sur ce forum qu'il est souvent question de Latex pour mettre en forme des formules scientifiques et ca semble être assez puissant.
J'aimerais savoir si en utilisant Latex il est possible d' aligner des matrices.

Je m'explique : lorsque l'on fait un produit matriciel, on le représe souvent avec une martrice en bas à gauche, une autre en haut à droit et la matrice résultat en bas à droite.

C'est exactement cela que j'aimerais savoir produire, si c'est faisable.

Merci pour votre aide précieuse,

Morgan

Réponses

  • <P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><IMG WIDTH="460" HEIGHT="112" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/9/101023/cv/img1.png&quot; ALT="$\displaystyle \begin{array}{cc} & \left( \begin{array}{ccc} a & b & c \\ d & f ......+ 3i \\ 4a+5d+6d & 4b + 5e + 6h & 4c + 5f + 6i \end{array} \right) \end{array} $"></DIV><P></P>
    Comme ça ?
    <BR>$$ \begin{array}{cc}
    <BR> &
    <BR>   \left( \begin{array}{ccc}
    <BR>         a & b & c \\
    <BR>         d & f & g \\
    <BR>         h & i & j
    <BR>   \end{array} \right)
    <BR> \\
    <BR>   \left( \begin{array}{ccc}
    <BR>         1 & 2 & 3 \\
    <BR>         4 & 5 & 6
    <BR>   \end{array} \right)
    <BR> &
    <BR>   \left( \begin{array}{ccc}
    <BR>         a+2d+3g   & b+2e+3h   & c+2f+3i \\
    <BR>         4a+5d+6d & 4b+5e+6h & 4c+5f+6i
    <BR>   \end{array} \right)
    <BR>\end{array} $$
  • Oui super exactement ca que je voulais.

    Merci :)
  • Si à la place de f,g,i,j dans la matrice du haut je veux écrire la matrice bloc M je fais comment?
  • Guimauve devrait revoir la définition du produit de deux matrices.
    Par ailleurs, je n'ai jamais vu l'intérêt de cette présentation bizarroïde, que j'ai déjà rencontré dans de vieux bouquins.
  • Que dire ... Que Guimauve devrait aussi apprendre à se servir du package amsmath ... La solution qu'il propose est ... médiocre ...
  • « Guimauve devrait revoir la définition du produit de deux matrices. »
    Il faut bien sûr remplacer f,g,h,i,j respectivement par e,f,g,h,i.

    e=mc3, le package easybmat est fait pour ça
  • +1 pour Eric.
  • Eric et Aleg, vous pourriez alors donner la solution moins "médiocre"...

    Pour RAJ : cette écriture a l'immense avantage de faciliter les calculs à la main...en tout cas je l'utilise systématiquement (évidemment, avec cet exemple erronné, la méthode est délicate à défendre :-)).
  • Eric et Guimauve c'est quoi ces packages dont vous parlez? Ca se trouve où?
  • Messieurs merci de votre aide mais au passage, si vous estimez qu'il existe de meilleures solutions, je serais heureux que vous nous en fassiez profiter et personnellement je suis très reconnaissant à Guimauve qui pour l'instant est seul à m'avoir proposé une solution.
  • mettre dans le préambule \usepackage{amsmath} puis utiliser

    $$ \begin{array}{cc}
    &
    \begin{pmatrix}
    a & b & c \\
    d & e & f \\
    g & h & i
    \end{pmatrix}
    \\
    \begin{pmatrix}
    1 & 2 & 3 \\
    4 & 5 & 6
    \end{pmatrix}
    &
    \begin{pmatrix}
    a+2d+3g & b+2e+3h & c+2f+3i \\
    4a+5d+6g & 4b+5e+6h & 4c+5f+6i
    \end{pmatrix}
    \end{array} $$

    C'est plus simple que des array car on n'a pas besoin de préciser manuellement le nombre de colonnes.
  • mettre dans le préambule \usepackage{amsmath} puis utiliser

    $$ \begin{array}{cc}
    &
    \begin{pmatrix}
    a & b & c \\
    d & e & f \\
    g & h & i
    \end{pmatrix}
    \\
    \\
    \begin{pmatrix}
    1 & 2 & 3 \\
    4 & 5 & 6
    \end{pmatrix}
    &
    \begin{pmatrix}
    a+2d+3g & b+2e+3h & c+2f+3i \\
    4a+5d+6g & 4b+5e+6h & 4c+5f+6i
    \end{pmatrix}
    \end{array} $$

    C'est plus simple que des array car on n'a pas besoin de préciser manuellement le nombre de colonnes.
  • Si je peux me permettre de vous demander encore une petite précision? Est-il possible d'aligner les colonnes c'est à dire, de faire en sorte que adg se retrouvent juste au dessus de a +2d +3 g etc?
  • oui, il suffit d'introduire des espaces fantômes horizontaux dans la matrice située au-dessus (celle où il y a a,d,g,..etc..) : je pense que c'est à cette solution qu'Eric, notre grand gourou Latex à nous, faisait allusion dans son message..
  • Vote grand gourou ? ca veut dire qu'il habite en Australie?
    merci je testerai ca dès le debut du week end :)
  • "Votre grand gourou ? ca veut dire qu'il habite en Australie?"
    Excellente, celle-là !!
  • On peut faire un code plus simple avec le package amsmath.
    <BR>
    <BR>Première option, bourrin ...
    <P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><TABLE CELLPADDING="0" WIDTH="100%" ALIGN="CENTER"><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="3" HEIGHT="29" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img1.png&quot; ALT="$\displaystyle \newline$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="58" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img2.png&quot; ALT="$\displaystyle \begin{pmatrix}
    \newline 1 & 2 \\
    \newline 3 & 4
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="61" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img3.png&quot; ALT="$\displaystyle \newline \begin{pmatrix}
    \newline 5 & 6 \\
    \newline 7 & 8
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="77" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img4.png&quot; ALT="$\displaystyle \begin{pmatrix}
    \newline 21 & 34 \\
    \newline 31 & 46
    \newline \end{pmatrix}
    \newline$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR></TABLE></DIV><P></P>
    \begin{align*}
    <BR>  & \begin{pmatrix}
    <BR>       1 & 2 \\
    <BR>       3 & 4
    <BR>       \end{pmatrix}
    <BR>  \\
    <BR>   \begin{pmatrix}
    <BR>       5 & 6 \\
    <BR>       7 & 8
    <BR>   \end{pmatrix}
    <BR>   &
    <BR>   \begin{pmatrix}
    <BR>       21 & 34 \\
    <BR>       31 & 46
    <BR>   \end{pmatrix}
    <BR>\end{align*}
    <BR>
    <BR>Pour aligner sur cet exemple, on peut feinter avec des blancs :
    <P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><TABLE CELLPADDING="0" WIDTH="100%" ALIGN="CENTER"><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="3" HEIGHT="29" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img1.png&quot; ALT="$\displaystyle \newline$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="67" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img5.png&quot; ALT="$\displaystyle \;\begin{pmatrix}
    \newline 1 & \;2 \\
    \newline 3 & \;4
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="61" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img3.png&quot; ALT="$\displaystyle \newline \begin{pmatrix}
    \newline 5 & 6 \\
    \newline 7 & 8
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="77" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img4.png&quot; ALT="$\displaystyle \begin{pmatrix}
    \newline 21 & 34 \\
    \newline 31 & 46
    \newline \end{pmatrix}
    \newline$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR></TABLE></DIV><P></P>
    \begin{align*}
    <BR>   &\;\begin{pmatrix}
    <BR>       1 & \;2 \\
    <BR>       3 & \;4
    <BR>   \end{pmatrix}
    <BR>   \\
    <BR>   \begin{pmatrix}
    <BR>       5 & 6 \\
    <BR>       7 & 8
    <BR>   \end{pmatrix}&\begin{pmatrix}
    <BR>       21 & 34 \\
    <BR>       31 & 46
    <BR>   \end{pmatrix}
    <BR>\end{align*}

    <BR>
    <BR>
    <BR>En regardant la doc du package, on arrive à un truc un peu mieux pour l'alignement :
    <P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><TABLE CLASS="equation*" CELLPADDING="0" WIDTH="100%" ALIGN="CENTER"><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="CENTER"><SPAN CLASS="MATH"><IMG WIDTH="143" HEIGHT="144" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img6.png&quot; ALT="$\displaystyle \newline \begin{pmatrix}
    \newline 5 & 6 \\
    \newline 7 & 8
    \newl......4 \\
    \newline 31 & 46
    \newline \end{pmatrix}
    \newline \end{gathered}
    \newline$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR></TABLE></DIV><P></P>
    \begin{equation*}
    <BR>   \begin{pmatrix}
    <BR>       5 & 6 \\
    <BR>       7 & 8
    <BR>   \end{pmatrix}
    <BR>     \begin{gathered}
    <BR>       \begin{pmatrix}
    <BR>         1 & 2 \\
    <BR>         3 & 4
    <BR>       \end{pmatrix}\\
    <BR>       \begin{pmatrix}
    <BR>         21 & 34 \\
    <BR>         31 & 46
    <BR>       \end{pmatrix}
    <BR>     \end{gathered}
    <BR>\end{equation*}

    <BR>
    <BR>Le paramètre b [sans le ' ' qui le précède. AD] de l'environnement gathered permet d'aligner sur la ligne de base.
    <BR>
    <BR>On peut bien sur encore feinter avec des blancs à l'intérieur de la matrice supérieure.
    <BR>
    <BR>Si maintenant on considère l'exemple des messages précédents, ça devient un peu sale. Si je devais aligner les colonnes dans ce cas, j'utiliserai le package xypic (désolé pas le temps ce soir, concert d'Al Di Meola).<BR>
  • Arg !!! Le paramètre du gathered a été interprété comme du code html !!!!!!!
  • On peut faire un code plus simple avec le package amsmath.
    <BR>
    <BR>Première option, bourrin ...
    <BR>
    <BR><P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><TABLE CELLPADDING="0" WIDTH="100%" ALIGN="CENTER"><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="3" HEIGHT="29" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img1.png&quot; ALT="$\displaystyle \newline$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="58" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img2.png&quot; ALT="$\displaystyle \begin{pmatrix}
    \newline 1 & 2 \\
    \newline 3 & 4
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="61" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img3.png&quot; ALT="$\displaystyle \newline \begin{pmatrix}
    \newline 5 & 6 \\
    \newline 7 & 8
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="77" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img4.png&quot; ALT="$\displaystyle \begin{pmatrix}
    \newline 21 & 34 \\
    \newline 31 & 46
    \newline \end{pmatrix}
    \newline$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR></TABLE></DIV><BR CLEAR="ALL"><P></P>
    <BR>
    <BR>Pour aligner sur cet exemple, on peut feinter avec des blancs :
    <BR>
    <BR><P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><TABLE CELLPADDING="0" WIDTH="100%" ALIGN="CENTER"><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="3" HEIGHT="29" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img1.png&quot; ALT="$\displaystyle \newline$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="67" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img5.png&quot; ALT="$\displaystyle \;\begin{pmatrix}
    \newline 1 & \;2 \\
    \newline 3 & \;4
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="RIGHT"><SPAN CLASS="MATH"><IMG WIDTH="61" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img3.png&quot; ALT="$\displaystyle \newline \begin{pmatrix}
    \newline 5 & 6 \\
    \newline 7 & 8
    \newline \end{pmatrix}$"></SPAN></TD><TD NOWRAP ALIGN="LEFT"><SPAN CLASS="MATH"><IMG WIDTH="77" HEIGHT="54" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img4.png&quot; ALT="$\displaystyle \begin{pmatrix}
    \newline 21 & 34 \\
    \newline 31 & 46
    \newline \end{pmatrix}
    \newline$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR></TABLE></DIV><BR CLEAR="ALL"><P></P>
    <BR>
    <BR>
    <BR>En regardant la doc du package, on arrive à un truc un peu mieux pour l'alignement :
    <BR>
    <BR><P></P><DIV ALIGN="CENTER" CLASS="mathdisplay"><TABLE CLASS="equation*" CELLPADDING="0" WIDTH="100%" ALIGN="CENTER"><TR VALIGN="MIDDLE"><TD NOWRAP ALIGN="CENTER"><SPAN CLASS="MATH"><IMG WIDTH="143" HEIGHT="144" ALIGN="MIDDLE" BORDER="0" SRC="http://www.les-mathematiques.net/phorum/2006/11/10/101127/cv/img6.png&quot; ALT="$\displaystyle \newline \begin{pmatrix}
    \newline 5 & 6 \\
    \newline 7 & 8
    \newl......4 \\
    \newline 31 & 46
    \newline \end{pmatrix}
    \newline \end{gathered}
    \newline$"></SPAN></TD><TD NOWRAP CLASS="eqno" WIDTH="10" ALIGN="RIGHT">   </TD></TR></TABLE></DIV><BR CLEAR="ALL"><P></P>
    <BR>
    <BR>Le paramètre b [sans le ' ' qui le précède. AD] de l'environnement gathered permet d'aligner sur la ligne de base.
    <BR>
    <BR>On peut bien sur encore feinter avec des blancs à l'intérieur de la matrice supérieure.
    <BR>
    <BR>Si maintenant on considère l'exemple des messages précédents, ça devient un peu sale. Si je devais aligner les colonnes dans ce cas, j'utiliserai le package xypic (désolé pas le temps ce soir, concert d'Al Di Meola).<BR>
Connectez-vous ou Inscrivez-vous pour répondre.