Register to reply

Problem with compiling formula by LaTeX

by linderox
Tags: compiling, formula, latex
Share this thread:
linderox
#1
May26-08, 02:48 AM
P: 9
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)
\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 stoped on the 2nd "\\". Can anybody say me why?


\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[(2n1)\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(2n1)\omega]t \\
+\sum_n \sum_k|2J_{2n-1}(c_1)J_{2k}(c_2)|\cos[2k\omega_1+(2n1)\omega]t \\
+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k1)\omega_12n\omega]t \\
+\sum_n \sum_k|J_{2n}(c_1)J_{2k-1}(c_2)|\cos [(2k1)\omega_1+2n\omega]t\right]
\end{split}\end{equation}
Phys.Org News Partner Science news on Phys.org
FIXD tells car drivers via smartphone what is wrong
Team pioneers strategy for creating new materials
Team defines new biodiversity metric
Hurkyl
#2
May26-08, 03:15 AM
Emeritus
Sci Advisor
PF Gold
Hurkyl's Avatar
P: 16,091
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.
linderox
#3
May26-08, 03:22 AM
P: 9
can you write right version here?
this version for example doesn't work too!
\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*}

cristo
#4
May26-08, 03:23 AM
Mentor
cristo's Avatar
P: 8,316
Problem with compiling formula by LaTeX

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):

\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 \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 \\
+\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 \\
\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{equation}
You should also correct the mistake that Hurkyl has pointed out.
linderox
#5
May26-08, 03:38 AM
P: 9
but it's it very long brackets!!!
cristo
#6
May26-08, 03:45 AM
Mentor
cristo's Avatar
P: 8,316
Quote Quote by linderox View Post
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.
linderox
#7
May26-08, 03:46 AM
P: 9
Yes, Cristo! It works with your version,but What I have write - it is my long formula with a begining bracket \left[ at the 1st line and
ended bracket \right] at the end of the whole formula

i dont understand what you meant... "You should repeat the \right. \\ left. procedure for all sets of brackets..." . maybe you can give some example?
Quote Quote by cristo View Post
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...
cristo
#8
May26-08, 03:57 AM
Mentor
cristo's Avatar
P: 8,316
This is how I'd typset it (I'm not really that familiar with "split")

\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 dont 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)
linderox
#9
May26-08, 04:08 AM
P: 9
Wow!!! great Thank! but now i have a problem counting each line... how to remove everything except the label to the formula?
cristo
#10
May26-08, 04:12 AM
Mentor
cristo's Avatar
P: 8,316
\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}
linderox
#11
May26-08, 05:39 AM
P: 9
Great thanks
cristo
#12
May26-08, 05:40 AM
Mentor
cristo's Avatar
P: 8,316
Quote Quote by linderox View Post
Great thanks
You're welcome
linderox
#13
May26-08, 06:14 AM
P: 9
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
cristo
#14
May26-08, 06:20 AM
Mentor
cristo's Avatar
P: 8,316
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:

\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]
imanius
#15
Dec8-08, 09:35 AM
P: 2
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*}
D H
#16
Dec8-08, 09:51 AM
Mentor
P: 15,167
\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.


Register to reply

Related Discussions
C++ code not compiling correctly Programming & Computer Science 3
Latex Formula Math & Science Software 5
LaTeX problem General Math 6
Another LaTeX problem Math & Science Software 2
Having trouble compiling a SAW routine Programming & Computer Science 1