I am writting my thesis and really like to be able to make some equations like the one shown in the picture but don't know how. Your help is really appreciated.


Image taken from : https://towardsdatascience.com/particle-swarm-optimization-visually-explained-46289eeb2e14


1 Answer 1


Here is my attempt with tikz:

\tikzset{mystyle/.style={minimum height=2cm,rounded corners=3mm,anchor=base,
P_i^{t+1} &= P_i^t+V_i^{t+1}\\
V_i^{t+1} &=
    \node[fill=gray!20,mystyle=Inertia\strut] (t1)
    {$w V_i^t$}} + 
    \node[fill=magenta!20,mystyle=Cognitive(Personal)] (t2)
    {$c_1 r_1\left(P_{best(i)}^t - P_i^t\right)$}} + 
    \node[fill=teal!20,mystyle=Social(Global)] (t3)
    {$c_2 r_2\left(P_{bestglobal}^t-P_i^t\right)$}}

enter image description here

  • Wow, perfect! Let me say thank you very much! Mar 4 at 14:17
  • 1
    @Andrey L. For vertical alignment of labels, I suggest putting \strut, not only for Inertia but in the command after \textsf{#1}
    – pascal974
    Mar 5 at 12:39
  • @pascal974, thanks, that's a good point.
    – Andrey L.
    Mar 5 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .