0
$\begingroup$

I want Mathematica to invert a matrix in which all variables are symbolic including Subscript. Now I am guessing this has something to do with the method I'm defining the variables in the summation, especially the use of Subscript.

But I am worried that since Subscript are for presentation purposes, I don't want to use them and I looking for an alternate way to do this.

As an example, consider the matrix below

A = { {F11 * Sum[Subscript[towpx^2, i], {i, 1, n}] + 
 F22 * Sum[Subscript[fpx^2, i], {i, 1, n}], 
Sum[F11 * Subscript[towpx, i], {i, 1, n}]*
  Sum[Subscript[towpy, i], {i, 1, n}] + 
 F22 * Sum[Subscript[fpx, i], {i, 1, n}]*
  Sum[Subscript[fpy, i], {i, 1, n}] } , { 
F11* Sum[Subscript[towpx, i], {i, 1, n}]*
  Sum[Subscript[towpy, i], {i, 1, n}] + 
 F22 * Sum[Subscript[fpx, i], {i, 1, n}]*
  Sum[Subscript[fpy, i], {i, 1, n}]  , 
F11 * Sum[Subscript[towpy^2, i], {i, 1, n}] + 
 F22 * Sum[Subscript[fpy^2, i], {i, 1, n}]} };

How can I Invert a matrix that needs to have variables with Subscript for display?

I am very new to Mathematicaand don't understand any of the stuff in general posts regarding correct syntax usages (Apologies if the post isn't appropriate)

Thanks in advance!

$\endgroup$
6
  • 4
    $\begingroup$ "simplest possible way on how to deal with this issue" - avoid subscripts for computational work, and reserve them for formatting; they're more trouble than they're worth. $\endgroup$ Commented Sep 27, 2017 at 11:13
  • 2
    $\begingroup$ Inverse[A] works for me. $\endgroup$
    – Michael E2
    Commented Sep 27, 2017 at 11:13
  • $\begingroup$ @J.M. okay, thank you. but what alternative would you suggest? $\endgroup$
    – S. Khan
    Commented Sep 27, 2017 at 11:16
  • $\begingroup$ @MichaelE2 , yes it does. But I am worried that since subscripts are for presentation purposes, I don't want to use them and I looking for an alternate way to do this. $\endgroup$
    – S. Khan
    Commented Sep 27, 2017 at 11:19
  • 2
    $\begingroup$ (1) You might want to edit the question to clarify what you want, since I read the main issue as "I want Mathematica to invert a matrix." (2) The same problem exists for mathematical papers in general. One idea is to represent each type of sum by its own short symbol/variable/string. Or just $A^{-1}$, since formulas for inverses are often unreadably complicated. $\endgroup$
    – Michael E2
    Commented Sep 27, 2017 at 11:33

1 Answer 1

5
$\begingroup$

Rewrite your matrix (notice I'm fixing a the erroneous Subscript[towpx^2, i] that should be Subscript[towpx, i]^2.

b = A /. {Subscript[Power[var_, exp_], index_] -> 
    Power[var[index], exp], Subscript[var_, index_] -> var[index]}

Define an UpValue rule for displaying var[index] as Subscript[var,index] for the vars of interest.

(# /: Format[#[i_]] := Subscript[#, i]) & /@ {fpx, fpy, towpy, towpx}

now

Mathematica graphics

but the FullForm, i.e the form Mathematica uses for internal calculations, is still free of Subscript

Mathematica graphics

and the inverse is just

Inverse[b]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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