Math & ScienceErroneous Code for Equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Amitavo Roy
Posts: 14
Joined: Sat Apr 06, 2013 11:50 am

Erroneous Code for Equation

Post by Amitavo Roy »

I am new in LaTeX. Could some body explain me what is wrong in this code as it always show me "missing } inserted"

Code: Select all

\begin{equation}
{\vec R}_{k,n,i}=
\mu_0 \sum_j \frac{I_{B,j}}{u_{\parallel,j,n,i}}
\left[G_{e,k,j,n,i}e^{-jm\varphi_{e,i}} \cdot
e^{j(\omega_k-\Omega_f)t}\right]_n \cdot
\left(j\Omega_0 \cdot \frac{\vec p_{j,n,i}}{\gamma_{j,n,i}}+
{\underbrace{\left(\frac{\gamma^2_{j,n,i}-1}{u^2_{\parallel,j,n,i}}\right){\overbrace{\left(\frac{1}{2B_{R,n}}\frac{dB_{R,n}{dz}}\right)}^{Mag_n}}\cdot
\frac{{\vec p}_{j,n,i}}{\gamma_{j,n,i}}}_{D_n}}\right)
\end{equation}
Last edited by Stefan Kottwitz on Sat Apr 06, 2013 2:37 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

Re: Erroneous Code for Equation

Post by Stefan Kottwitz »

Check that all your opening and closing braces match. Write with more spaces to better see it, or temporarily split your complex equation in parts to localize the error.

Btw. don't choose a topic title "Help me" but a title which briefly describes a problem. Your topic has been renamed.

Stefan
LaTeX.org admin
Amitavo Roy
Posts: 14
Joined: Sat Apr 06, 2013 11:50 am

Re: Erroneous Code for Equation

Post by Amitavo Roy »

Thanks stefan for your help...

I follow your instruction...but still showing me the same error...
waiting for your valuable suggestion
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

Re: Erroneous Code for Equation

Post by Stefan Kottwitz »

I understand. So if you already made your code better readable, by inserting spaces, indenting lines, or similar, you could post it here again. The code above is still hardly readable, most people would habe problems in locating unmatched braces.

Stefan
LaTeX.org admin
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Erroneous Code for Equation

Post by svend_tveskaeg »

It took me some time to dissect the code. (As Stefan says, it is very messy.)

I finally found the problem; \frac{dB_{R,n}{dz}} should be \frac{dB_{R,n}}{dz}.

Here is an attempt to make it more readable:

Code: Select all

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{gather}
\begin{split}
 \vec{R}_{k,n,i}
 &= \mu_0 \sum_j\frac{I_{B,j}}{u_{\parallel,j,n,i}}
 \left[
  G_{e,k,j,n,i}e^{-jm\varphi_{e,i}} \cdot e^{j(\omega_k-\Omega_f)t}
 \right]_n\\
 &\hphantom{{}=\mu_0 \sum_j}
  \cdot
 \left(
  j\Omega_0 \cdot \frac{\vec p_{j,n,i}}{\gamma_{j,n,i}}+
   \underbrace{
    \left(
     \frac{\gamma^2_{j,n,i}-1}{u^2_{\parallel,j,n,i}}
    \right)
    \overbrace{
     \left(
      \frac{1}{2B_{R,n}}
      \frac{dB_{R,n}}{dz}
     \right)
    }^{Mag_n}
   \cdot \frac{{\vec p}_{j,n,i}}{\gamma_{j,n,i}}
   }_{D_n}
 \right)
\end{split}
\end{gather}

\end{document}
Output.
Output.
output.jpg (44.9 KiB) Viewed 6319 times
Note the use of \hphantom (and especially {} before =) to get the correct vertical alignment when the equation is split over two (in general, more than one) lines. Furthermore, the {gather} and {split} environments inside one another are used to vertically center the equation number.

P.S. If you use Emacs, putting the following code in your .emacs file will let you detect matching brackets easier:

Code: Select all

(show-paren-mode t)
Last edited by svend_tveskaeg on Wed Apr 10, 2013 7:48 pm, edited 6 times in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Amitavo Roy
Posts: 14
Joined: Sat Apr 06, 2013 11:50 am

Re: Erroneous Code for Equation

Post by Amitavo Roy »

Thanks a lot svend_tveskaeg...
Yes it is perfect now...
Post Reply