Sample code in Latex:
%Chebyshev of second kind
\begin{equation}
\sum_{\ell \hiderel{=} 0}^n\frac{( \ChebyU{\ell}@{x} )^2}*{ \frac{\pi}{2} }*=\frac{ 2^n }{ \frac{\pi}{2} 2^n+1 }\frac{ \ChebyU{n+1}@{x} \ChebyU{n}@{y} - \ChebyU{n}@{x} \ChebyU{n+1}@{y} }{x-y}
\end{equation}
\frac{(\ChebyU{\ell}@{x})^2}*{\frac{\pi}{2}}
is the fraction I am looking at for this specific case. Since it is a fraction in the denominator of another fraction I would like to use Python regex to change this from a/(b/c)
to (ac)/b
.
Example output:
%Chebyshev of second kind
\begin{equation}
\sum_{\ell \hiderel{=} 0}^n\frac{(2 \ChebyU{\ell}@{x} )^2}{\pi}*=\frac{ 2^n }{ \frac{\pi}{2} 2^n+1 }\frac{ \ChebyU{n+1}@{x} \ChebyU{n}@{y} - \ChebyU{n}@{x} \ChebyU{n+1}@{y} }{x-y}
\end{equation}
End result: \frac{(2\ChebyU{\ell}@{x})^2}{\pi}
is the fraction that the regex should result in.
How would I go about doing this with regex in Python?