Lagrangian in LaTeX (\mathcal{L}(x, \lambda))
- LaTeX command
\mathcal{L}(x, \lambda)- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Where it is used
Lagrangian function combining an objective with its constraints weighted by multipliers lambda.
The Lagrangian is \mathcal{L}(x, \lambda, \nu) = f(x) + \sum_i \lambda_i g_i(x) + \sum_j \nu_j h_j(x), and the dual function is its infimum over x. Setting \nabla_x \mathcal{L} = 0 gives the stationarity condition used in constrained calculus problems and SVM derivations. \mathcal gives the script L and only works for uppercase letters. Because the same \mathcal{L} also denotes losses in machine learning, papers mixing both sometimes write L or \Lambda for one of them. Some textbooks use the opposite sign convention, f - \lambda g, so state yours.
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\begin{document}
Lagrangian: $\mathcal{L}(x, \lambda)$
\[ \mathcal{L}(x, \lambda) = f(x) + \sum_{i=1}^{m} \lambda_i g_i(x) \]
\end{document}Related symbols
- Lambda
\lambda - Equality Constraint
h(x) = 0 - Gradient
\nabla f(x) - Constraint
g(x) \leq 0 - Hessian
\nabla^2 f(x) - Subject To
\text{s.t.}
Frequently asked questions
- How do I write Lagrangian in LaTeX?
- Type \mathcal{L}(x, \lambda) in math mode, for example $\mathcal{L}(x, \lambda) = f(x) + \sum_{i=1}^{m} \lambda_i g_i(x)$. It works in plain LaTeX without loading any package.
- Which package do I need for \mathcal{L}(x, \lambda)?
- None. \mathcal{L}(x, \lambda) is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use \mathcal{L}(x, \lambda) in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\mathcal{L}(x, \lambda)$ in running text.
Beste AI LaTeX Editor, Overleaf Alternatief
Octree helpt onderzoekers van 15+ universiteiten sneller onderzoeksartikelen schrijven met AI
- Genereer mooie TikZ-diagrammen met AI
- Upload afbeelding en converteer naadloos naar LaTeX
- Krijg directe hulp bij het schrijven en opmaken van onderzoeksartikelen