display square of derivative in LaTeX needs parenthesis

asked 2023-10-19 17:33:57 +0200

QMeqGR gravatar image

Using %display latex

diff(x,t)^2 is displayed in LaTeX as

\frac{\partial}{\partial t}x^2

This is confusing when looking at the LaTeX output. It should have an extra set of parenthesis

(\frac{\partial}{\partial t}x)^2

Is there a way to get this to display correctly, or to use \frac{\partial x}{\partial t}?

edit retag flag offensive close merge delete


Indeed :

sage: latex(diff(x,t)^2)
\frac{\partial}{\partial t}x\left(t\right)^{2}

i e. $\frac{\partial}{\partial t}x\left(t\right)^{2}$.


sage: latex(diff(x^2,t))
2 \, x\left(t\right) \frac{\partial}{\partial t}x\left(t\right)

i.e. $2 \, x\left(t\right) \frac{\partial}{\partial t}x\left(t\right)$.

No ambiguity there...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-10-20 08:38:25 +0200 )edit