1
$\begingroup$

I would like to compute the product

$$(Es+r_{13})(F_{13}s)(F_{3}s+r_{3})(F_{2}s+r_{2})(F_{12}s+r_{12})(F_{1}s+r_{1})(F_{23}s+r_{23})$$

where $E$, $F_i$, and $r_i$ represent arbitrary numbers whose notation makes sense in the general problem I am working on.

When I simply copy and paste the LaTex expression into Mathematica, I get some weird stuff which clearly is not the product.

What I am doing wrong?

$\endgroup$
1
$\begingroup$
str = "(e*s+r_{13})(F_{13}s)(F_{3}s+r_{3})(F_{2}s+r_{2})(F_{12}s+r_{12})(F_{1}s+r_{1})(F_{23}s+r_{23})";
ToExpression[str, TeXForm]

(*    s Subscript[F, 13] (s Subscript[F, 1] + Subscript[r, 1])
      (s Subscript[F, 2] + Subscript[r, 2]) (s Subscript[F, 3] + Subscript[r, 3])
      (s Subscript[F, 12] + Subscript[r, 12]) (e s + Subscript[r, 13])
      (s Subscript[F, 23] + Subscript[r, 23])                     *)
$\endgroup$
3
  • $\begingroup$ Can I further ask how to ask mathematica to only show the coefficients of s^3 terms in the product? $\endgroup$ – crystal_math Jan 9 at 14:35
  • $\begingroup$ Yes, with Coefficient[%, s^3]. $\endgroup$ – Roman Jan 9 at 14:57
  • $\begingroup$ Please note that I've modified the first term from Es to e*s because Es is a single symbol. $\endgroup$ – Roman Jan 9 at 15:02
0
$\begingroup$

You can remove the space from the pasted-in LaTeX expression so your $Es$, which was interpreted as $E s$, goes back to being $Es$.

Expression as pasted in:

latex_1

which evaluates to:

mma_1

Edit the expression to:

latex_2

so it now evaluates to:

mma_2

which is what I presume you want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.