Problems with left-aligning in LaTeX

$$
\begin{flalign*}
    &y' - ?&\\
	y' &= -\frac{1}{\sqrt{1 - (\sqrt{1-x^{2}})^{2}}} \cdot \frac{1}{2\sqrt{1-x^{2}}} \cdot (-2x) = \frac{1}{\sqrt{1 - 1 + x^{2}}} \cdot \frac{\cancel{2}x}{\cancel{2}\sqrt{1-x^{2}}} = \frac{1}{\sqrt{x^{2}}} \cdot \frac{{x}}{\sqrt{1-x^{2}}} =& \\
	&= \frac{\cancel{x}}{\pm \cancel{x}\sqrt{1-x^{2}}} = \pm\frac{1}{\sqrt{1-x^{2}}}&
\end{flalign*}
$$

In flalign* environment I have 3 lines:

  1. Setting up a problem to solve (y’ - ?).
  2. First line of a long math expression with \\ at the end.
  3. Second line of this expression.

What I’m trying to do

I would like it to look like this:

So, I want:

  • The first line - to be left-aligned.
  • The second line - to be left-aligned.
  • The third line (continuation of the long math expression) - to be aligned with first equal sign in the second line.

Things I have tried

I tried to play with & signs to adjust alignment to my purpose, but nothing seems to work.
The code above produces this result:

I know this code works exactly as it meant to work, but I can’t understand how to modify it to get the desired result.

Thanks in advance!

Does this give the desired result?

$$
\begin{flalign*}
    y' &- ?\\
	y' &= -\frac{1}{\sqrt{1 - (\sqrt{1-x^{2}})^{2}}} \cdot \frac{1}{2\sqrt{1-x^{2}}} \cdot (-2x) = \frac{1}{\sqrt{1 - 1 + x^{2}}} \cdot \frac{\cancel{2}x}{\cancel{2}\sqrt{1-x^{2}}} = \frac{1}{\sqrt{x^{2}}} \cdot \frac{{x}}{\sqrt{1-x^{2}}} \\
	&= \frac{\cancel{x}}{\pm \cancel{x}\sqrt{1-x^{2}}} = \pm\frac{1}{\sqrt{1-x^{2}}}
\end{flalign*}
$$

Thanks for the response!

Yes it does, but in case the first line was something like y'(100) &- ?, the second and third lines would start to shift to the right:

And I would like to have a general solution, that would work in case of any symbols in the first line (my bad, that I didn’t mention it in the start post). So I would like it to work like this:

I think this works, I used \phantom to create an invisible copy of the part of the line above.

$$
\begin{flalign*}
	&y(100)' - ? \\
	&y' = -\frac{1}{\sqrt{1 - (\sqrt{1-x^{2}})^{2}}} \cdot \frac{1}{2\sqrt{1-x^{2}}} \cdot (-2x) = \frac{1}{\sqrt{1 - 1 + x^{2}}} \cdot \frac{\cancel{2}x}{\cancel{2}\sqrt{1-x^{2}}} = \frac{1}{\sqrt{x^{2}}} \cdot \frac{{x}}{\sqrt{1-x^{2}}} \\
	& \phantom{y'} = \frac{\cancel{x}}{\pm \cancel{x}\sqrt{1-x^{2}}} = \pm\frac{1}{\sqrt{1-x^{2}}}
\end{flalign*}
$$
1 Like

Wow, thank you so much! It seems a bit like workaround, I mean if I have a 5-line expression, I need to paste \phantom in the beginning of each line after the first. But it does what I want, thank you!

I’m just wondering if there is a perfect clean solution, like may be inside flalign* block I can kinda logically separate &y(100)' - ? \\ and y' =& -\frac{1}... that they can be aligned as if they “don’t see” each other or some other solution…

What makes things difficult is that you want to align something vertical in the middle of the text on the first line.

Another solution is, kind of, to find a similar spacing for $y’$. See here:

Another solution is to replace the phantom command with a shorter custom version:

$$\newcommand{\p}{\phantom{y'}}$$

$$ \begin{flalign*} &y(100)' - ? \\
&y' = -\frac{1}{\sqrt{1 - (\sqrt{1-x^{2}})^{2}}} \cdot \frac{1}{2\sqrt{1-x^{2}}} \cdot (-2x) = \frac{1}{\sqrt{1 - 1 + x^{2}}} \cdot \frac{\cancel{2}x}{\cancel{2}\sqrt{1-x^{2}}} = \frac{1}{\sqrt{x^{2}}} \cdot \frac{{x}}{\sqrt{1-x^{2}}} \\ 
& \p = \frac{\cancel{x}}{\pm \cancel{x}\sqrt{1-x^{2}}}  \\
& \p = \pm\frac{1}{\sqrt{1-x^{2}}} 
\end{flalign*}
$$

I don’t know if there is a way to solve this with only & signs.

1 Like

Great! Thank you!

I’m not an English native speaker, so I must have misunderstood this sentence:

What makes things difficult is that you want to align something vertical in the middle of the text on the first line.

I’m not sure that I want to align something in the middle of the of the text on the first line. The only thing I want from the first line is to stick to the left.

When there is no 2-line expressions everything is good:

But when there are 2(or more)-line expressions, than I want the alignment to be generally the same as in the pic above, but align the second/third/… lines of this long expression not to the left but to the first = of the first line of this long expression.

Just thought I’d clarify it just in case, so you can make sure you understand my intentions correctly. I’m pretty sure you’ve come up with the best solution possible.

Maybe it is just better to do one step at a time in each math block. It makes things easier, something like this:

Value of $y’(100)$

To calculate the value for $y’(100)$ we first have to take the derivative of $y$:

$$
y’ = …
$$

Now we let $x=100$:

$$
y’(100) = …
$$

1 Like

That’s nice idea. I’m very grateful to you for your time and knowledge!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.