New feature: Properly shown mathematical equations

Solutions

Note: These are based on the replies below. Thanks goes to those who responded here, it was a team effort.
You can use either option or both.

  • Modify the prompt

Many find this noted by @minchien9 to be the best answer which is to modify the prompt to include such

Could you please use the specific LaTeX math mode delimiters for your response?

LaTex math mode specific delimiters as following

inline math mode : `\(` and `\)`
display math mode: insert linebreak after opening `$$`, `\[` and before closing `$$`, `\]`

(ref 1) (ref 2)

  • Use a Chrome extension

As noted by @away, use the Chrome extension TeX All the Things (ref)



Above are the solutions that work

The remainder of this reply is the original reply to the first post.


Have you tired asking ChatGPT to generate LaTeX, MathML or such?

Do not limit yourself to just text when using ChatGPT


Prompt

Show Higgs equation in LaTeX and MathML

ChatGPT Completion

The Higgs equation can be expressed using LaTeX and MathML as follows:

LaTeX:

The Higgs equation in LaTeX is:

\begin{equation}
\mathcal{L}{\mathrm{Higgs}} = (D\mu \phi)^\dagger (D^\mu \phi) - \mu^2 \phi^\dagger \phi - \lambda (\phi^\dagger \phi)^2
\end{equation}

where \mathcal{L}{\mathrm{Higgs}} is the Higgs Lagrangian, D\mu is the covariant derivative, \phi is the Higgs field, \mu^2 is the mass term, and \lambda is the self-interaction term.

MathML:

The Higgs equation in MathML is:

<math>
  <mrow>
    <mi mathvariant="script">L</mi>
    <mi mathvariant="normal">Higgs</mi>
    <mo>=</mo>
    <mo stretchy="false">(</mo>
    <msup>
      <mo mathvariant="normal">(</mo>
      <mi>D</mi>
      <mi>&#x03BC;</mi>
      <mi>&#x03C6;</mi>
      <mo mathvariant="normal">)</mo>
      <mo>&#x2020;</mo>
    </msup>
    <mo mathvariant="normal">(</mo>
    <msup>
      <mo mathvariant="normal">(</mo>
      <mi>D</mi>
      <mi>&#x03BC;</mi>
      <mi>&#x03C6;</mi>
      <mo mathvariant="normal">)</mo>
      <mo>&#x2020;</mo>
    </msup>
    <mo stretchy="false">)</mo>
    <mo>&#x2212;</mo>
    <msup>
      <mi>&#x03BC;</mi>
      <mn>2</mn>
    </msup>
    <mo mathvariant="normal">(</mo>
    <msup>
      <mi>&#x03C6;</mi>
      <mo>&#x2020;</mo>
    </msup>
    <mi>&#x03C6;</mi>
    <mo mathvariant="normal">)</mo>
    <mo>&#x2212;</mo>
    <mi>&#x03BB;</mi>
    <mo mathvariant="normal">(</mo>
    <msup>
      <mo stretchy="false">(</mo>
      <msup>
        <mi>&#x03C6;</mi>
        <mo>&#x2020;</mo>
      </msup>
      <mi>&#x03C6;</mi>
      <mo stretchy="false">)</mo>
    </msup>
    <mo>&#x2022;</mo>
    <msup>
      <mo stretchy="false">(</mo>
      <msup>
        <mi>&#x03C6;</mi>
        <mo>&#x2020;</mo>
      </msup>
      <mi>&#x03C6;</mi>
      <mo stretchy="false">)</mo>
    </msup>
    <mo stretchy="false">)</mo>
  </mrow>
</math>

where \mathcal{L}{\mathrm{Higgs}} is the Higgs Lagrangian, D\mu is the covariant derivative, \phi is the Higgs field, \mu^2 is the mass term, and \lambda


To view LaTeX as graphics, one possible site: https://quicklatex.com/

image

Note: quicklatext.com will even give you a link to view as PNG
https://quicklatex.com/cache3/f5/ql_9eb6fb9d0725171481a12ba56e86f2f5_l3.png

To view MathML as Unicode, one possible site: MathML Tester

L Higgs = ( ( D μ φ ) † ( ( D μ φ ) † ) − μ 2 ( φ † φ ) − λ ( ( φ † φ ) • ( φ † φ ) )


Discourse which is the software that runs this site has a math plugin that can render MathJax and ChatGPT can generate MathJax.

Prompt

Show Higgs equation in MathJax

ChatGPT Completion

The Higgs equation in MathJax is:

$$\mathcal{L}*{\mathrm{Higgs}} = (D*\mu \phi)^\dagger (D^\mu \phi) - \mu^2 \phi^\dagger \phi - \lambda (\phi^\dagger \phi)^2$$

where \mathcal{L}*{\mathrm{Higgs}} is the Higgs Lagrangian, D*\mu is the covariant derivative, \phi is the Higgs field, \mu^2 is the mass term, and \lambda is the self-interaction term.

To get the math expression to represent in Discourse need to put the $$ bookmarks on separate lines.

$$
\mathcal{L}*{\mathrm{Higgs}} = (D*\mu \phi)^\dagger (D^\mu \phi) - \mu^2 \phi^\dagger \phi - \lambda (\phi^\dagger \phi)^2
$$

In trying that here it did not work so I guess this site does not have the plugin enabled. On another site which does have MathJax enabled it shows as

So you can have you cake and eat it too with a little effort. :slightly_smiling_face:


ChatGPT also understands LaTeX.

Prompt

Explain

\begin{equation}
\mathcal{L}{\mathrm{Higgs}} = (D\mu \phi)^\dagger (D^\mu \phi) - \mu^2 \phi^\dagger \phi - \lambda (\phi^\dagger \phi)^2
\end{equation}

ChatGPT Completion

The equation represents the Lagrangian density of the Higgs field in the context of the Standard Model of particle physics. The Higgs field is a scalar field that is responsible for the generation of mass for elementary particles such as the W and Z bosons and the fermions.

The Lagrangian density consists of three terms:

The first term represents the kinetic energy of the Higgs field. It is given by (D\mu \phi)^\dagger (D^\mu \phi), where \phi is the Higgs field and D_\mu is the covariant derivative. The covariant derivative is used to ensure that the Lagrangian is invariant under local gauge transformations.

The second term represents the potential energy of the Higgs field. It is given by -\mu^2 \phi^\dagger \phi, where \mu is a constant parameter known as the Higgs mass parameter.

The third term represents the self-interaction of the Higgs field. It is given by -\lambda (\phi^\dagger \phi)^2, where \lambda is a positive constant parameter known as the Higgs quartic coupling.

The equation describes the behavior of the Higgs field in the presence of other particles and fields in the Standard Model. The dynamics of the Higgs field are determined by the principle of least action, which leads to the equations of motion for the field. The Higgs field is a scalar field, which means that it has a single degree of freedom, and it interacts with other particles in the Standard Model through the exchange of gauge bosons.

So just as programmers use source code or JSON data in parts of the textual stream you can also use LaTeX in parts of the textual stream for both prompts and requesting in completions. :slightly_smiling_face:

Note: When the output from ChatGPT is pasted into a Discourse post with the Math plugin active this is how it is rendered. Notice that the MathJax is rendered as math and not MathJax.

image

If @admin could activate the Discourse math plugin many of us here would appreciate it. :slightly_smiling_face:

6 Likes