Problem with compiling formula by LaTeX

In summary: And yes, the \begin{eqnarray} ... \end{eqnarray} construction I gave is better. It's just that I've never really used the split environment myself... (I use eqnarray instead).
  • #1
linderox
9
0
I read a lot literature how to provide dividing of the formulas to new lines,but it's work just on a short one good like 1st one and doesn't on main (2nd one)
Code:
\begin{equation}\begin{split}
\Psi = & \cos kz + i\sin kz + {} \\
& {} + \frac{f(\theta)}{r}
(\cos kr + i\sin kr)
\end{split}\end{equation}

I try different ways used {split} but everything stopped on the 2nd "\\". Can anybody say me why?

Code:
\begin{equation}\begin{split}
U = U_0\cos[c_1 \cos(\omega t) + c_2 cos(\omega_1 t) + \phi] \\
=U_0 \cos\phi\left[|J_0(c_1)J_0(c_2)| + \sum_n |2J_0(c_2 )J_{2n}(c_1)|\cos 2n\omega t \\
+\sum_k|2J_0(c_1 )J_{2k}(c_2)|\cos 2k\omega_1 t + \sum_n\sum_k |2J_2n(c_1)J_{2k}(c_2)| \cos [2(k\omega_1 — n\omega)t] \\
+\sum_n \sum_k|2J_{2n}(c_1)J_{2k}(c_2)|\cos [2(k\omega_1 + n\omega)t] \\
+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1—(2n — 1)\omega]t \\
+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1+(2n — 1)\omega]t\right] \\
+U_0\sin\phi\left[\sum_n |2J_0(c_2)J_{2n-1}(c_1)|\cos[(2n—1)\omega t] \\
+\sum_k | 2J_0(c_1)J_{2k-1}(c_2)|\cos[(2k — 1)\omega_1 t] \\
+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1—(2n—1)\omega]t \\
+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1+(2n—1)\omega]t \\
+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1—2n\omega]t \\
+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1+2n\omega]t\right]
\end{split}\end{equation}
 
Last edited:
Physics news on Phys.org
  • #2
Well, the most obvious problem is you forgot the alignment character (&). I could believe that would result in the bottom part of your equation sitting a few feet past the right margin.
 
  • #3
can you write right version here?
this version for example doesn't work too!
Code:
\begin{eqnarray*}
U=U_0\cos[c_1 \cos(\omega t) + c_2 cos(\omega_1 t) + \phi] \\
& {} U=U_0 \cos\phi\left[|J_0(c_1)J_0(c_2)| + \sum_n |2J_0(c_2 )J_{2n}(c_1)|\cos 2n\omega t \\
& {} +\sum_k|2J_0(c_1 )J_{2k}(c_2)|\cos 2k\omega_1 t + \sum_n\sum_k |2J_2n(c_1)J_{2k}(c_2)| \cos [2(k\omega_1 — n\omega)t] \right]
\end{eqnarray*}
 
  • #4
I would imagine that your problem is that you are trying to split equations before you have closed the brackets (i.e. you have a \left[ but no \right] before the \\). A way to remedy this is to use phantom delimiters (\left. and \right.) , so your input would read (with additions in red):

Code:
\begin{equation}\begin{split}
U = U_0\cos[c_1 \cos(\omega t) + c_2 cos(\omega_1 t) + \phi] \\
=U_0 \cos\phi\left[|J_0(c_1)J_0(c_2)| + \sum_n |2J_0(c_2 )J_{2n}(c_1)|\cos 2n\omega t [color=red]\right.[/color]\\
+\sum_k|2J_0(c_1 )J_{2k}(c_2)|\cos 2k\omega_1 t + \sum_n\sum_k |2J_2n(c_1)J_{2k}(c_2)| \cos [2(k\omega_1 — n\omega)t] \\
+\sum_n \sum_k|2J_{2n}(c_1)J_{2k}(c_2)|\cos [2(k\omega_1 + n\omega)t] \\
+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1—(2n — 1)\omega]t \\
+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1+(2n — 1)\omega]t\right] \\
+U_0\sin\phi\left[\sum_n |2J_0(c_2)J_{2n-1}(c_1)|\cos[(2n—1)\omega t] \\
+\sum_k | 2J_0(c_1)J_{2k-1}(c_2)|\cos[(2k — 1)\omega_1 t] \\
+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1—(2n—1)\omega]t \\
+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1+(2n—1)\omega]t \\
+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1—2n\omega]t \\
[color=red]\left.[/color]+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1+2n\omega]t\right]
\end{split}\end{equation}

You should also correct the mistake that Hurkyl has pointed out.
 
  • #5
but it's it very long brackets!
 
  • #6
linderox said:
but it's it very long brackets!

Did I miss something? Is there only one set of brackets in your equation, or are there several? You should repeat the \right. \\ left. procedure for all sets of brackets. Note that this won't do anything to the appearance of the equation, but will just make it work.
 
  • #7
Yes, Cristo! It works with your version,but What I have write - it is my long formula with a beginning bracket \left[ at the 1st line and
ended bracket \right] at the end of the whole formula

i don't understand what you meant... "You should repeat the \right. \\ left. procedure for all sets of brackets..." . maybe you can give some example?
cristo said:
You should repeat the \right. \\ left. procedure for all sets of brackets. Note that this won't do anything to the appearance of the equation, but will just make it work.
2) How better present this formula?
I want to see all lines connected to the left side of the page,but not like now...
 
Last edited:
  • #8
This is how I'd typset it (I'm not really that familiar with "split")

Code:
\begin{eqnarray}
%\begin{split}
U&=& U_0\cos[c_1 \cos(\omega t) + c_2 cos(\omega_1 t) + \phi] \\
&=&U_0 \cos\phi\left[|J_0(c_1)J_0(c_2)| + \sum_n |2J_0(c_2 )J_{2n}(c_1)|\cos 2n\omega t \right.\\
&&+\sum_k|2J_0(c_1 )J_{2k}(c_2)|\cos 2k\omega_1 t + \sum_n\sum_k |2J_2n(c_1)J_{2k}(c_2)| \cos [2(k\omega_1 — n\omega)t] \\
&&+\sum_n \sum_k|2J_{2n}(c_1)J_{2k}(c_2)|\cos [2(k\omega_1 + n\omega)t] \\
&&+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1—(2n — 1)\omega]t \\
&&\left.+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1+(2n — 1)\omega]t\right] \\
&&+U_0\sin\phi\left[\sum_n |2J_0(c_2)J_{2n-1}(c_1)|\cos[(2n—1)\omega t\right. \\
&&+\sum_k | 2J_0(c_1)J_{2k-1}(c_2)|\cos[(2k — 1)\omega_1 t] \\
&&+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1—(2n—1)\omega]t \\
&&+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1+(2n—1)\omega]t \\
&&+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1—2n\omega]t \\
&&\left.+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1+2n\omega]t\right]
%\end{split}
\end{eqnarray}

i don't understand what you meant... "You should repeat the \right. \\ left. procedure for all sets of brackets..." . maybe you can give some example?
I just meant that you've got more than one set of brackets, so need to put more that one \left. and \right. in (I've done it above)
 
  • #9
Wow! great Thank! but now i have a problem counting each line... how to remove everything except the label to the formula?
 
  • #10
Code:
\begin{eqnarray}
%\begin{split}
U&=& U_0\cos[c_1 \cos(\omega t) + c_2 cos(\omega_1 t) + \phi] \\
&=&U_0 \cos\phi\left[|J_0(c_1)J_0(c_2)| + \sum_n |2J_0(c_2 )J_{2n}(c_1)|\cos 2n\omega t \right.\nonumber \\
&&+\sum_k|2J_0(c_1 )J_{2k}(c_2)|\cos 2k\omega_1 t + \sum_n\sum_k |2J_2n(c_1)J_{2k}(c_2)| \cos [2(k\omega_1 — n\omega)t] \nonumber \\
&&+\sum_n \sum_k|2J_{2n}(c_1)J_{2k}(c_2)|\cos [2(k\omega_1 + n\omega)t]\nonumber \\
&&+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1—(2n — 1)\omega]t \nonumber \\
&&\left.+\sum_n \sum_k|J_{2n-1}(c_1)J_{2k-1}(c_2)|\cos[(2k —1)\omega_1+(2n — 1)\omega]t\right] \nonumber \\
&&+U_0\sin\phi\left[\sum_n |2J_0(c_2)J_{2n-1}(c_1)|\cos[(2n—1)\omega t\right. \nonumber \\
&&+\sum_k | 2J_0(c_1)J_{2k-1}(c_2)|\cos[(2k — 1)\omega_1 t] \nonumber \\
&&+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1—(2n—1)\omega]t \nonumber \\
&&+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1+(2n—1)\omega]t \nonumber \\
&&+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1—2n\omega]t \nonumber \\
&&\left.+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k—1)\omega_1+2n\omega]t\right] \nonumber
%\end{split}
\end{eqnarray}
 
  • #11
Great thanks
 
  • #12
linderox said:
Great thanks

You're welcome :smile:
 
  • #13
hm... but why it does not work?
\be
\begin{split}
P(t)=cos\theta J_0(\alpha) + 2 \cos \theta \sum_{n=1}^\infty J_{2n}(\alpha)\cos[2n f_0 t +l_0] \\
&&-2\sin\theta \sum_{n=1}^\infty J_{2n-1}(\alpha)cos[(2n-1) f_0 t +l_0]
\end{split}
\label{equ:P_t_bessel}
\ee
 
  • #14
I'm not sure; like I said, I don't really know too much about the split command. I can see one problem, namely that you have no && in your first line. Here's another way to write it, along with the output:

Code:
\be
\begin{array}{ccc}
P(t)&=&cos\theta J_0(\alpha) + 2 \cos \theta \sum_{n=1}^\infty J_{2n}(\alpha)\cos[2n f_0 t +l_0] \\
&&-2\sin\theta \sum_{n=1}^\infty J_{2n-1}(\alpha)cos[(2n-1) f_0 t +l_0]
\end{array} 
\ee

[tex]\begin{array}{ccc}
P(t)&=&cos\theta J_0(\alpha) + 2 \cos \theta \sum_{n=1}^\infty J_{2n}(\alpha)\cos[2n f_0 t +l_0] \\
&&-2\sin\theta \sum_{n=1}^\infty J_{2n-1}(\alpha)cos[(2n-1) f_0 t +l_0]
\end{array} [/tex]
 
Last edited:
  • #15
I have a problem,
I have \left{ and a \righ} in two lines, I want them to be the same size, both big, but only one that has the summation infront of it is big

Can you please help?
thank you


\begin{eqnarray*}
\log p(\mathbf{x}_n,\mathbf{z}_n| \bm{\mu},\bm{\pi}) &=& \log \prod_{k=1}^K \left[\pi_k \, p(\mathbf{x}_n|\bm{\mu_k}) \right]^{z_{nk}} \\
&=& \sum_{k=1}^K z_{nk} \{ \log \pi_k + \log p(\mathbf{x}_n|\bm{\mu_k}) \} \\
&=& \sum_{k=1}^K z_{nk} \left\{ \log \pi_k \right. \\
&+& \left. \sum_{i=1}^D [x_{ni}\, \log \mu_{ki}+(1-x_{ni})\, \log (1-\mu_{ki})] \right\}
\end{eqnarray*}
 
  • #16
\left and \right can only be used on the same line. There are at least a couple of ways around this:

(1) Use a dummy \right. to pair with the \left{ on one line and a dummy \left. to pair with the \right} on the next line.

(2) Use bigl/bigr Bigl/Bigr biggl/biggr Biggl/Biggr in lieu of left/right.
 

What is LaTeX and why is it used for compiling formulas?

LaTeX is a typesetting software commonly used in scientific and technical fields for creating high-quality documents. It is especially useful for compiling mathematical and scientific formulas due to its advanced typesetting capabilities and ability to handle complex equations with ease.

Why am I getting errors when compiling my formula in LaTeX?

There could be multiple reasons for this, such as missing or incorrect syntax, incompatible packages, or conflicting commands. It is important to carefully check your code and consult online resources or experts for troubleshooting.

How can I include special characters or symbols in my formula using LaTeX?

LaTeX has a wide range of symbols and characters available through packages such as amssymb and amsmath. You can also use the \symbols command to insert specific symbols. It is important to ensure that the package containing the symbols you need is loaded in your document.

Can I customize the appearance of my formula in LaTeX?

Yes, LaTeX allows for a high level of customization in terms of font, size, alignment, and spacing in formulas. You can use commands such as \font and \displaystyle to make adjustments. There are also various packages available for further customization.

How can I ensure my formula looks professional and consistent with the rest of my document in LaTeX?

LaTeX has built-in templates and formatting options that can help maintain consistency in the appearance of your formula with the rest of your document. It is also important to use proper formatting techniques, such as using \begin{equation} and \end{equation} for numbered equations, to maintain a professional look.

Similar threads

  • Advanced Physics Homework Help
Replies
1
Views
676
  • Calculus and Beyond Homework Help
Replies
8
Views
119
  • Calculus and Beyond Homework Help
Replies
3
Views
358
  • Advanced Physics Homework Help
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
500
Replies
2
Views
11K
  • Advanced Physics Homework Help
Replies
7
Views
1K
  • Differential Equations
Replies
28
Views
3K
  • Introductory Physics Homework Help
Replies
5
Views
4K
  • Introductory Physics Homework Help
Replies
3
Views
160
Back
Top