Home
PDF (letter size)
PDF (legal size)

comparing Tikz with Mathematica for generating a classification diagram

Nasser M. Abbasi

July 22, 2013   Compiled on May 18, 2020 at 4:46pm

Currently I use Visio drawing program to make all my diagrams. I am trying to find a better alternative that is more math friendly to use.

This note compares using LaTeX with Tikz and Mathematica in order to make a small classification diagram. This diagram will contain mathematical expressions in it with text.

The Mathematica solution used the LayeredGraphPlot[] function, while the Tikz solution used tikz-qtree package.

This below gives the code used and the result in both cases. It took me about 15 hrs to do the Tikz solution with lots of help from experts at TeX stackexchange since I knew nothing about it before starting.



Tikz solution

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-qtree}
\begin{document}
\tikzset{font=\small,
 level 1/.style={level distance=2cm},level 2/.style={level distance=4cm},
 level 3/.style={level distance=2cm},
 every node/.style={draw,rectangle,rounded corners,align=center,
       text width = 120pt},wide node/.style={text width=200pt}}

\begin{tikzpicture}
    \Tree [.{second order linear partial differential equation}
      [.\node[wide node]{elliptic
        \\No characteristic curves. diffusion process  reached equilibrium, steady
          state temperature distribution. Numerically solved by relaxation methods.
        \\{$A\frac{\partial^{2}u}{\partial x^{2}}+B\frac{\partial^{2}u}
        {\partial x\partial y}+C\frac{\partial^{2}u}
        {\partial y^{2}}+D\frac{\partial u}{\partial x}+
        E\frac{\partial u}{\partial y}+Fu=G$}
        \\{$B^2-4AC<0$}
        \\{$A=1,C=1,B=0$}};
     [.{{$F=0$}
        \\a function that satisfies Laplace is called harmonic}
           [.{{$G=0$}
             \\Laplace in 2D
             \\{$ \frac{\partial^{2}u}{\partial x^{2}}+
                  \frac{\partial^{2}u}{\partial y^{2}}=0 $}}
           ]
           [.{{$G=g(x,y)$}
                 \\Poisson in 2D
                 \\{$ \frac{\partial^{2}u}{\partial x^{2}}+
                      \frac{\partial^{2}u}{\partial y^{2}}=g(x,y) $}}
           ]
     ]
          [.{$F=k^2$}
             [.{{$G=0$}
               \\homogeneous Helmholtz
               \\{$ \frac{\partial^{2}u}{\partial x^{2}}+
                    \frac{\partial^{2}u}{\partial y^{2}} +
                    k^2 u=0 $}\\eigenvalue equilibrium}
             ]
             [.{{$G=g(x,y)$}
                \\inhomogeneous Helmholtz
                \\{$ \frac{\partial^{2}u}{\partial x^{2}}+
                     \frac{\partial^{2}u}{\partial y^{2}} +
                     k^2 u=g(x,y) $}\\steady state oscillation}
             ]
          ]
     ]
     [.parabolic ]
     [.hyperbolic ]
    ]
\end{tikzpicture}
\end{document}

pict



Mathematica solution

SetDirectory[NotebookDirectory[]];
pde = TraditionalForm@
   Defer[A D[u[x, y], {x, 2}] + B D[u[x, y], x, y] +
      C D[u[x, y], {y, 2}] + "D" D[u[x, y], x] + "E" D[u[x, y], x] +F u[x, y] == G];

elliptic = Column[{"elliptic", "No characteristic curves",
  "diffusion process  reached equilibrium, steady state temperature distribution",
  "Numerically, solved by relaxation methods",
  pde, B^2 - 4 A C < 0, Row[{A == 1, ",", C == 1, ",", B == 0}] },
  Alignment -> Center];

lev1 = Column[{"F=0",
              Style["function that satisfies Laplace is called harmonic", 10]},
              Alignment -> Center];

lev2 = "F=k^2";

helmholtz1 = Column[{"G=0", Style["homogeneous", 10],
  TraditionalForm@Defer[D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] + k^2 u[x, y] ==
   0], "eigenvalue equilibrium"}, Alignment -> Center];

helmholtz2 = Column[{TraditionalForm@Defer[G == g[x, y]],
    Style["inhomogeneous", 10],
    TraditionalForm@Defer[D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] + k^2 u[x, y] ==
       g[x, y]], "steady state oscillation"}, Alignment -> Center];

laplace = Column[{TraditionalForm@Defer[G == 0],
    Style["Laplace PDE in 2D", 10],
    TraditionalForm@Defer[D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == 0]},
   Alignment -> Center];

poisson =   Column[{TraditionalForm@Defer[G == g[x, y]],
    Style["Poisson PDE in 2D", 10],
    TraditionalForm@Defer[D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == g[x, y]]},
   Alignment -> Center];

r = Framed@LayeredGraphPlot[{"second order PDE's" -> elliptic,
    "second order PDE's" -> "parabolic",
    "second order PDE's" -> "hyperbolic",
    elliptic -> lev1, elliptic -> lev2,    lev1 -> laplace,
    lev1 -> poisson, lev2 -> helmholtz1,  lev2 -> helmholtz2},
   VertexLabeling -> True,
   VertexRenderingFunction -> (Inset[
       Framed[Style[#2, 14], Background -> White,
        FrameStyle -> Gray], #1, {Center, Top}] &),
   AspectRatio -> .7, DirectedEdges -> False,
   PlotRangePadding -> Automatic, ImageSize -> {1000, 800}]

pict