[Tex/LaTex] Equation with two separate answers

amsmathequationshorizontal alignmentnumbering

\begin{equation}
\begin{aligned}
    2x^2+x &= 0 &\\
    x(2x+1) &= 0 &\\
\end{aligned}
\end{equation}
\begin{equation*}
\begin{aligned}
    x &= 0 & 2x+1 &=0\\
    & & 2x &=-1\\
    & & x &=-\frac{1}{2}
\end{aligned}
\end{equation*}

enter image description here

I have one equation that I'm solving step by step. After using the zero-product property, the equation solution splits into two equations. I need the two equations to be aligned, but not with the first one (equal signs in first two lines not aligned with the second two lines). I still want the results and equation to be numbered as one equation (now the number is in a wrong place).

After all that I want the another result to be cancelled like \cancel{x = 0} and the other to be double-underlined as the final result \underline{\underline{x=-1}}.

Any suggestions how to complete this code?

Best Answer

You could use forest or tikz-cd to illustrate these things.

\documentclass{article}
\usepackage[edges]{forest}
\begin{document}

\begin{forest}
forked edges,
for tree={edge+={thick,-stealth},math content}
[{2x^2+x=0}
 [{x(2x+1)=0}
  [{x=0},tier=f
  ]
  [{2x+1=0}
   [{x=-\frac{1}{2}},tier=f]
  ]
 ] 
]
\end{forest}
\end{document}

enter image description here

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[every arrow/.append style={Leftrightarrow},column sep=0em]
 &  2x^2+x=0 \arrow[d]& \\
 & x(2x+1)=0 \arrow[dr,Leftarrow] \arrow[ddl,Leftarrow]& \\
 & & 2x+1=0 \arrow[d]\\
 x=0 & \lor & x=-\frac{1}{2} \\
\end{tikzcd}
\end{document}

enter image description here

Or with crossed out results.

\documentclass[fleqn]{article}
\usepackage{tikz-cd}
\usepackage[edges]{forest}
\usetikzlibrary{shapes.misc}
\begin{document}
\section*{With \texttt{forest}}
\[\begin{forest}
forked edges,
for tree={edge+={thick,-stealth},math content,
if n children=0{tier=f}{}}
[{2x^2+x=0}
 [{x(2x+1)=0}
  [{x=0},cross out,draw=red]
  [{2x+1=0}
   [{x=-\frac{1}{2}}]
  ]
 ] 
]
\end{forest}\]

\section*{With \texttt{tikz-cd}}
\[\begin{tikzcd}[every arrow/.append style={Leftrightarrow},column sep=0em]
 &  2x^2+x=0 \arrow[d]& \\
 & x(2x+1)=0 \arrow[dr,Leftarrow] \arrow[ddl,Leftarrow]& \\
 & & 2x+1=0 \arrow[d]\\
 |[cross out,draw=red]|x=0 & \lor & x=-\frac{1}{2} \\
\end{tikzcd}\]

\end{document}

enter image description here

Related Question